@@ -11,6 +11,7 @@ import {
11
11
import { LoginPageLayout } from "~/components/LoginPageLayout" ;
12
12
import { Button , LinkButton } from "~/components/primitives/Buttons" ;
13
13
import { Fieldset } from "~/components/primitives/Fieldset" ;
14
+ import { FormError } from "~/components/primitives/FormError" ;
14
15
import { Header1 } from "~/components/primitives/Headers" ;
15
16
import { NamedIcon } from "~/components/primitives/NamedIcon" ;
16
17
import { Paragraph } from "~/components/primitives/Paragraph" ;
@@ -19,6 +20,10 @@ import type { LoaderType as RootLoader } from "~/root";
19
20
import { isGithubAuthSupported } from "~/services/auth.server" ;
20
21
import { commitSession , setRedirectTo } from "~/services/redirectTo.server" ;
21
22
import { getUserId } from "~/services/session.server" ;
23
+ import {
24
+ getUserSession ,
25
+ commitSession as commitAuthSession ,
26
+ } from "~/services/sessionStorage.server" ;
22
27
import { appEnvTitleTag } from "~/utils" ;
23
28
import { requestUrl } from "~/utils/requestUrl.server" ;
24
29
@@ -41,22 +46,36 @@ export async function loader({ request }: LoaderFunctionArgs) {
41
46
const url = requestUrl ( request ) ;
42
47
const redirectTo = url . searchParams . get ( "redirectTo" ) ;
43
48
49
+ const session = await getUserSession ( request ) ;
50
+ const error = session . get ( "auth:error" ) ;
51
+
52
+ let githubError : string | undefined ;
53
+ if ( error ) {
54
+ if ( "message" in error ) {
55
+ githubError = error . message ;
56
+ } else {
57
+ githubError = JSON . stringify ( error , null , 2 ) ;
58
+ }
59
+ }
60
+
44
61
if ( redirectTo ) {
45
62
const session = await setRedirectTo ( request , redirectTo ) ;
46
63
47
64
return typedjson (
48
- { redirectTo, showGithubAuth : isGithubAuthSupported } ,
65
+ { redirectTo, showGithubAuth : isGithubAuthSupported , githubError } ,
49
66
{
50
67
headers : {
51
68
"Set-Cookie" : await commitSession ( session ) ,
52
69
} ,
53
70
}
54
71
) ;
55
72
} else {
56
- return typedjson ( {
57
- redirectTo : null ,
58
- showGithubAuth : isGithubAuthSupported ,
59
- } ) ;
73
+ return typedjson (
74
+ { redirectTo : null , showGithubAuth : isGithubAuthSupported , githubError } ,
75
+ {
76
+ headers : { "Set-Cookie" : await commitAuthSession ( session ) } ,
77
+ }
78
+ ) ;
60
79
}
61
80
}
62
81
@@ -78,7 +97,7 @@ export default function LoginPage() {
78
97
Create an account or login
79
98
</ Paragraph >
80
99
< Fieldset className = "w-full" >
81
- < div className = "flex flex-col gap-y-2" >
100
+ < div className = "flex flex-col items-center gap-y-2" >
82
101
{ data . showGithubAuth && (
83
102
< Button
84
103
type = "submit"
@@ -102,6 +121,8 @@ export default function LoginPage() {
102
121
/>
103
122
Continue with Email
104
123
</ LinkButton >
124
+
125
+ { data . githubError && < FormError > { data . githubError } </ FormError > }
105
126
</ div >
106
127
< Paragraph variant = "extra-small" className = "mt-2 text-center" >
107
128
By signing up you agree to our{ " " }
0 commit comments