getAuthStatus(): TAuthenticationStatus¶
The getAuthStatus
method allows to check what is the current status of the authentication.
Returned value¶
A returned value has a type of TAuthenticationStatus
. Find out more about TAuthenticationStatus type here.
Example¶
In this example we make a AuthenticationApi
call to check the auth status. If no user is authorized a login modal will be displayed with the help of openLoginModal method.
useStorefront(async (storefront) => {
const authenticationApi = await storefront.getApi('AuthenticationApi');
const authStatus = authenticationApi.getAuthStatus();
if (authStatus === 'unauthorized') {
await authenticationApi.openLoginModal();
}
});
Authentication API methods reference¶
- selectAuthStatus$
- selectIsAuthorized$
- isAuthorized
- login
- logout
- resetPassword
- setLoginEmail
- getLoginEmail
- selectLoginEmail$
- register
- getAdditionalFieldsForRegistration
- openLoginModal
- closeLoginModal
- openRegisterModal
- closeRegisterModal
- openRemindPasswordModal
- closeRemindPasswordModal