getLoginEmail(): string¶
The getLoginEmail
method allows to get an email that a given user logs in with. The user must be authorized in order to perform this action.
Returned value¶
A returned value has a type of string
that represents an email of a currently authorized user.
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);
}
});