Authentication
SALVO-TS provides some functions to help you manage customer authentication in Shopify. These are available on the Auth singleton object.
You can access Auth in components or pages via this.auth. If you need to use it from elsewhere, import the Theme instance and access it it there:
typescript// Inside componentawait this.auth.logout();// Inside pageawait this.auth.logout();// Inside other fileimport theme from '@/theme';await theme.auth.logout();
typescript// Inside componentawait this.auth.logout();// Inside pageawait this.auth.logout();// Inside other fileimport theme from '@/theme';await theme.auth.logout();
After the customer has logged in, you can access their details via auth.customer - see the Customer documentation for more information.
Standard Shopify Auth
Login
Logout
External Auth via Multipass
For Shopify Plus projects which involve an ESC-Shopify Multipass Integration, SALVO-TS provides some simple helper functions for communicating with the auth service.
Hosted Login
typescript// This will perform a redirect to the auth service, then// return the user to the specified URL.this.auth.multipass.hostedLogin({service: 'https://example.eastsidecoapps.io/',redirect: window.location.href,});
typescript// This will perform a redirect to the auth service, then// return the user to the specified URL.this.auth.multipass.hostedLogin({service: 'https://example.eastsidecoapps.io/',redirect: window.location.href,});
Inline Login
If the project supports it, you can login via Multipass directly.
typescriptawait this.auth.multipass.inlineLogin({// exact options will depend on the Multipass integrationemail: 'foo@example.com',password: 'password123',});
typescriptawait this.auth.multipass.inlineLogin({// exact options will depend on the Multipass integrationemail: 'foo@example.com',password: 'password123',});