@krak-stack/auth 0.1.51 → 0.1.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/api.group.d.ts +60 -0
- package/dist/admin/schema.d.ts +64 -0
- package/dist/admin/schema.js +41 -0
- package/dist/api.d.ts +297 -216
- package/dist/components/admin-organization-form.js +110 -69
- package/dist/components/admin-organizations.js +99 -6
- package/dist/components/admin-users.js +38 -4
- package/dist/components/auth-client-api.d.ts +60 -0
- package/dist/components/auth-client.d.ts +17 -1
- package/dist/components/auth-client.js +15 -1
- package/dist/components/auth-forms.d.ts +1 -0
- package/dist/components/auth-forms.js +309 -252
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/organization-switcher.d.ts +18 -7
- package/dist/components/organization-switcher.js +264 -189
- package/dist/components/user-button.js +197 -178
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/schema.d.ts +1 -0
- package/dist/schema.js +2 -0
- package/dist/server/api.group.d.ts +22 -1
- package/dist/server/api.group.js +10 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/schema.d.ts +20 -0
- package/dist/server/schema.js +5 -0
- package/dist/service.d.ts +50 -0
- package/package.json +1 -1
|
@@ -1,21 +1,37 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useAtomSuspense } from "@effect/atom-react";
|
|
2
|
+
import { useAtomSet, useAtomSuspense, useAtomValue } from "@effect/atom-react";
|
|
3
|
+
import { FormBuilder, FormReact } from "@lucas-barake/effect-form-react";
|
|
3
4
|
import { Link, useNavigate, useRouterState } from "@tanstack/react-router";
|
|
4
|
-
import { Schema } from "effect";
|
|
5
|
+
import { Effect, Option, Schema } from "effect";
|
|
5
6
|
import { Atom, AsyncResult } from "effect/unstable/reactivity";
|
|
6
7
|
import { REGEXP_ONLY_DIGITS } from "input-otp";
|
|
7
|
-
import { KeyRound, Mail } from "lucide-react";
|
|
8
|
+
import { KeyRound, Loader2, Mail } from "lucide-react";
|
|
8
9
|
import { useEffect, useState } from "react";
|
|
9
10
|
import { Button, buttonVariants } from "@/components/ui/button";
|
|
10
11
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card";
|
|
12
|
+
import { CheckboxField, ErrorMessage, SubmitError, TextField, effectFormMessages, } from "@/components/ui/effect-form";
|
|
11
13
|
import { Field, FieldLabel } from "@/components/ui/field";
|
|
12
|
-
import { FieldError, useAppForm } from "@/components/ui/form";
|
|
13
14
|
import { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, } from "@/components/ui/input-otp";
|
|
14
15
|
import { authClientApi } from "./auth-client-api";
|
|
15
16
|
import { useKrakstackAuth } from "./auth-provider";
|
|
16
17
|
import { cn } from "./utils";
|
|
17
18
|
import { ExtraProjectPublicConfig as ExtraProjectPublicConfigSchema, } from "../extra/schema";
|
|
18
19
|
const EMAIL_OTP_RESEND_COOLDOWN_SECONDS = 60;
|
|
20
|
+
const signinFormBuilder = FormBuilder.empty
|
|
21
|
+
.addField("email", Schema.String)
|
|
22
|
+
.addField("password", Schema.String)
|
|
23
|
+
.addField("otp", Schema.String);
|
|
24
|
+
const signupFormBuilder = FormBuilder.empty
|
|
25
|
+
.addField("name", Schema.String)
|
|
26
|
+
.addField("email", Schema.String)
|
|
27
|
+
.addField("password", Schema.String);
|
|
28
|
+
const verifyEmailFormBuilder = FormBuilder.empty
|
|
29
|
+
.addField("email", Schema.String)
|
|
30
|
+
.addField("otp", Schema.String);
|
|
31
|
+
const resetPasswordFormBuilder = FormBuilder.empty.addField("password", Schema.String);
|
|
32
|
+
const twoFactorFormBuilder = FormBuilder.empty
|
|
33
|
+
.addField("code", Schema.String)
|
|
34
|
+
.addField("trustDevice", Schema.Boolean);
|
|
19
35
|
const defaultMessages = {
|
|
20
36
|
en: {
|
|
21
37
|
auth_continue_with_google: "Continue with Google",
|
|
@@ -67,6 +83,13 @@ const defaultMessages = {
|
|
|
67
83
|
two_factor_verify_description: "Enter the code from your authenticator app to continue.",
|
|
68
84
|
two_factor_verify_email_description: "Enter the verification code sent to your email to continue.",
|
|
69
85
|
two_factor_verify_error: "Could not verify the code.",
|
|
86
|
+
verify_email_code: "Verification code",
|
|
87
|
+
verify_email_description: "Enter the one-time code sent to your email address.",
|
|
88
|
+
verify_email_error: "Unable to verify email.",
|
|
89
|
+
verify_email_resend: "Resend code",
|
|
90
|
+
verify_email_resend_error: "Unable to send verification code.",
|
|
91
|
+
verify_email_resent: "A new verification code has been sent.",
|
|
92
|
+
verify_email_title: "Verify your email",
|
|
70
93
|
},
|
|
71
94
|
fr: {
|
|
72
95
|
auth_continue_with_google: "Continuer avec Google",
|
|
@@ -118,6 +141,13 @@ const defaultMessages = {
|
|
|
118
141
|
two_factor_verify_description: "Saisissez le code de votre application d'authentification pour continuer.",
|
|
119
142
|
two_factor_verify_email_description: "Saisissez le code de vérification envoyé à votre courriel pour continuer.",
|
|
120
143
|
two_factor_verify_error: "Impossible de vérifier le code.",
|
|
144
|
+
verify_email_code: "Code de vérification",
|
|
145
|
+
verify_email_description: "Saisissez le code à usage unique envoyé à votre adresse courriel.",
|
|
146
|
+
verify_email_error: "Impossible de vérifier le courriel.",
|
|
147
|
+
verify_email_resend: "Renvoyer le code",
|
|
148
|
+
verify_email_resend_error: "Impossible d'envoyer le code de vérification.",
|
|
149
|
+
verify_email_resent: "Un nouveau code de vérification a été envoyé.",
|
|
150
|
+
verify_email_title: "Vérifier votre courriel",
|
|
121
151
|
},
|
|
122
152
|
};
|
|
123
153
|
const labels = (locale) => ({
|
|
@@ -212,23 +242,56 @@ export function Signin(props) {
|
|
|
212
242
|
const interval = window.setInterval(updateResendSeconds, 1000);
|
|
213
243
|
return () => window.clearInterval(interval);
|
|
214
244
|
}, [emailOtpResendAvailableAt]);
|
|
215
|
-
const form =
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
245
|
+
const [form] = useState(() => FormReact.make(signinFormBuilder, {
|
|
246
|
+
fields: { email: TextField, password: TextField, otp: OtpField },
|
|
247
|
+
mode: { validation: "onSubmit" },
|
|
248
|
+
onSubmit: (action, { decoded: value }) => Effect.tryPromise({
|
|
249
|
+
try: async () => {
|
|
250
|
+
const email = value.email.trim();
|
|
251
|
+
const sendEmailOtp = async () => {
|
|
252
|
+
const result = await authClient.emailOtp.sendVerificationOtp({
|
|
253
|
+
email,
|
|
254
|
+
type: "sign-in",
|
|
255
|
+
});
|
|
256
|
+
if (result.error) {
|
|
257
|
+
throw new Error(result.error.message ?? m.sign_in_email_otp_send_error);
|
|
258
|
+
}
|
|
259
|
+
setAuthMethod("emailOtp");
|
|
260
|
+
setEmailSubmitted(true);
|
|
261
|
+
setOtpSentTo(email);
|
|
262
|
+
setEmailOtpResendAvailableAt(Date.now() + EMAIL_OTP_RESEND_COOLDOWN_SECONDS * 1000);
|
|
263
|
+
};
|
|
264
|
+
if (action.type === "social") {
|
|
265
|
+
const result = await authClient.signIn.social({
|
|
266
|
+
provider: "google",
|
|
267
|
+
callbackURL: socialRedirectTarget,
|
|
268
|
+
errorCallbackURL: "/sign-in",
|
|
269
|
+
...(oauthQuery
|
|
270
|
+
? { additionalData: { query: oauthQuery } }
|
|
271
|
+
: {}),
|
|
272
|
+
...(oauthQuery ? { oauth_query: oauthQuery } : {}),
|
|
273
|
+
});
|
|
274
|
+
if (result.error) {
|
|
275
|
+
throw new Error(result.error.message ?? m.sign_in_error);
|
|
276
|
+
}
|
|
277
|
+
if (result.data?.url)
|
|
278
|
+
onNavigate(result.data.url);
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
if (action.type === "sendEmailOtp") {
|
|
282
|
+
await sendEmailOtp();
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
if (!action.emailSubmitted) {
|
|
286
|
+
if (action.method === "emailOtp")
|
|
287
|
+
await sendEmailOtp();
|
|
288
|
+
else
|
|
289
|
+
setEmailSubmitted(true);
|
|
223
290
|
return;
|
|
224
291
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
try {
|
|
229
|
-
if (selectedAuthMethod === "emailOtp") {
|
|
230
|
-
if (!otpSentTo) {
|
|
231
|
-
await sendEmailOtp(email, (message) => formApi.setErrorMap({ onSubmit: { form: message, fields: {} } }));
|
|
292
|
+
if (action.method === "emailOtp") {
|
|
293
|
+
if (!action.otpSent) {
|
|
294
|
+
await sendEmailOtp();
|
|
232
295
|
return;
|
|
233
296
|
}
|
|
234
297
|
const result = await authClient.signIn.emailOtp({
|
|
@@ -236,13 +299,7 @@ export function Signin(props) {
|
|
|
236
299
|
otp: value.otp.trim(),
|
|
237
300
|
});
|
|
238
301
|
if (result.error) {
|
|
239
|
-
|
|
240
|
-
onSubmit: {
|
|
241
|
-
form: result.error.message ?? m.sign_in_email_otp_error,
|
|
242
|
-
fields: {},
|
|
243
|
-
},
|
|
244
|
-
});
|
|
245
|
-
return;
|
|
302
|
+
throw new Error(result.error.message ?? m.sign_in_email_otp_error);
|
|
246
303
|
}
|
|
247
304
|
onNavigate(redirectTarget);
|
|
248
305
|
return;
|
|
@@ -254,119 +311,81 @@ export function Signin(props) {
|
|
|
254
311
|
...(oauthQuery ? { oauth_query: oauthQuery } : {}),
|
|
255
312
|
});
|
|
256
313
|
if (result.error) {
|
|
257
|
-
|
|
258
|
-
onSubmit: {
|
|
259
|
-
form: result.error.message ?? m.sign_in_error,
|
|
260
|
-
fields: {},
|
|
261
|
-
},
|
|
262
|
-
});
|
|
263
|
-
return;
|
|
314
|
+
throw new Error(result.error.message ?? m.sign_in_error);
|
|
264
315
|
}
|
|
265
316
|
if (hasTwoFactorRedirect(result.data)) {
|
|
266
317
|
onTwoFactorRedirect(`/2fa${oauthQuery ? `?${oauthQuery}` : `?callbackURL=${encodeURIComponent(redirectTarget)}`}`);
|
|
267
318
|
return;
|
|
268
319
|
}
|
|
269
320
|
onNavigate(result.data?.url ?? redirectTarget);
|
|
270
|
-
}
|
|
271
|
-
catch
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
},
|
|
282
|
-
});
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
setEmailSubmitted(true);
|
|
295
|
-
setOtpSentTo(email);
|
|
296
|
-
setEmailOtpResendAvailableAt(Date.now() + EMAIL_OTP_RESEND_COOLDOWN_SECONDS * 1000);
|
|
297
|
-
}
|
|
298
|
-
catch {
|
|
299
|
-
setError(m.sign_in_email_otp_send_error);
|
|
300
|
-
}
|
|
301
|
-
};
|
|
321
|
+
},
|
|
322
|
+
catch: (cause) => cause instanceof Error
|
|
323
|
+
? cause
|
|
324
|
+
: new Error(action.type === "sendEmailOtp" ||
|
|
325
|
+
(action.type === "submit" &&
|
|
326
|
+
action.method === "emailOtp" &&
|
|
327
|
+
(!action.emailSubmitted || !action.otpSent))
|
|
328
|
+
? m.sign_in_email_otp_send_error
|
|
329
|
+
: action.type === "submit" && action.method === "emailOtp"
|
|
330
|
+
? m.sign_in_email_otp_error
|
|
331
|
+
: m.sign_in_error),
|
|
332
|
+
}),
|
|
333
|
+
}));
|
|
334
|
+
const submit = useAtomSet(form.submit);
|
|
335
|
+
const submitResult = useAtomValue(form.submit);
|
|
336
|
+
const formValues = Option.getOrElse(useAtomValue(form.values), () => ({
|
|
337
|
+
email: "",
|
|
338
|
+
password: "",
|
|
339
|
+
otp: "",
|
|
340
|
+
}));
|
|
341
|
+
const resetForm = useAtomSet(form.reset);
|
|
342
|
+
const setEmail = useAtomSet(form.getFieldAtoms(form.fields.email).setValue);
|
|
343
|
+
const setPassword = useAtomSet(form.getFieldAtoms(form.fields.password).setValue);
|
|
344
|
+
const setOtp = useAtomSet(form.getFieldAtoms(form.fields.otp).setValue);
|
|
302
345
|
const resetEmailStep = () => {
|
|
346
|
+
const email = formValues.email;
|
|
347
|
+
resetForm();
|
|
348
|
+
setEmail(email);
|
|
303
349
|
setEmailSubmitted(false);
|
|
304
350
|
setOtpSentTo("");
|
|
305
351
|
setEmailOtpResendAvailableAt(0);
|
|
306
|
-
form.setFieldValue("password", "");
|
|
307
|
-
form.setFieldValue("otp", "");
|
|
308
|
-
form.setErrorMap({ onSubmit: undefined });
|
|
309
352
|
};
|
|
310
|
-
const switchAuthMethod =
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
form.setFieldValue("otp", "");
|
|
353
|
+
const switchAuthMethod = () => {
|
|
354
|
+
setPassword("");
|
|
355
|
+
setOtp("");
|
|
314
356
|
if (selectedAuthMethod === "emailOtp") {
|
|
357
|
+
resetForm();
|
|
358
|
+
setEmail(formValues.email);
|
|
315
359
|
setAuthMethod("password");
|
|
316
360
|
setOtpSentTo("");
|
|
317
361
|
setEmailOtpResendAvailableAt(0);
|
|
318
362
|
return;
|
|
319
363
|
}
|
|
320
|
-
|
|
321
|
-
};
|
|
322
|
-
const resendEmailOtp = async () => {
|
|
323
|
-
form.setErrorMap({ onSubmit: undefined });
|
|
324
|
-
form.setFieldValue("otp", "");
|
|
325
|
-
await sendEmailOtp(form.state.values.email.trim(), (message) => form.setErrorMap({ onSubmit: { form: message, fields: {} } }));
|
|
364
|
+
submit({ type: "sendEmailOtp" });
|
|
326
365
|
};
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
provider: "google",
|
|
331
|
-
callbackURL: socialRedirectTarget,
|
|
332
|
-
errorCallbackURL: "/sign-in",
|
|
333
|
-
...(oauthQuery ? { additionalData: { query: oauthQuery } } : {}),
|
|
334
|
-
...(oauthQuery ? { oauth_query: oauthQuery } : {}),
|
|
335
|
-
});
|
|
336
|
-
if (result.error) {
|
|
337
|
-
form.setErrorMap({
|
|
338
|
-
onSubmit: {
|
|
339
|
-
form: result.error.message ?? m.sign_in_error,
|
|
340
|
-
fields: {},
|
|
341
|
-
},
|
|
342
|
-
});
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
if (result.data?.url)
|
|
346
|
-
onNavigate(result.data.url);
|
|
347
|
-
}
|
|
348
|
-
catch {
|
|
349
|
-
form.setErrorMap({ onSubmit: { form: m.sign_in_error, fields: {} } });
|
|
350
|
-
}
|
|
366
|
+
const resendEmailOtp = () => {
|
|
367
|
+
setOtp("");
|
|
368
|
+
submit({ type: "sendEmailOtp" });
|
|
351
369
|
};
|
|
352
|
-
|
|
370
|
+
const signInWithGoogle = () => submit({ type: "social" });
|
|
371
|
+
return (_jsxs(Card, { className: "w-full max-w-md", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-3xl", children: m.auth_sign_in }), _jsx(CardDescription, { children: !emailSubmitted ? (m.sign_in_description) : (_jsxs(_Fragment, { children: [text(m.sign_in_email_as, { email: formValues.email }), " ", _jsx(Button, { type: "button", variant: "link", className: "h-auto px-0", onClick: resetEmailStep, children: m.sign_in_change_email })] })) })] }), _jsxs(CardContent, { children: [hasPrimaryAuth ? (_jsx(form.Initialize, { defaultValues: { email: "", password: "", otp: "" }, children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: (event) => {
|
|
353
372
|
event.preventDefault();
|
|
354
373
|
event.stopPropagation();
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
374
|
+
submit({
|
|
375
|
+
type: "submit",
|
|
376
|
+
emailSubmitted,
|
|
377
|
+
method: selectedAuthMethod,
|
|
378
|
+
otpSent: Boolean(otpSentTo),
|
|
379
|
+
});
|
|
380
|
+
}, children: [!emailSubmitted ? (_jsx(form.email, { label: m.field_email, type: "email", autoComplete: "email", required: true })) : null, emailSubmitted && selectedAuthMethod === "password" ? (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(form.password, { label: m.field_password, type: "password", autoComplete: "current-password", required: true }), _jsxs("div", { className: "flex flex-wrap gap-x-4 gap-y-2 text-sm", children: [_jsx(Link, { className: authLinkClassName, to: "/forgot-password", search: searchObject(searchString), children: m.sign_in_forgot_password }), canChangeAuthMethod ? (_jsxs(Button, { type: "button", variant: "link", className: "h-auto px-0", onClick: switchAuthMethod, children: [_jsx(Mail, {}), m.sign_in_use_email_otp] })) : null] })] })) : null, emailSubmitted && selectedAuthMethod === "emailOtp" ? (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(form.otp, { label: m.sign_in_email_otp_code }), _jsxs("div", { className: "flex flex-wrap gap-x-4 gap-y-2 text-sm", children: [otpSentTo ? (_jsx(Button, { type: "button", variant: "link", className: "h-auto px-0", disabled: emailOtpResendSeconds > 0, onClick: resendEmailOtp, children: emailOtpResendSeconds > 0
|
|
362
381
|
? text(m.sign_in_email_otp_resend_countdown, {
|
|
363
382
|
seconds: String(emailOtpResendSeconds),
|
|
364
383
|
})
|
|
365
|
-
: m.sign_in_email_otp_resend })) : null, canChangeAuthMethod ? (_jsxs(Button, { type: "button", variant: "link", className: "h-auto px-0", onClick: switchAuthMethod, children: [_jsx(KeyRound, {}), m.sign_in_use_password] })) : null] })] })) : null, _jsx(
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
384
|
+
: m.sign_in_email_otp_resend })) : null, canChangeAuthMethod ? (_jsxs(Button, { type: "button", variant: "link", className: "h-auto px-0", onClick: switchAuthMethod, children: [_jsx(KeyRound, {}), m.sign_in_use_password] })) : null] })] })) : null, _jsx(SubmitError, { result: submitResult }), _jsx("div", { children: _jsxs(Button, { type: "submit", disabled: submitResult.waiting, children: [submitResult.waiting ? (_jsx(Loader2, { className: "animate-spin", "data-icon": "inline-start" })) : null, !emailSubmitted
|
|
385
|
+
? m.sign_in_continue
|
|
386
|
+
: selectedAuthMethod === "emailOtp"
|
|
387
|
+
? m.sign_in_email_otp_verify
|
|
388
|
+
: m.auth_sign_in] }) })] }) })) : null, options.google && !emailSubmitted ? (_jsxs("div", { className: "mt-4 flex flex-col gap-3", children: [hasPrimaryAuth ? (_jsx(Divider, { label: m.auth_or_continue_with })) : null, _jsxs(Button, { type: "button", variant: "outline", className: "w-full", disabled: submitResult.waiting, onClick: signInWithGoogle, children: [_jsx(GoogleLogo, {}), m.auth_continue_with_google] })] })) : null, !hasPrimaryAuth && !options.google ? (_jsx("p", { className: "text-muted-foreground text-sm", children: m.oauth_client_no_auth_methods })) : null, options.signUp ? (_jsx("p", { className: "text-muted-foreground mt-6 text-center text-sm", children: _jsxs(Link, { className: authLinkClassName, to: "/sign-up", search: searchObject(searchString), children: [m.sign_in_need_account, " ", m.auth_sign_up] }) })) : null] })] }));
|
|
370
389
|
}
|
|
371
390
|
export function Signup(props) {
|
|
372
391
|
const { authClient, baseUrl, labels: m, projectConfig: providedProjectConfig, } = useAuthFormOptions(props);
|
|
@@ -378,23 +397,36 @@ export function Signup(props) {
|
|
|
378
397
|
const redirectTarget = getRedirectTarget(searchString, projectConfig?.authDomain, projectConfig?.rootDomain);
|
|
379
398
|
const authOptions = projectConfig?.authOptions;
|
|
380
399
|
const onNavigate = (target) => navigate({ href: target });
|
|
381
|
-
const onVerifyEmail = (email) => navigate({
|
|
400
|
+
const onVerifyEmail = (email) => navigate({
|
|
401
|
+
to: "/verify-email",
|
|
402
|
+
search: { ...searchObject(searchString), email },
|
|
403
|
+
});
|
|
382
404
|
const options = {
|
|
383
405
|
google: authOptions?.google ?? true,
|
|
384
406
|
signUp: authOptions?.signUp ?? true,
|
|
385
407
|
signUpName: authOptions?.signUpName ?? true,
|
|
386
408
|
};
|
|
387
|
-
const form =
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
409
|
+
const [form] = useState(() => FormReact.make(signupFormBuilder, {
|
|
410
|
+
fields: { name: TextField, email: TextField, password: TextField },
|
|
411
|
+
mode: { validation: "onSubmit" },
|
|
412
|
+
onSubmit: (action, { decoded: value }) => Effect.tryPromise({
|
|
413
|
+
try: async () => {
|
|
414
|
+
if (action === "social") {
|
|
415
|
+
const result = await authClient.signIn.social({
|
|
416
|
+
provider: "google",
|
|
417
|
+
callbackURL: redirectTarget,
|
|
418
|
+
errorCallbackURL: "/sign-up",
|
|
419
|
+
});
|
|
420
|
+
if (result.error) {
|
|
421
|
+
throw new Error(result.error.message ?? m.sign_up_error);
|
|
422
|
+
}
|
|
423
|
+
if (result.data?.url)
|
|
424
|
+
onNavigate(result.data.url);
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
if (!options.signUp) {
|
|
428
|
+
throw new Error(m.sign_up_disabled_description);
|
|
429
|
+
}
|
|
398
430
|
const result = await authClient.signUp.email({
|
|
399
431
|
name: options.signUpName
|
|
400
432
|
? value.name.trim()
|
|
@@ -403,54 +435,78 @@ export function Signup(props) {
|
|
|
403
435
|
password: value.password,
|
|
404
436
|
});
|
|
405
437
|
if (result.error) {
|
|
406
|
-
|
|
407
|
-
onSubmit: {
|
|
408
|
-
form: result.error.message ?? m.sign_up_error,
|
|
409
|
-
fields: {},
|
|
410
|
-
},
|
|
411
|
-
});
|
|
412
|
-
return;
|
|
438
|
+
throw new Error(result.error.message ?? m.sign_up_error);
|
|
413
439
|
}
|
|
414
440
|
onVerifyEmail(value.email.trim());
|
|
415
|
-
}
|
|
416
|
-
catch
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
});
|
|
423
|
-
const signUpWithGoogle = async () => {
|
|
424
|
-
try {
|
|
425
|
-
const result = await authClient.signIn.social({
|
|
426
|
-
provider: "google",
|
|
427
|
-
callbackURL: redirectTarget,
|
|
428
|
-
errorCallbackURL: "/sign-up",
|
|
429
|
-
});
|
|
430
|
-
if (result.error) {
|
|
431
|
-
form.setErrorMap({
|
|
432
|
-
onSubmit: {
|
|
433
|
-
form: result.error.message ?? m.sign_up_error,
|
|
434
|
-
fields: {},
|
|
435
|
-
},
|
|
436
|
-
});
|
|
437
|
-
return;
|
|
438
|
-
}
|
|
439
|
-
if (result.data?.url)
|
|
440
|
-
onNavigate(result.data.url);
|
|
441
|
-
}
|
|
442
|
-
catch {
|
|
443
|
-
form.setErrorMap({ onSubmit: { form: m.sign_up_error, fields: {} } });
|
|
444
|
-
}
|
|
445
|
-
};
|
|
441
|
+
},
|
|
442
|
+
catch: (cause) => cause instanceof Error ? cause : new Error(m.sign_up_error),
|
|
443
|
+
}),
|
|
444
|
+
}));
|
|
445
|
+
const submit = useAtomSet(form.submit);
|
|
446
|
+
const submitResult = useAtomValue(form.submit);
|
|
447
|
+
const signUpWithGoogle = () => submit("social");
|
|
446
448
|
if (!options.signUp) {
|
|
447
|
-
return (_jsxs(Card, { className: "w-full max-w-md", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-3xl", children: m.sign_up_disabled_title }), _jsx(CardDescription, { children: m.sign_up_disabled_description })] }), _jsx(CardContent, { children:
|
|
449
|
+
return (_jsxs(Card, { className: "w-full max-w-md", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-3xl", children: m.sign_up_disabled_title }), _jsx(CardDescription, { children: m.sign_up_disabled_description })] }), _jsx(CardContent, { children: _jsx("p", { className: "text-muted-foreground text-center text-sm", children: _jsxs(Link, { className: authLinkClassName, to: "/sign-in", search: searchObject(searchString), children: [m.sign_up_have_account, " ", m.auth_sign_in] }) }) })] }));
|
|
448
450
|
}
|
|
449
|
-
return (_jsxs(Card, { className: "w-full max-w-md", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-3xl", children: m.sign_up_title }), _jsx(CardDescription, { children: m.sign_up_description })] }), _jsxs(CardContent, { children: [_jsx(form.
|
|
451
|
+
return (_jsxs(Card, { className: "w-full max-w-md", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-3xl", children: m.sign_up_title }), _jsx(CardDescription, { children: m.sign_up_description })] }), _jsxs(CardContent, { children: [_jsx(form.Initialize, { defaultValues: { name: "", email: "", password: "" }, children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: (event) => {
|
|
450
452
|
event.preventDefault();
|
|
451
453
|
event.stopPropagation();
|
|
452
|
-
|
|
453
|
-
}, children: [options.signUpName ? (_jsx(form.
|
|
454
|
+
submit("email");
|
|
455
|
+
}, children: [options.signUpName ? (_jsx(form.name, { label: m.field_name, autoComplete: "name", required: true })) : null, _jsx(form.email, { label: m.field_email, type: "email", autoComplete: "email", required: true }), _jsx(form.password, { label: m.field_password, type: "password", autoComplete: "new-password", minLength: 8, required: true }), _jsx(SubmitError, { result: submitResult }), _jsxs(Button, { type: "submit", disabled: submitResult.waiting, children: [submitResult.waiting ? (_jsx(Loader2, { className: "animate-spin", "data-icon": "inline-start" })) : null, effectFormMessages().submit] })] }) }), options.google ? (_jsxs("div", { className: "mt-4 flex flex-col gap-3", children: [_jsx(Divider, { label: m.auth_or_continue_with }), _jsxs(Button, { type: "button", variant: "outline", className: "w-full", disabled: submitResult.waiting, onClick: signUpWithGoogle, children: [_jsx(GoogleLogo, {}), m.auth_continue_with_google] })] })) : null, _jsx("p", { className: "text-muted-foreground mt-6 text-center text-sm", children: _jsxs(Link, { className: authLinkClassName, to: "/sign-in", search: searchObject(searchString), children: [m.sign_up_have_account, " ", m.auth_sign_in] }) })] })] }));
|
|
456
|
+
}
|
|
457
|
+
export function VerifyEmail(props) {
|
|
458
|
+
const { authClient, baseUrl, labels: m, projectConfig: providedProjectConfig, } = useAuthFormOptions(props);
|
|
459
|
+
const navigate = useNavigate();
|
|
460
|
+
const searchString = useRouterState({
|
|
461
|
+
select: (state) => state.location.searchStr,
|
|
462
|
+
});
|
|
463
|
+
const projectConfig = useAuthProjectConfig(baseUrl, searchString, providedProjectConfig);
|
|
464
|
+
const redirectTarget = getRedirectTarget(searchString, projectConfig?.authDomain, projectConfig?.rootDomain);
|
|
465
|
+
const onNavigate = (target) => navigateTarget(target, navigate);
|
|
466
|
+
const [resent, setResent] = useState(false);
|
|
467
|
+
const [form] = useState(() => FormReact.make(verifyEmailFormBuilder, {
|
|
468
|
+
fields: { email: TextField, otp: OtpField },
|
|
469
|
+
mode: { validation: "onSubmit" },
|
|
470
|
+
onSubmit: (action, { decoded: value }) => Effect.tryPromise({
|
|
471
|
+
try: async () => {
|
|
472
|
+
if (action === "resend") {
|
|
473
|
+
const result = await authClient.emailOtp.sendVerificationOtp({
|
|
474
|
+
email: value.email.trim(),
|
|
475
|
+
type: "email-verification",
|
|
476
|
+
});
|
|
477
|
+
if (result.error) {
|
|
478
|
+
throw new Error(result.error.message ?? m.verify_email_resend_error);
|
|
479
|
+
}
|
|
480
|
+
setResent(true);
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
const result = await authClient.emailOtp.verifyEmail({
|
|
484
|
+
email: value.email.trim(),
|
|
485
|
+
otp: value.otp.trim(),
|
|
486
|
+
});
|
|
487
|
+
if (result.error) {
|
|
488
|
+
throw new Error(result.error.message ?? m.verify_email_error);
|
|
489
|
+
}
|
|
490
|
+
onNavigate(redirectTarget);
|
|
491
|
+
},
|
|
492
|
+
catch: (cause) => cause instanceof Error
|
|
493
|
+
? cause
|
|
494
|
+
: new Error(action === "resend"
|
|
495
|
+
? m.verify_email_resend_error
|
|
496
|
+
: m.verify_email_error),
|
|
497
|
+
}),
|
|
498
|
+
}));
|
|
499
|
+
const submit = useAtomSet(form.submit);
|
|
500
|
+
const submitResult = useAtomValue(form.submit);
|
|
501
|
+
const resendCode = () => submit("resend");
|
|
502
|
+
return (_jsxs(Card, { className: "w-full max-w-md", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-3xl", children: m.verify_email_title }), _jsx(CardDescription, { children: m.verify_email_description })] }), _jsxs(CardContent, { children: [_jsx(form.Initialize, { defaultValues: {
|
|
503
|
+
email: getSearchParam(searchString, "email") ?? "",
|
|
504
|
+
otp: "",
|
|
505
|
+
}, children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: (event) => {
|
|
506
|
+
event.preventDefault();
|
|
507
|
+
event.stopPropagation();
|
|
508
|
+
submit("verify");
|
|
509
|
+
}, children: [_jsx(form.email, { label: m.field_email, type: "email", autoComplete: "email", required: true }), _jsx(form.otp, { label: m.verify_email_code }), _jsx(SubmitError, { result: submitResult }), resent ? (_jsx("p", { className: "text-muted-foreground text-sm", children: m.verify_email_resent })) : null, _jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [_jsxs(Button, { type: "submit", disabled: submitResult.waiting, children: [submitResult.waiting ? (_jsx(Loader2, { className: "animate-spin", "data-icon": "inline-start" })) : null, effectFormMessages().submit] }), _jsx(Button, { type: "button", variant: "ghost", disabled: submitResult.waiting, onClick: resendCode, children: m.verify_email_resend })] })] }) }), _jsx("p", { className: "text-muted-foreground mt-6 text-center text-sm", children: _jsx(Link, { className: authLinkClassName, to: "/sign-in", children: m.forgot_password_back_to_sign_in }) })] })] }));
|
|
454
510
|
}
|
|
455
511
|
export function ResetPassword(props) {
|
|
456
512
|
const { authClient, labels: m } = useAuthFormOptions(props);
|
|
@@ -460,37 +516,32 @@ export function ResetPassword(props) {
|
|
|
460
516
|
});
|
|
461
517
|
const token = getSearchParam(searchString, "token") ?? "";
|
|
462
518
|
const onSuccess = () => navigate({ to: "/sign-in" });
|
|
463
|
-
const form =
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
519
|
+
const [form] = useState(() => FormReact.make(resetPasswordFormBuilder, {
|
|
520
|
+
fields: { password: TextField },
|
|
521
|
+
mode: { validation: "onSubmit" },
|
|
522
|
+
onSubmit: (_, { decoded: value }) => Effect.tryPromise({
|
|
523
|
+
try: async () => {
|
|
524
|
+
if (!token)
|
|
525
|
+
throw new Error(m.reset_password_missing_token);
|
|
526
|
+
const result = await authClient.resetPassword({
|
|
527
|
+
newPassword: value.password,
|
|
528
|
+
token,
|
|
470
529
|
});
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
},
|
|
483
|
-
});
|
|
484
|
-
return;
|
|
485
|
-
}
|
|
486
|
-
onSuccess();
|
|
487
|
-
},
|
|
488
|
-
});
|
|
489
|
-
return (_jsxs(Card, { className: "w-full max-w-md", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-3xl", children: m.reset_password_title }), _jsx(CardDescription, { children: m.reset_password_description })] }), _jsx(CardContent, { children: _jsx(form.AppForm, { children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: (event) => {
|
|
530
|
+
if (result.error) {
|
|
531
|
+
throw new Error(result.error.message ?? m.reset_password_error);
|
|
532
|
+
}
|
|
533
|
+
onSuccess();
|
|
534
|
+
},
|
|
535
|
+
catch: (cause) => cause instanceof Error ? cause : new Error(m.reset_password_error),
|
|
536
|
+
}),
|
|
537
|
+
}));
|
|
538
|
+
const submit = useAtomSet(form.submit);
|
|
539
|
+
const submitResult = useAtomValue(form.submit);
|
|
540
|
+
return (_jsxs(Card, { className: "w-full max-w-md", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-3xl", children: m.reset_password_title }), _jsx(CardDescription, { children: m.reset_password_description })] }), _jsx(CardContent, { children: _jsx(form.Initialize, { defaultValues: { password: "" }, children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: (event) => {
|
|
490
541
|
event.preventDefault();
|
|
491
542
|
event.stopPropagation();
|
|
492
|
-
|
|
493
|
-
}, children: [_jsx(form.
|
|
543
|
+
submit();
|
|
544
|
+
}, children: [_jsx(form.password, { label: m.reset_password_new_password, type: "password", autoComplete: "new-password", minLength: 8, required: true }), _jsx(SubmitError, { result: submitResult }), _jsxs(Button, { type: "submit", disabled: submitResult.waiting, children: [submitResult.waiting ? (_jsx(Loader2, { className: "animate-spin", "data-icon": "inline-start" })) : null, effectFormMessages().submit] })] }) }) })] }));
|
|
494
545
|
}
|
|
495
546
|
export function TwoFactor(props) {
|
|
496
547
|
const { authClient, baseUrl, labels: m, projectConfig: providedProjectConfig, } = useAuthFormOptions(props);
|
|
@@ -504,72 +555,79 @@ export function TwoFactor(props) {
|
|
|
504
555
|
const onNavigate = (target) => navigateTarget(target, navigate);
|
|
505
556
|
const [mode, setMode] = useState("totp");
|
|
506
557
|
const [emailCodeSent, setEmailCodeSent] = useState(false);
|
|
507
|
-
const form =
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
558
|
+
const [form] = useState(() => FormReact.make(twoFactorFormBuilder, {
|
|
559
|
+
fields: { code: AuthCodeField, trustDevice: CheckboxField },
|
|
560
|
+
mode: { validation: "onSubmit" },
|
|
561
|
+
onSubmit: (action, { decoded: value }) => Effect.tryPromise({
|
|
562
|
+
try: async () => {
|
|
563
|
+
if (action.type === "sendEmailCode") {
|
|
564
|
+
const result = await authClient.twoFactor.sendOtp();
|
|
565
|
+
if (result.error) {
|
|
566
|
+
throw new Error(result.error.message ?? m.two_factor_send_email_code_error);
|
|
567
|
+
}
|
|
568
|
+
setEmailCodeSent(true);
|
|
569
|
+
setMode("email");
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
const code = value.code.trim();
|
|
573
|
+
const result = action.mode === "backup"
|
|
574
|
+
? await authClient.twoFactor.verifyBackupCode({
|
|
520
575
|
code,
|
|
521
576
|
trustDevice: value.trustDevice,
|
|
522
577
|
...(oauthQuery ? { oauth_query: oauthQuery } : {}),
|
|
523
578
|
})
|
|
524
|
-
:
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
});
|
|
551
|
-
return;
|
|
552
|
-
}
|
|
553
|
-
setEmailCodeSent(true);
|
|
554
|
-
setMode("email");
|
|
555
|
-
};
|
|
579
|
+
: action.mode === "email"
|
|
580
|
+
? await authClient.twoFactor.verifyOtp({
|
|
581
|
+
code,
|
|
582
|
+
trustDevice: value.trustDevice,
|
|
583
|
+
...(oauthQuery ? { oauth_query: oauthQuery } : {}),
|
|
584
|
+
})
|
|
585
|
+
: await authClient.twoFactor.verifyTotp({
|
|
586
|
+
code,
|
|
587
|
+
trustDevice: value.trustDevice,
|
|
588
|
+
...(oauthQuery ? { oauth_query: oauthQuery } : {}),
|
|
589
|
+
});
|
|
590
|
+
if (result.error) {
|
|
591
|
+
throw new Error(result.error.message ?? m.two_factor_verify_error);
|
|
592
|
+
}
|
|
593
|
+
onNavigate(getResultRedirectUrl(result.data) ?? redirectTarget);
|
|
594
|
+
},
|
|
595
|
+
catch: (cause) => cause instanceof Error
|
|
596
|
+
? cause
|
|
597
|
+
: new Error(action.type === "sendEmailCode"
|
|
598
|
+
? m.two_factor_send_email_code_error
|
|
599
|
+
: m.two_factor_verify_error),
|
|
600
|
+
}),
|
|
601
|
+
}));
|
|
602
|
+
const submit = useAtomSet(form.submit);
|
|
603
|
+
const submitResult = useAtomValue(form.submit);
|
|
604
|
+
const sendEmailCode = () => submit({ type: "sendEmailCode" });
|
|
556
605
|
return (_jsxs(Card, { className: "w-full max-w-md", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-3xl", children: m.two_factor_title }), _jsx(CardDescription, { children: mode === "backup"
|
|
557
606
|
? m.two_factor_verify_backup_description
|
|
558
607
|
: mode === "email"
|
|
559
608
|
? m.two_factor_verify_email_description
|
|
560
|
-
: m.two_factor_verify_description })] }), _jsx(CardContent, { children: _jsx(form.
|
|
609
|
+
: m.two_factor_verify_description })] }), _jsx(CardContent, { children: _jsx(form.Initialize, { defaultValues: { code: "", trustDevice: true }, children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: (event) => {
|
|
561
610
|
event.preventDefault();
|
|
562
611
|
event.stopPropagation();
|
|
563
|
-
|
|
564
|
-
}, children: [_jsx(form.
|
|
612
|
+
submit({ type: "verify", mode });
|
|
613
|
+
}, children: [_jsx(form.code, { autoComplete: "one-time-code", label: mode === "backup"
|
|
614
|
+
? m.two_factor_backup_code
|
|
615
|
+
: mode === "email"
|
|
565
616
|
? m.two_factor_email_code
|
|
566
|
-
: m.two_factor_code
|
|
617
|
+
: m.two_factor_code, otp: mode !== "backup", required: true }), _jsx(form.trustDevice, { label: m.two_factor_trust_device }), _jsx(SubmitError, { result: submitResult }), emailCodeSent && mode === "email" ? (_jsx("p", { className: "text-muted-foreground text-sm", children: m.two_factor_email_code_sent })) : null, _jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [_jsxs(Button, { type: "submit", disabled: submitResult.waiting, children: [submitResult.waiting ? (_jsx(Loader2, { className: "animate-spin", "data-icon": "inline-start" })) : null, effectFormMessages().submit] }), _jsx(Button, { type: "button", variant: "ghost", disabled: submitResult.waiting, onClick: sendEmailCode, children: m.two_factor_send_email_code }), _jsx(Button, { type: "button", variant: "ghost", onClick: () => setMode(mode === "backup" ? "totp" : "backup"), children: mode === "backup"
|
|
567
618
|
? m.two_factor_use_totp
|
|
568
619
|
: m.two_factor_use_backup_code })] })] }) }) })] }));
|
|
569
620
|
}
|
|
570
|
-
const
|
|
571
|
-
const invalid =
|
|
572
|
-
return (_jsxs(Field, { "data-invalid": invalid, children: [_jsx(FieldLabel, { htmlFor: field.
|
|
621
|
+
const OtpField = ({ field, props, }) => {
|
|
622
|
+
const invalid = Option.isSome(field.error);
|
|
623
|
+
return (_jsxs(Field, { "data-invalid": invalid, children: [_jsx(FieldLabel, { htmlFor: field.path, children: props.label }), _jsxs(InputOTP, { id: field.path, name: field.path, maxLength: 6, value: field.value, onChange: field.onChange, onBlur: field.onBlur, autoComplete: "one-time-code", inputMode: "numeric", pattern: REGEXP_ONLY_DIGITS, required: true, children: [_jsxs(InputOTPGroup, { children: [_jsx(InputOTPSlot, { index: 0, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 1, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 2, "aria-invalid": invalid })] }), _jsx(InputOTPSeparator, {}), _jsxs(InputOTPGroup, { children: [_jsx(InputOTPSlot, { index: 3, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 4, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 5, "aria-invalid": invalid })] })] }), Option.isSome(field.error) ? (_jsx(ErrorMessage, { text: field.error.value })) : null] }));
|
|
624
|
+
};
|
|
625
|
+
const AuthCodeField = ({ field, props }) => {
|
|
626
|
+
if (props.otp) {
|
|
627
|
+
return _jsx(OtpField, { field: field, props: { label: props.label } });
|
|
628
|
+
}
|
|
629
|
+
const { otp: _, ...textFieldProps } = props;
|
|
630
|
+
return _jsx(TextField, { field: field, props: textFieldProps });
|
|
573
631
|
};
|
|
574
632
|
const Divider = ({ label }) => (_jsxs("div", { className: "text-muted-foreground flex items-center gap-3 text-xs", children: [_jsx("span", { className: "bg-border h-px flex-1" }), label, _jsx("span", { className: "bg-border h-px flex-1" })] }));
|
|
575
633
|
const GoogleLogo = () => (_jsxs("svg", { "aria-hidden": "true", className: "size-[18px]", viewBox: "0 0 18 18", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("path", { d: "M17.64 9.204c0-.638-.057-1.252-.164-1.84H9v3.481h4.844a4.14 4.14 0 0 1-1.796 2.716v2.259h2.908c1.702-1.567 2.684-3.874 2.684-6.616Z", fill: "#4285F4" }), _jsx("path", { d: "M9 18c2.43 0 4.467-.806 5.956-2.18l-2.908-2.259c-.806.54-1.837.86-3.048.86-2.344 0-4.328-1.583-5.036-3.711H.957v2.332A8.997 8.997 0 0 0 9 18Z", fill: "#34A853" }), _jsx("path", { d: "M3.964 10.71A5.41 5.41 0 0 1 3.682 9c0-.593.102-1.17.282-1.71V4.958H.957A8.996 8.996 0 0 0 0 9c0 1.452.348 2.827.957 4.042l3.007-2.332Z", fill: "#FBBC05" }), _jsx("path", { d: "M9 3.58c1.321 0 2.508.454 3.44 1.346l2.582-2.58C13.463.891 11.426 0 9 0A8.997 8.997 0 0 0 .957 4.958L3.964 7.29C4.672 5.162 6.656 3.58 9 3.58Z", fill: "#EA4335" })] }));
|
|
@@ -662,9 +720,8 @@ const shouldUseDocumentRedirect = (target) => {
|
|
|
662
720
|
return true;
|
|
663
721
|
if (target.startsWith("/"))
|
|
664
722
|
return false;
|
|
665
|
-
if (target.startsWith(window.location.origin))
|
|
666
|
-
return
|
|
667
|
-
}
|
|
723
|
+
if (target.startsWith(window.location.origin))
|
|
724
|
+
return true;
|
|
668
725
|
return target.startsWith("http://") || target.startsWith("https://");
|
|
669
726
|
};
|
|
670
727
|
const nameFromEmail = (email) => {
|