Checking if the user is signed in
Logging out
Logging out is done by calling thelogout
function, and it will clear all the session data, including the Dynamic user and any connected wallets (non verified wallets).
Getting the current authenticated user (Dynamic user)
Getting the user JWT
Updating the current authenticated user (Dynamic user)
You can update the current authenticated user (Dynamic user) by calling theupdateUser
function.
You can pass many user fields to the function, and it will update the user with the new values.
If any of the fields require OTP verification (like email or phone number), the function will return an OTPVerification
object,
that you can use to check what kind of OTP verification is required (email or phone number), send the OTP to the user, and verify the OTP.
Checking if a user has missing fields
You can toggle user data collected and also to be required or not in the Dynamic dashboard. We don’t control that in the JavaScript SDK, but you can check if a user has missing fields by calling theuser.missingFields
property.
With that, you can display the appropriate UI to the user to complete the onboarding process, and call the updateUser
function to update the user with the missing fields.
Refreshing the current authenticated user (Dynamic user)
You can refresh the current authenticated user (Dynamic user) by calling therefreshUser
function.
This function will refresh the user object in the SDK with the latest data from the server.