Indicates whether the site visitor is a logged-in member.
The loggedIn()
function returns a boolean value
indicating whether the current visitor is logged in as a site member.
If a member is logged in, loggedIn()
returns true
.
Otherwise, loggedIn()
returns false
.
function loggedIn(): Promise<boolean>;
import { authentication } from "@wix/site-members";
// ...
const isLoggedIn = await authentication.loggedIn();
if (isLoggedIn) {
console.log("Member is logged in");
} else {
console.log("Member is not logged in");
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Logs a registered member in with an email and password.
The login()
function returns a Promise that resolves when the member with
the specified email address and password is logged in.
The login()
function only works with existing members. To register a new member use
the register()
function.
Note:
wix-members-frontend
are only partially functional when previewing your site.
View a published version of your site to see their complete functionality.
Login email address.
Member password.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Logs the current member out of the site.
The logout()
function logs the current member out of the site.
Notes:
The APIs in wix-members-frontend
are only partially functional when previewing your site.
View a published version of your site to see their complete functionality.
The APIs in wix-members-frontend
can only be used once the page has loaded. Therefore,
you must use them in code that is contained in or is called from the
onReady() event handler or any element event handler.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Sets the function that runs when a member logs in.
The onLogin()
event handler runs when a member logs into your site.
onLogin
receives a currentMember
object for the logged-in member,
which contains the CurrentMember
methods
you can use to retrieve the member's information.
Usually, you want to call onLogin()
in the masterPage.js file in the
code editor so that the onLogin()
event handler runs no matter which
page a member uses to log in.
Notes:
The APIs in wix-members-frontend
are only partially functional when previewing your site.
View a published version of your site to see their complete functionality.
The APIs in wix-members-frontend
can only be used once the page has loaded. Therefore,
you must use them in code that is contained in or is called from the
onReady() event handler or any element event handler.
handler(currentMember: CurrentMember): void
Function name or expression to run when a member logs in.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.