The AuthService is used to retrieve all user-related data and authenticate the user. You can import the AuthService from the experro-storefront package.
import { AuthService } from 'experro-storefront';
Here is a list of functions that the AuthService provides.
  1. isUserLoggedIn
  2. getUserDetails
  3. setUserDetails
  4. login
  5. logout
  6. signup
  7. forgotPassword

isUserLoggedIn

This function returns either false or true to indicate whether the user is logged in or not.
const isLoggedIn = AuthService.isUserLoggedIn();

getUserDetails

This function returns the user details including cart, store, and user information.
const userObj = AuthService.getUserDetails();

setUserDetails

This function is used to update the details of the user. It takes userDetails as the parameter.
const userObj = AuthService.setUserDetails(userDetails);

login

This function is used to login to the base theme. The function accepts an object with username and password as two properties.
const userObj = AuthService.login({username, password});

logout

This function logs you out from the base theme.
AuthService.logout();

signup

This function is used to register the user details. This function accepts an object with firstName, lastName, email, password, phone, company, and customFields as properties of the object.
const user = AuthService.signup({
  firstName,
  lastName,
  email,
  password,
  phone,
  company,
  customFields,
});

forgotPassword

The function is used to reset the password. This function accepts an object with email as the property of the object.
const res = AuthService.forgetPassword({ email });