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

Commit 6e2ee9a

Browse files
[DEV-1438] If the redirect parameter is set always use it as the redirect path (#113)
* If the redirect parameter is set always use it as the redirect path * Update to v1.0.10-alpha.0 --------- Co-authored-by: Userfront Robot <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 557dae4 commit 6e2ee9a

6 files changed

Lines changed: 25 additions & 8 deletions

File tree

package-lock.json

Lines changed: 1 addition & 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.9",
3+
"version": "1.0.10-alpha.0",
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/models/config/actions.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,14 +274,28 @@ export const markAsSecondFactor = assign({
274274
// Redirect to the afterLoginPath etc. after signed in, just an alias for the Userfront API method
275275
export const redirectIfLoggedIn = (context: AuthContext<any>) => {
276276
if (context.config.redirect !== false) {
277-
callUserfront({ method: "redirectIfLoggedIn", args: [] });
277+
callUserfront({
278+
method: "redirectIfLoggedIn",
279+
args: [
280+
{
281+
redirect: context.config?.redirect,
282+
},
283+
],
284+
});
278285
}
279286
};
280287

281288
// Redirect to the afterLoginPath if the user is already logged in when the form loads, if redirectOnLoad = true
282289
export const redirectOnLoad = (context: AuthContext<any>) => {
283290
if (context.config.redirectOnLoad) {
284-
callUserfront({ method: "redirectIfLoggedIn", args: [] });
291+
callUserfront({
292+
method: "redirectIfLoggedIn",
293+
args: [
294+
{
295+
redirect: context.config?.redirect,
296+
},
297+
],
298+
});
285299
}
286300
};
287301

package/src/models/forms/universal.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,7 @@ const universalMachineConfig: AuthMachineConfig = {
671671
args: [
672672
{
673673
method: event.factor?.strategy,
674+
redirect: context.config?.redirect,
674675
},
675676
],
676677
});
@@ -695,6 +696,7 @@ const universalMachineConfig: AuthMachineConfig = {
695696
method: "link",
696697
token: context.query.token,
697698
uuid: context.query.uuid,
699+
redirect: context.config?.redirect,
698700
},
699701
],
700702
});

package/src/models/views/emailLink.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const emailLinkConfig: AuthMachineConfig = {
4040
});
4141
}
4242
// Login link
43-
const arg: Record<string, any> = {
43+
const arg: Record<string, string | boolean | undefined> = {
4444
method: "passwordless",
4545
email: context.user.email,
4646
redirect: context.config.redirect,
@@ -86,9 +86,10 @@ const emailLinkConfig: AuthMachineConfig = {
8686
invoke: {
8787
// Set the method and email, and name and/or username if present, as arguments
8888
src: (context) => {
89-
const arg: Record<string, string> = {
89+
const arg: Record<string, string | boolean | undefined> = {
9090
method: "passwordless",
9191
email: context.user.email,
92+
redirect: context.config.redirect,
9293
};
9394
if (hasValue(context.user.name)) {
9495
arg.name = context.user.name;

0 commit comments

Comments
 (0)