File tree 1 file changed +9
-1
lines changed
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import { Welcome } from "./Welcome"
9
9
import { FormTextField } from "../Form"
10
10
import * as API from "./../../api"
11
11
import { LoadingButton } from "./../Button"
12
+ import { firstOrItem } from "../../util/array"
12
13
13
14
/**
14
15
* BuiltInAuthFormValues describes a form using built-in (email/password)
@@ -61,7 +62,14 @@ export const SignInForm: React.FC<SignInProps> = ({
61
62
await loginHandler ( email , password )
62
63
// Tell SWR to invalidate the cache for the user endpoint
63
64
await mutate ( "/api/v2/users/me" )
64
- await router . push ( "/" )
65
+
66
+ let redirect = "/"
67
+ if ( router . query ?. redirect ) {
68
+ redirect = firstOrItem ( router . query . redirect , redirect )
69
+ }
70
+
71
+ console . log ( "Using redirect: " + redirect )
72
+ await router . push ( redirect )
65
73
} catch ( err ) {
66
74
helpers . setFieldError ( "password" , "The username or password is incorrect." )
67
75
}
You can’t perform that action at this time.
0 commit comments