HYPR Reconcile Lambda
On this page
When a user logs in with a HYPR identity provider, FusionAuth uses the email address to reconcile the user. You can use a lambda to customize the user and registration during the login.
When you create a lambda in the Admin UI, FusionAuth provides an empty function.
Lambda Structure#
When you create the lambda with the API, give the function the following signature:
function reconcile(user, registration, context) {
// Lambda code goes here
}
This lambda must contain a function named reconcile that accepts the following parameters:
user: the FusionAuth User object. You can modify this object. However, you can't change the email or username attributes after FusionAuth links the user.registration: the FusionAuth UserRegistration object. You can modify this object.
context: Available since1.64.0an object containing the context of the request, including access to secrets. This object is read-only.
The User API and Registration API documentation describe the user and registration objects. HYPR returns no profile data, so the lambda receives no third object.
Example Lambda#
The following lambda counts HYPR logins and records the time of the last HYPR login in user.data.hypr. The lambda also gives the user the passwordless role, so your application can tell which users log in with HYPR. Add the passwordless role to your application before you use the lambda.
// records each HYPR login and gives HYPR users a passwordless role
function reconcile(user, registration, context) {
user.data = user.data || {};
user.data.hypr = {
lastLoginInstant: Date.now(),
loginCount: ((user.data.hypr && user.data.hypr.loginCount) || 0) + 1
};
if (!registration) {
return;
}
var roles = registration.roles || [];
if (roles.indexOf('passwordless') === -1) {
roles.push('passwordless');
}
registration.roles = roles;
}Assigning The Lambda#
After you create the lambda, assign the lambda to the HYPR identity provider.
Navigate to Settings -> Identity Providers . Select your existing HYPR configuration. If you haven't configured HYPR yet, click Add provider and select HYPR.
Related
Learn how to map the data from an Apple login to a FusionAuth user and registration with a reconcile lambda.
Learn how to map the data from an Epic Games login to a FusionAuth user and registration with a reconcile lambda.
Learn how to map the data from a Facebook login to a FusionAuth user and registration with a reconcile lambda.
Learn how to map the data from a Google login to a FusionAuth user and registration with a reconcile lambda.