File tree Expand file tree Collapse file tree
frontend/main/src/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {
1111} from '@firebase/auth' ;
1212import { useAuth , useSigninCheck } from 'reactfire' ;
1313import { Auth , User } from 'firebase/auth' ;
14+ import { useRouter } from 'next/router' ;
1415
1516export const FirebaseAuth = ( {
1617 full = true ,
@@ -20,6 +21,8 @@ export const FirebaseAuth = ({
2021 const [ email , setEmail ] = useState ( '' ) ;
2122 const [ password , setPassword ] = useState ( '' ) ;
2223 const auth = useAuth ( ) ;
24+ const router = useRouter ( ) ;
25+ const pathBack = router ?. query ?. path ;
2326
2427 let signInOptions = [ ] ;
2528 if ( full ) {
@@ -41,7 +44,7 @@ export const FirebaseAuth = ({
4144 }
4245 const uiConfig = {
4346 signInOptions,
44- signInSuccessUrl : window . location . href ,
47+ signInSuccessUrl : ` ${ window . location . origin + ( pathBack ? pathBack : '' ) } ` ,
4548 credentialHelper : 'none' ,
4649 tosUrl : `${ window . location . origin } /terms-of-use` ,
4750 // Privacy policy url/callback.
@@ -155,7 +158,6 @@ export const LoadingSpinner = () => {
155158 className = "fill-basics-50 dark:fill-basics-500"
156159 />
157160 </ svg >
158- Loading...
159161 </ div >
160162 ) ;
161163} ;
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { useAuth, useSigninCheck } from 'reactfire';
66import dynamic from 'next/dynamic' ;
77import { signOut } from '@/components/FirebaseAuth' ;
88import ActiveLink from '@/components/ActiveLink' ;
9+ import { useRouter } from 'next/router' ;
910
1011const AuthWrapper = dynamic < any > (
1112 ( ) => import ( '@/components/FirebaseAuth' ) . then ( ( mod ) => mod . AuthWrapper ) ,
@@ -40,14 +41,19 @@ export default function AvatarMenu({
4041} ) : JSX . Element {
4142 const auth = useAuth ( ) ;
4243 const { data : signInCheckResult } = useSigninCheck ( ) ;
43-
44+ const router = useRouter ( ) ;
4445 return (
4546 < FirebaseFirestoreProvider >
4647 < >
4748 < div className = "relative" >
4849 < AuthWrapper
4950 fallback = {
50- < Link href = "/user/profile" >
51+ < Link
52+ href = {
53+ `/user/profile` +
54+ ( router . asPath === '/' ? '' : `?path=${ router . asPath } ` )
55+ }
56+ >
5157 < a className = "flex items-center justify-center p-2 rounded text-basics-50 hover:bg-primary-800 dark:hover:bg-primary-800 focus:ring-2 focus:ring-basics-50" >
5258 < svg
5359 width = "20"
You can’t perform that action at this time.
0 commit comments