Skip to content
This repository was archived by the owner on Mar 19, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@userfront/toolkit",
"version": "1.0.9-alpha.1",
"version": "1.0.9-alpha.2",
"description": "Bindings and components for authentication with Userfront with React, Vue, other frameworks, and plain JS + HTML",
"type": "module",
"directories": {
Expand Down
1 change: 1 addition & 0 deletions package/src/forms/UniversalForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ const componentForStep = (state) => {

// Already logged in - for forms on pages without redirect-on-load
case "alreadyLoggedIn":
case "initRefreshTokens":
case "refreshTokens":
return {
title: strings.general.welcome,
Expand Down
21 changes: 20 additions & 1 deletion package/src/models/forms/universal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ const universalMachineConfig: AuthMachineConfig = {

// If there's already a user refresh their tokens, proceed.
{
target: "refreshTokens",
target: "initRefreshTokens",
cond: "isLoggedIn",
},

Expand Down Expand Up @@ -397,6 +397,20 @@ const universalMachineConfig: AuthMachineConfig = {
],
},

initRefreshTokens: {
always: [
// Try to use the query params if they exist
{
target: "handleLoginWithLink",
cond: "hasLinkQueryParams",
},
// If no query params, proceed refreshing tokens
{
target: "refreshTokens",
},
],
},

refreshTokens: {
invoke: {
// Update the tokens
Expand Down Expand Up @@ -699,6 +713,11 @@ const universalMachineConfig: AuthMachineConfig = {
},
],
onError: [
// If logged in go to refresh tokens
{
target: "refreshTokens",
cond: "isLoggedIn",
},
// If there was a problem logging in with the link token and uuid,
// go back to first factor selection and show the error.
// Mark the query params invalid, so we don't infinitely retry them.
Expand Down