Greetings Fellow Wixers
I hope that all is well
I humbly require any assistance in educating me on how to create a custom signup/login page for my site utilizing the wix-members API versus wix-users. Essentially I followed the guidelines presented at the URL below but altered the code to use wix-members api instead of wix-users but things do not appear to be functioning correctly (probably user error because iâm a noob)
wixfix | custom-login-sign-up-pages
My Code & Data
o For testing Iâm using three pages: signup page (to collect user input via forms and store into âMemberinfoâ dataset AND register to the site), login page (to allow user to enter email/password and login to site| this is the part thatâs not working), and a âblankâ page that the user goes to automatically after logging in.
o signup page
(page permission: everyone can view)
(Memberinfo dataset permission)
(Memberinfo dataset permission: see image)
Code:
import { authentication } from âwix-membersâ ;
import wixLocation from âwix-locationâ ;
$w . onReady ( function ()
{
$w ( â#submitButtonâ ). onClick ( function ()
{
//Submit User & Pass to âContactâ CRM
let email = $w ( â#registerEmailâ ). value ;
let password = $w ( â#registerPasswordâ ). value ;
//Register User data to contact/site | email, password, & alias
authentication . register ( email , password ,
{
//Created custom 'alias' (username) field in CRM and I capture that data from my form and register it as well
contactInfo :
{
"Alias" : $w ( '#registerAlias' ). value ,
}
})
console . log ( "Registered New User!" )
. then ( ( result ) =>
{
**let** resultStatus = result.status ;
})
})
});
//If someone select âPCâ for selection tag then show option to enter RAM and GPU
export function registerSystemsowned_change ( event )
{
if ( $w ( â#registerSystemsownedâ ). selectedIndices . includes ( 11 ) )
{
$w ( â#registerRAMâ ). show ( âfadeâ );
$w ( â#registerGPUâ ). show ( âfadeâ );
console . log ( âUser selected PC during signupâ );
}
}
//Link to take folks to âLoginâ page if they already have an account
export function text44_click ( event )
{
console . log ( âLINK: signup > loginâ )
wixLocation . to ( â/loginâ )
}
o login page
(page permission: everyone can view)
(No dataset added to page, because the login function uses the âsite memberâ data right?)
Code:
import { authentication , currentMember } from âwix-membersâ ;
import wixLocation from âwix-locationâ ;
$w . onReady ( function ()
{
$w ( â#loginButtonâ ). onClick ( function ()
{
let email = $w ( â#loginEmailâ ). value ;
let password = $w ( â#loginPasswordâ ). value ;
//Logs users in based on the email & password entered right?
authentication . login ( email , password )
. then (() =>
{
**let** user = currentMember . getMember ()
console . log ( user )
wixLocation . to ( '/blank' )
})
})
});
//Link to take folks to Sign Up page
export function text44_click ( event )
{
console . log ( âLINK: login > signupâ )
wixLocation . to ( â/sign-upâ )
}
o blank page
(page permission: members only)
code:
import { authentication , currentMember } from âwix-membersâ ;
import wixLocation from âwix-locationâ ;
$w . onReady ( function ()
{
console . log ( âA member logged in and this is a member only pageâ )
let user = currentMember . getMember ()
let userRole = currentMember . getRoles ()
console . log ( user )
console . log ( userRole )
});
When I publish my site and login with the credentials for a created user it does go to the blank page but the log does not show that a user is actually logged in.
Questions:
-
In finer detail, what is occuring when we execute authentication.register(email, password)? This is taking user input and registering them with your site by adding their data to the âsite memberâsâ portion under CRM correct? There password is saved by the site but hidden correct?
-
In finer detail, what is occuring when we execute authentication.login(email,password)? Is this taking the entered input from the user (email & password), and comparing it to what is in the CRM (site member page) to determine if its valid and if so logging the user into the site?
-
Does this generate some special ID or token that is attached to the logged in user for their duration that they are on the site until they log out?
-
Anyone have any easy to understand code that will generate a message if the login credentials are not valid (i.e not a signed up user/credentials not in the site members database) âi.e. Sorry credentials are not valid, sign up if you are not a memberâ. Iâm always looking for more wix-members examples
-
Anyone have examples of how to check for the current user using wix-members? Do I just use currentmember.getMember() and print that to the console to see who my site is detecting as logged in
-
All my code is on the individual pages, is there anything I need to put on the global pages to help with login issues?
Sorry for the super long post, been hacking away at this for some time and iâm probably mission 1 or 2 small things but I need some help. Thank you to anyone who could offer any idea, or advice. One day when my site is making millions, I will remember the help and throw you a few bones
aLvin