Upgrade Passage-Elements to v2
Breaking changes from Passage Elements v1 to v2
PassageUser
class deprecated
The PassageUser
class has been deprecated as of Passage-Elements v2 in favor of using the updated Passage-JS library directly. Learn more about how to use Passage-JS to manage the currently authenticated user and the associated session here.
When updating to Passage-Elements 2.0 update the following PassageUser
methods to these Passage-JS methods:
PassageUser method | Passage-JS method |
---|---|
|
|
|
|
|
|
|
|
|
|
Callback updates
Passage-Elements v2 introduces updates to the beforeAuth
and onSuccess
callbacks.
beforeAuth
callback
The beforeAuth
callback has new updated types that are now shared with the onSuccess
callback. If you are not using TypeScript then your existing beforeAuth
callback will continue to work with no additional changes.
The type from Passage-Elements v1 BeforeAuthCallbackType
has been renamed to AuthCallbackType
and the BeforeAuthCallbackPayload
has been renamed to AuthCallbackPayload
in v2.
interface Metadata {
[key: string]: boolean | string | number;
}
enum AuthCallbackType {
Login = 'login',
Register = 'register',
}
interface AuthCallbackPayload {
authType?: AuthCallbackType;
/** Any additional metadata provided by the user. This will only be available on registration. */
userMetadata?: Metadata;
}
type BeforeAuthCallback = (identifier: string, payload: AuthCallbackPayload) => boolean;
onSuccess
callback
The onSuccess
callback has been extended to include additional information about the type of authentication occurring, either login or registration, and any additional metadata provided by the user during registration.
The authCallbackPayload
has been added as a second parameter to the onSuccess
callback which is also used by the beforeAuth
callback. Existing implementations of the onSuccess
callback will continue to work with no additional changes.
type OnSuccessCallback = (authResult: AuthResult, payload: AuthCallbackPayload) => void;
Learn more
For more information on how to use the beforeAuth
and onSuccess
callbacks, as well as the new onEvent
callback read the guide on Custom logic with callbacks.