Linking accounts
During the passkey registration flow, we recommended you link the authenticatorId (passkey id) to a local user account.
You may have noticed that the Principal also includes a userId property, which mirrors the authenticatorId. During passkey registration the userId defaults to the authenticatorId because, from a Passlock perspective we don’t know anything about the user at this stage. All we know is that someone created a passkey:
{ "authenticatorId": "spy28n0bqca11tq", "userId": "spy28n0bqca11tq"}Assigning a custom user ID
Section titled “Assigning a custom user ID”The Principal.userId can be changed via a backend REST call.
import { assignUser, isPasskey } from "@passlock/server";
const passkeyId = "myPasskeyId";const userId = "myInternalUserId";
const result = await assignUser({ userId, passkeyId, tenancyId, apiKey });
if (isPasskey(result)) { console.log(result.userId)}If you reassign the userId to align with your own internal user IDs, you can use this property to look up local user accounts:
import { exchangeCode } from "@passlock/server";
const principal = await exchangeCode({ code, tenancyId, apiKey });console.log(principal);{ "authenticatorId": "spy28n0bqca11tq", "userId": "myInternalUserId"}Using the console
Section titled “Using the console”Custom user IDs can also be assigned through your Passlock console.