You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Define an action or an endpoint to generate a registration token:
[HttpGet("/create-token")]publicasyncTask<IActionResult>GetRegisterToken(stringalias){// Get existing userid from session or create a new user in your databasevaruserId=Guid.NewGuid().ToString();// Provide the userid and an alias to link to this uservarpayload=newRegisterOptions(userId,alias){// Optional: Link this userid to an alias (e.g. email)Aliases=[alias]};try{vartokenRegistration=awaitpasswordlessClient.CreateRegisterTokenAsync(payload);// Return this token to the frontendreturnOk(tokenRegistration);}catch(PasswordlessApiExceptione){returnnewJsonResult(e.Details){StatusCode=(int?)e.StatusCode,};}}
Verify user
Define an action or an endpoint to verify an authentication token:
[HttpGet("/verify-signin")]publicasyncTask<IActionResult>VerifyAuthenticationToken(stringtoken){try{varverifiedUser=awaitpasswordlessClient.VerifyTokenAsync(token);// Sign the user in, set a cookie, etcreturnOk(verifiedUser);}catch(PasswordlessApiExceptione){returnnewJsonResult(e.Details){StatusCode=(int?)e.StatusCode};}}