Login issue- Cannot direct to dynamic page after login

@aphrsmgmtsb First you should register then try the login process

@ajithkrr I try to register and confirm the email. Then I proceed to login but not come out anything. The email already become site member.

@aphrsmgmtsb Could you try registering another user…
…or check your live database if there is any field for that email which already became the site member

I have the same issue & I discovered that I could not use an email address as part of a dynamic page URL. Try it on your browser’s address bar - you will find a 404 page not found when you use email in the page address. It probably doesn’t allow using @ in a URL?

My solution is this

  • I have a database of Students grades with 9 char student number as the primary key
  • I have uploaded the students data to this database
  • their email address are “student number@…”
  • I strip out the unique student number from the 1st 9 characters of the email address & use this to access their dynamic page of grades

This works for me - hope it helps?

Now I have to setup their registration process

import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
 
$w.onReady(function(){  
    $w('#loginNow').onClick(function (){    
 let email = $w('#loginEmail').value;    
 let password = $w('#loginPassword').value;  
        wixUsers.login(email,password)  
        .then(()=>{
                var res = email.substr(0, 9);
                wixLocation.to(`/students/${res}`);    
            })
        })
    })

Trying to refine this further: I wanted to use the member area app to control login/logout/password checking/email resetting, etc.

This uses PrivateMembersData database & two of the fields (nickname & slug) contain exactly what I want - the student no (which is the part of the email address before @) so I thought I would use the nickname field as my student number for the logged in student’s dynamic URL page display i.e his grades & feedback comments

Here’s my code - I put it on the master page so it would work on any page in the website

import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';

$w.onReady(function () {

 if (wixUsers.currentUser.loggedIn) {
 let user = wixUsers.currentUser;
        wixData.query("Members/PrivateMembersData")
            .eq("_id", wixUsers.currentUser.id)
            .find()
            .then((results) => {
 let nickname = results.items[0].nickname;
                wixLocation.to(`/Students/${nickname}`);
            })
    }
});