Authentication
Bazaar provides authentication out-of-the-box allowing you to create and authenticate users securely and easily.
Authorization is provided with the Permissions API.
Log in and Sign up
Log in and Sign up are conveniently combined into a single method call:
Calling the login
method opens a pop-up window by default, which falls back to redirect login if the pop-up fails to open.
Optionally, you can set a login type:
Available LoginType
are
POPUP_FALLBACK
: Complete auth in a popup window but fall back to redirect if popup creation fails (default).POPUP
: Complete auth in a popup window.REDIRECT
: Complete auth via a redirect. This may case the site to loose context (temporary, unsaved data).
Log Out
A utility method to delete an auth token from local storage and perform a page refresh.
Check if a User is Logged In
A utility method to check if an auth token is set in local storage.
Handle a Successful Login Event
Logging in takes place without a page fresh, so you need a way to handle a successful login event. To do so, set a callback as the first and only argument of onLogin
:
Handle a Login Error Event
Handle a login error event: