setLoginEmail(email: string): void¶
The setLoginEmail
method allows to set an email that a given user logs in with. The user must be authorized in order to perform this action.
Input parameters¶
email¶
email
is a mandatory parameter of the string
type which represents an email address that we want to set.
Returned value¶
A returned value has a type of void
.
Example¶
In this example we make a AuthenticationApi
call to get an email of a currently authorized user with the getLoginEmail
method and if it's different than the email we want to set, we call a setLoginEmail
to change it.
useStorefront(async (storefront) => {
const authenticationApi = await storefront.getApi('AuthenticationApi');
const emailToSet = 'differentemail@example.com';
const currentEmail = authenticationApi.getLoginEmail();
if (currentEmail !== emailToSet) {
authenticationApi.setLoginEmail(emailToSet);
}
});