Chord OMS
...
Gatsby
SDK Reference
useAuth
9min
the useauth hook returns a series of methods that enable authentication with a shopify customer account import { useauth } from '@chordcommerce/gatsby theme performance' const { isloggedin, status, gettoken, login, logout, recover, register, resetpassword } = useauth() isloggedin boolean indicating whether a user is currently logged in status string indicating the status of authentication in redux this string can be used to determine if the authentication status has been verified yet, which happens asynchronously after page load example import { useauth, authstatus } from '@chordcommerce/gatsby theme performance' const { status } = useauth() if (status === authstatus failed) { // the authentication session has been checked and there is no current valid session } gettoken() retrieves the current shopify customer access token example const token = await gettoken() login() submits the email address and password for a shopify customer and initiates an authentication session this method creates a shopify customer access token example await login({ email 'test\@test com', password 'testtest' }) logout() clears the authentication session this method destroys the current shopify customer access token example await logout() recover() sends a shopify reset password email to the customer example await recover('test\@test com') register() creates a new shopify customer and initiates an authentication session this method creates a shopify customer access token example await register({ email 'test\@test com', password 'testtest' }) resetpassword() resets a shopify customerβs password with an id and token from a shopify reset password email example await resetpassword({ id 'id', password 'testtests', // the new password token '123' })