File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 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"
99import { FormTextField } from "../Form"
1010import * as API from "./../../api"
1111import { LoadingButton } from "./../Button"
12+ import { firstOrItem } from "../../util/array"
1213
1314/**
1415 * BuiltInAuthFormValues describes a form using built-in (email/password)
@@ -61,7 +62,14 @@ export const SignInForm: React.FC<SignInProps> = ({
6162 await loginHandler ( email , password )
6263 // Tell SWR to invalidate the cache for the user endpoint
6364 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 )
6573 } catch ( err ) {
6674 helpers . setFieldError ( "password" , "The username or password is incorrect." )
6775 }
You can’t perform that action at this time.
0 commit comments