Skip to content
This repository was archived by the owner on Mar 19, 2025. It is now read-only.

Commit 54e849f

Browse files
authored
Merge pull request #73 from userfront/dev-574-635-fixes
DEV-574 DEV-635 small bug fixes
2 parents 7944844 + 009a57e commit 54e849f

6 files changed

Lines changed: 76 additions & 7 deletions

File tree

package-lock.json

Lines changed: 53 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@userfront/toolkit",
3-
"version": "1.0.0",
3+
"version": "1.0.1-alpha.1",
44
"description": "Bindings and components for authentication with Userfront with React, Vue, other frameworks, and plain JS + HTML",
55
"type": "module",
66
"directories": {

package/src/forms/UniversalForm.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ const componentForStep = (state) => {
396396
isLoading: true,
397397
},
398398
};
399-
case "password.showPasswordSuccess":
399+
case "password.showPasswordSet":
400400
return {
401401
title: strings[type].done,
402402
Component: Success,

package/src/models/views/setUpTotp.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ const setUpTotpConfig: AuthMachineConfig = {
8989
cond: "secondFactorRequiredFromView",
9090
},
9191
// We're signed in.
92-
// Core JS redirects as appropriate here.
92+
// Instruct CoreJS to redirect as appropriate here
9393
// Show the "verified" view in case we don't redirect.
9494
{
95+
actions: "redirectIfLoggedIn",
9596
target: "showTotpSetupComplete",
9697
},
9798
],

package/src/services/userfront.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ declare module "@userfront/core" {
1414
}
1515

1616
let singleton = Userfront;
17+
let isSingletonOverridden = false;
1718

1819
/**
1920
* Override the Userfront singleton imported from @userfront/core with an object of your choice.
@@ -22,6 +23,7 @@ let singleton = Userfront;
2223
*/
2324
export const overrideUserfrontSingleton = (newSingleton: any) => {
2425
singleton = newSingleton as typeof Userfront;
26+
isSingletonOverridden = true;
2527
};
2628

2729
// A type with the keys of all functions in Type
@@ -110,7 +112,21 @@ export const callUserfront = async ({ method, args = [] }: CallUserfront) => {
110112
return Promise.reject();
111113
}
112114
try {
113-
return await (<any>_method)(...args);
115+
const res = await (<any>_method)(...args);
116+
// Workaround to avoid flickering when CoreJS redirects:
117+
// wait for the current iteration of the event loop to finish,
118+
// and for the async task queue to finish,
119+
// and for the NEXT event loop cycle to finish,
120+
// then return.
121+
// TODO DEV-658 fix this in a nicer and more reliable way
122+
if (isSingletonOverridden) {
123+
// Don't wait if we've overridden the CoreJS singleton,
124+
// i.e. mocked it out for tests.
125+
return res;
126+
}
127+
return new Promise((resolve) => {
128+
setTimeout(() => resolve(res), 1);
129+
});
114130
} catch (err: any) {
115131
console.warn(
116132
`Method ${method} on Userfront object threw. Error: ${err.message}`

0 commit comments

Comments
 (0)