User Management

How to manage your authenticated user in iOS

Get user

Once your user has been authenticated, you can call passage.getCurrentUser() which will return a PassageUserInfo instance. When the user is no longer authenticated, this method will return nil.

Here's an example:

let passage = PassageAuth(appId: "YOUR_APP_ID")
let user = try? await passage.getCurrentUser()

You can learn more about the available user properties here.

Methods for updating user

Change contact info

To change the user's phone number or email, you can follow the examples below. Note that the user will receive a verification email or text message where they'll need to confirm the change.

// Change email for authenticated user
try? await passage.changeEmail(newEmail: "[email protected]");

// Change phone for authenticated user
try? await passage.changePhone(newPhone: "155555555555");

Manage user passkeys

The following CRUD operations are available for user device passkey credentials:

// Create a new device passkey
let newDevicePasskey = try? await passage.addDevice()

// Get user's device passkeys
let devicePasskeys = try? await passage.listDevices()

// Edit a device passkey name
let newName = "My favorite passkey"
try? await passage.editDevice(deviceId: id, friendlyName: newName)

// Revoke a device passkey
// NOTE: This does NOT remove the passkey from the user's device, but it revokes the passkey
try? await passage.revokeDevice(deviceId: id)

Sign out user

To log out your user and remove their tokens from the TokenStore (more on this in the next section), you can simply call passage.signOut() .

try? await passage.signOut()

Last updated