Search.../

login( )

Logs a user in based on email and password.

Description

The login() function returns a Promise that resolves to a session token used to log a user into your site.

The returned sessionToken must be applied using the applySessionToken() function in client-side code to complete the login.

Authorization

Request

This endpoint does not take any parameters

Response Object

Fulfilled - Session token for logging the user in. Rejected - Error message.

Returns an empty object.

Status/Error Codes

Was this helpful?

Log in a user

This example contains a backend function which returns a session token to be used in client-side code to log in the user with the given email and password.

Copy Code
1import wixUsersBackend from 'wix-users-backend';
2
3export function myBackendFunction(email, password) {
4 return wixUsersBackend.login(email, password)
5 .then( (sessionToken) => {
6 return {sessionToken, "approved": true};
7 } )
8 .catch( (error) => {
9 return {"approved": false, "reason": error};
10 } );
11}
12