@liedsonc/core-auth-kit 0.1.0 → 0.2.1
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/README.md +802 -759
- package/auth-ui/bin/init.js +126 -0
- package/auth-ui/components/auth-card.tsx +49 -49
- package/auth-ui/components/auth-form.tsx +53 -53
- package/auth-ui/components/error-message.tsx +24 -24
- package/auth-ui/components/form-field.tsx +39 -39
- package/auth-ui/components/loading-spinner.tsx +19 -19
- package/auth-ui/components/oauth-buttons.tsx +49 -49
- package/auth-ui/components/password-input.tsx +93 -93
- package/auth-ui/components/success-message.tsx +24 -24
- package/auth-ui/package.json +59 -55
- package/auth-ui/pages/forgot-password/index.tsx +83 -83
- package/auth-ui/pages/login/index.tsx +119 -119
- package/auth-ui/pages/register/index.tsx +149 -149
- package/auth-ui/pages/reset-password/index.tsx +133 -133
- package/auth-ui/pages/verify-email/index.tsx +143 -143
- package/auth-ui/templates/app/(auth)/forgot-password/page.tsx +5 -0
- package/auth-ui/templates/app/(auth)/layout.tsx +12 -0
- package/auth-ui/templates/app/(auth)/login/page.tsx +5 -0
- package/auth-ui/templates/app/(auth)/register/page.tsx +5 -0
- package/auth-ui/templates/app/(auth)/reset-password/page.tsx +5 -0
- package/auth-ui/templates/app/(auth)/verify-email/page.tsx +5 -0
- package/auth-ui/templates/app/api/auth/forgot-password/route.ts +16 -0
- package/auth-ui/templates/app/api/auth/login/route.ts +16 -0
- package/auth-ui/templates/app/api/auth/logout/route.ts +8 -0
- package/auth-ui/templates/app/api/auth/register/route.ts +16 -0
- package/auth-ui/templates/app/api/auth/reset-password/route.ts +16 -0
- package/auth-ui/templates/app/api/auth/session/route.ts +8 -0
- package/auth-ui/templates/app/api/auth/verify-email/route.ts +16 -0
- package/auth-ui/templates/env.example +25 -0
- package/auth-ui/templates/lib/auth-client.ts +20 -0
- package/auth-ui/templates/lib/auth-config.ts +43 -0
- package/auth-ui/tsconfig.json +4 -15
- package/package.json +17 -6
- package/tailwind.config.ts +41 -41
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { Input } from "./ui/input";
|
|
5
|
-
import { Button } from "./ui/button";
|
|
6
|
-
import { cn } from "../utils";
|
|
7
|
-
|
|
8
|
-
function getStrength(value: string): 0 | 1 | 2 | 3 {
|
|
9
|
-
if (!value) return 0;
|
|
10
|
-
let s = 0;
|
|
11
|
-
if (value.length >= 8) s++;
|
|
12
|
-
if (value.length >= 12) s++;
|
|
13
|
-
if (/[A-Z]/.test(value) && /[a-z]/.test(value) && /\d/.test(value)) s++;
|
|
14
|
-
return Math.min(s, 3) as 0 | 1 | 2 | 3;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface PasswordInputProps
|
|
18
|
-
extends Omit<React.ComponentProps<typeof Input>, "type"> {
|
|
19
|
-
showStrength?: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const PasswordInput = React.forwardRef<HTMLInputElement, PasswordInputProps>(
|
|
23
|
-
({ className, showStrength = false, ...props }, ref) => {
|
|
24
|
-
const [show, setShow] = React.useState(false);
|
|
25
|
-
const [value, setValue] = React.useState("");
|
|
26
|
-
const id = React.useId();
|
|
27
|
-
const strength = showStrength ? getStrength(value) : 0;
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<div className="space-y-1.5">
|
|
31
|
-
<div className="relative">
|
|
32
|
-
<Input
|
|
33
|
-
ref={ref}
|
|
34
|
-
type={show ? "text" : "password"}
|
|
35
|
-
autoComplete="current-password"
|
|
36
|
-
aria-describedby={showStrength ? `${id}-strength` : undefined}
|
|
37
|
-
className={cn("pr-10", className)}
|
|
38
|
-
{...props}
|
|
39
|
-
value={props.value ?? value}
|
|
40
|
-
onChange={(e) => {
|
|
41
|
-
setValue(e.target.value);
|
|
42
|
-
props.onChange?.(e);
|
|
43
|
-
}}
|
|
44
|
-
/>
|
|
45
|
-
<Button
|
|
46
|
-
type="button"
|
|
47
|
-
variant="ghost"
|
|
48
|
-
size="icon"
|
|
49
|
-
className="absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent"
|
|
50
|
-
aria-label={show ? "Hide password" : "Show password"}
|
|
51
|
-
aria-pressed={show}
|
|
52
|
-
onClick={() => setShow((p) => !p)}
|
|
53
|
-
tabIndex={-1}
|
|
54
|
-
>
|
|
55
|
-
<span className="text-xs font-medium" aria-hidden="true">
|
|
56
|
-
{show ? "Hide" : "Show"}
|
|
57
|
-
</span>
|
|
58
|
-
</Button>
|
|
59
|
-
</div>
|
|
60
|
-
{showStrength && value && (
|
|
61
|
-
<div
|
|
62
|
-
id={`${id}-strength`}
|
|
63
|
-
role="progressbar"
|
|
64
|
-
aria-valuenow={strength}
|
|
65
|
-
aria-valuemin={0}
|
|
66
|
-
aria-valuemax={3}
|
|
67
|
-
aria-label="Password strength"
|
|
68
|
-
className="flex gap-1"
|
|
69
|
-
>
|
|
70
|
-
{[1, 2, 3].map((i) => (
|
|
71
|
-
<span
|
|
72
|
-
key={i}
|
|
73
|
-
className={cn(
|
|
74
|
-
"h-1 flex-1 rounded-full",
|
|
75
|
-
i <= strength
|
|
76
|
-
? strength === 1
|
|
77
|
-
? "bg-destructive"
|
|
78
|
-
: strength === 2
|
|
79
|
-
? "bg-amber-500"
|
|
80
|
-
: "bg-green-500"
|
|
81
|
-
: "bg-muted"
|
|
82
|
-
)}
|
|
83
|
-
/>
|
|
84
|
-
))}
|
|
85
|
-
</div>
|
|
86
|
-
)}
|
|
87
|
-
</div>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
);
|
|
91
|
-
PasswordInput.displayName = "PasswordInput";
|
|
92
|
-
|
|
93
|
-
export { PasswordInput };
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Input } from "./ui/input";
|
|
5
|
+
import { Button } from "./ui/button";
|
|
6
|
+
import { cn } from "../utils";
|
|
7
|
+
|
|
8
|
+
function getStrength(value: string): 0 | 1 | 2 | 3 {
|
|
9
|
+
if (!value) return 0;
|
|
10
|
+
let s = 0;
|
|
11
|
+
if (value.length >= 8) s++;
|
|
12
|
+
if (value.length >= 12) s++;
|
|
13
|
+
if (/[A-Z]/.test(value) && /[a-z]/.test(value) && /\d/.test(value)) s++;
|
|
14
|
+
return Math.min(s, 3) as 0 | 1 | 2 | 3;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface PasswordInputProps
|
|
18
|
+
extends Omit<React.ComponentProps<typeof Input>, "type"> {
|
|
19
|
+
showStrength?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const PasswordInput = React.forwardRef<HTMLInputElement, PasswordInputProps>(
|
|
23
|
+
({ className, showStrength = false, ...props }, ref) => {
|
|
24
|
+
const [show, setShow] = React.useState(false);
|
|
25
|
+
const [value, setValue] = React.useState("");
|
|
26
|
+
const id = React.useId();
|
|
27
|
+
const strength = showStrength ? getStrength(value) : 0;
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div className="space-y-1.5">
|
|
31
|
+
<div className="relative">
|
|
32
|
+
<Input
|
|
33
|
+
ref={ref}
|
|
34
|
+
type={show ? "text" : "password"}
|
|
35
|
+
autoComplete="current-password"
|
|
36
|
+
aria-describedby={showStrength ? `${id}-strength` : undefined}
|
|
37
|
+
className={cn("pr-10", className)}
|
|
38
|
+
{...props}
|
|
39
|
+
value={props.value ?? value}
|
|
40
|
+
onChange={(e) => {
|
|
41
|
+
setValue(e.target.value);
|
|
42
|
+
props.onChange?.(e);
|
|
43
|
+
}}
|
|
44
|
+
/>
|
|
45
|
+
<Button
|
|
46
|
+
type="button"
|
|
47
|
+
variant="ghost"
|
|
48
|
+
size="icon"
|
|
49
|
+
className="absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent"
|
|
50
|
+
aria-label={show ? "Hide password" : "Show password"}
|
|
51
|
+
aria-pressed={show}
|
|
52
|
+
onClick={() => setShow((p) => !p)}
|
|
53
|
+
tabIndex={-1}
|
|
54
|
+
>
|
|
55
|
+
<span className="text-xs font-medium" aria-hidden="true">
|
|
56
|
+
{show ? "Hide" : "Show"}
|
|
57
|
+
</span>
|
|
58
|
+
</Button>
|
|
59
|
+
</div>
|
|
60
|
+
{showStrength && value && (
|
|
61
|
+
<div
|
|
62
|
+
id={`${id}-strength`}
|
|
63
|
+
role="progressbar"
|
|
64
|
+
aria-valuenow={strength}
|
|
65
|
+
aria-valuemin={0}
|
|
66
|
+
aria-valuemax={3}
|
|
67
|
+
aria-label="Password strength"
|
|
68
|
+
className="flex gap-1"
|
|
69
|
+
>
|
|
70
|
+
{[1, 2, 3].map((i) => (
|
|
71
|
+
<span
|
|
72
|
+
key={i}
|
|
73
|
+
className={cn(
|
|
74
|
+
"h-1 flex-1 rounded-full",
|
|
75
|
+
i <= strength
|
|
76
|
+
? strength === 1
|
|
77
|
+
? "bg-destructive"
|
|
78
|
+
: strength === 2
|
|
79
|
+
? "bg-amber-500"
|
|
80
|
+
: "bg-green-500"
|
|
81
|
+
: "bg-muted"
|
|
82
|
+
)}
|
|
83
|
+
/>
|
|
84
|
+
))}
|
|
85
|
+
</div>
|
|
86
|
+
)}
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
PasswordInput.displayName = "PasswordInput";
|
|
92
|
+
|
|
93
|
+
export { PasswordInput };
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { cn } from "../utils";
|
|
4
|
-
|
|
5
|
-
export function SuccessMessage({
|
|
6
|
-
children,
|
|
7
|
-
className,
|
|
8
|
-
id,
|
|
9
|
-
}: {
|
|
10
|
-
children: React.ReactNode;
|
|
11
|
-
className?: string;
|
|
12
|
-
id?: string;
|
|
13
|
-
}) {
|
|
14
|
-
if (!children) return null;
|
|
15
|
-
return (
|
|
16
|
-
<p
|
|
17
|
-
id={id}
|
|
18
|
-
role="status"
|
|
19
|
-
className={cn("text-sm text-green-600 dark:text-green-400", className)}
|
|
20
|
-
>
|
|
21
|
-
{children}
|
|
22
|
-
</p>
|
|
23
|
-
);
|
|
24
|
-
}
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../utils";
|
|
4
|
+
|
|
5
|
+
export function SuccessMessage({
|
|
6
|
+
children,
|
|
7
|
+
className,
|
|
8
|
+
id,
|
|
9
|
+
}: {
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
className?: string;
|
|
12
|
+
id?: string;
|
|
13
|
+
}) {
|
|
14
|
+
if (!children) return null;
|
|
15
|
+
return (
|
|
16
|
+
<p
|
|
17
|
+
id={id}
|
|
18
|
+
role="status"
|
|
19
|
+
className={cn("text-sm text-green-600 dark:text-green-400", className)}
|
|
20
|
+
>
|
|
21
|
+
{children}
|
|
22
|
+
</p>
|
|
23
|
+
);
|
|
24
|
+
}
|
package/auth-ui/package.json
CHANGED
|
@@ -1,55 +1,59 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@liedsonc/core-auth-kit",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"description": "Production-ready authentication UI package for Next.js App Router",
|
|
5
|
-
"main": "./index.ts",
|
|
6
|
-
"types": "./index.ts",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": "./index.ts",
|
|
9
|
-
"./styles": "./styles/index.css"
|
|
10
|
-
},
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"**/*.
|
|
14
|
-
"**/*.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
},
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"url": "https://github.com/liedsonc/core-auth-kit
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@liedsonc/core-auth-kit",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Production-ready authentication UI package for Next.js App Router",
|
|
5
|
+
"main": "./index.ts",
|
|
6
|
+
"types": "./index.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.ts",
|
|
9
|
+
"./styles": "./styles/index.css"
|
|
10
|
+
},
|
|
11
|
+
"bin": "bin/init.js",
|
|
12
|
+
"files": [
|
|
13
|
+
"**/*.ts",
|
|
14
|
+
"**/*.tsx",
|
|
15
|
+
"**/*.css",
|
|
16
|
+
"**/*.js",
|
|
17
|
+
"templates"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc --noEmit",
|
|
21
|
+
"type-check": "tsc --noEmit",
|
|
22
|
+
"publish": "npm publish --access public"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@radix-ui/react-label": "^2.1.0",
|
|
26
|
+
"@radix-ui/react-slot": "^1.1.0",
|
|
27
|
+
"class-variance-authority": "^0.7.0",
|
|
28
|
+
"clsx": "^2.1.1",
|
|
29
|
+
"tailwind-merge": "^2.5.0"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"next": "^15.0.0",
|
|
33
|
+
"react": "^19.0.0",
|
|
34
|
+
"react-dom": "^19.0.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/react": "^19.0.0",
|
|
38
|
+
"typescript": "^5.6.0"
|
|
39
|
+
},
|
|
40
|
+
"keywords": [
|
|
41
|
+
"nextjs",
|
|
42
|
+
"auth",
|
|
43
|
+
"authentication",
|
|
44
|
+
"ui",
|
|
45
|
+
"shadcn",
|
|
46
|
+
"react",
|
|
47
|
+
"typescript"
|
|
48
|
+
],
|
|
49
|
+
"license": "MIT",
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git+https://github.com/liedsonc/core-auth-kit.git",
|
|
53
|
+
"directory": "auth-ui"
|
|
54
|
+
},
|
|
55
|
+
"bugs": {
|
|
56
|
+
"url": "https://github.com/liedsonc/core-auth-kit/issues"
|
|
57
|
+
},
|
|
58
|
+
"homepage": "https://github.com/liedsonc/core-auth-kit#readme"
|
|
59
|
+
}
|
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import Link from "next/link";
|
|
4
|
-
import { useAuth } from "../../hooks/use-auth";
|
|
5
|
-
import { AuthCard } from "../../components/auth-card";
|
|
6
|
-
import { AuthForm } from "../../components/auth-form";
|
|
7
|
-
import { FormField } from "../../components/form-field";
|
|
8
|
-
import { SuccessMessage } from "../../components/success-message";
|
|
9
|
-
import { Button } from "../../components/ui/button";
|
|
10
|
-
import { Input } from "../../components/ui/input";
|
|
11
|
-
import { useState } from "react";
|
|
12
|
-
|
|
13
|
-
const successMessage =
|
|
14
|
-
"If an account exists for this email, you will receive a link to reset your password.";
|
|
15
|
-
|
|
16
|
-
export function ForgotPasswordPage() {
|
|
17
|
-
const { forgotPassword, loading, error, clearError } = useAuth();
|
|
18
|
-
const [email, setEmail] = useState("");
|
|
19
|
-
const [submitted, setSubmitted] = useState(false);
|
|
20
|
-
const [fieldError, setFieldError] = useState<string | undefined>();
|
|
21
|
-
|
|
22
|
-
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
|
23
|
-
e.preventDefault();
|
|
24
|
-
clearError();
|
|
25
|
-
setFieldError(undefined);
|
|
26
|
-
if (!email.trim()) {
|
|
27
|
-
setFieldError("Email is required.");
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
await forgotPassword(email.trim());
|
|
31
|
-
setSubmitted(true);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<div className="flex min-h-screen flex-col items-center justify-center p-4">
|
|
36
|
-
<AuthCard
|
|
37
|
-
title="Forgot password"
|
|
38
|
-
subtitle="Enter your email and we'll send you a reset link"
|
|
39
|
-
footer={
|
|
40
|
-
<div className="flex w-full justify-center text-sm text-muted-foreground">
|
|
41
|
-
<Link
|
|
42
|
-
href="/login"
|
|
43
|
-
className="underline underline-offset-4 hover:text-foreground"
|
|
44
|
-
>
|
|
45
|
-
Back to sign in
|
|
46
|
-
</Link>
|
|
47
|
-
</div>
|
|
48
|
-
}
|
|
49
|
-
>
|
|
50
|
-
{submitted ? (
|
|
51
|
-
<SuccessMessage>{successMessage}</SuccessMessage>
|
|
52
|
-
) : (
|
|
53
|
-
<AuthForm onSubmit={handleSubmit} loading={loading}>
|
|
54
|
-
{error && (
|
|
55
|
-
<p role="alert" className="text-sm text-destructive">
|
|
56
|
-
Something went wrong. Please try again later.
|
|
57
|
-
</p>
|
|
58
|
-
)}
|
|
59
|
-
<FormField label="Email" htmlFor="forgot-email" error={fieldError} required>
|
|
60
|
-
<Input
|
|
61
|
-
id="forgot-email"
|
|
62
|
-
type="email"
|
|
63
|
-
autoComplete="email"
|
|
64
|
-
placeholder="you@example.com"
|
|
65
|
-
value={email}
|
|
66
|
-
onChange={(e) => setEmail(e.target.value)}
|
|
67
|
-
disabled={loading}
|
|
68
|
-
aria-invalid={!!fieldError}
|
|
69
|
-
/>
|
|
70
|
-
</FormField>
|
|
71
|
-
<Button type="submit" className="w-full" disabled={loading}>
|
|
72
|
-
{loading ? (
|
|
73
|
-
<span className="inline-block size-4 animate-spin rounded-full border-2 border-current border-t-transparent" />
|
|
74
|
-
) : (
|
|
75
|
-
"Send reset link"
|
|
76
|
-
)}
|
|
77
|
-
</Button>
|
|
78
|
-
</AuthForm>
|
|
79
|
-
)}
|
|
80
|
-
</AuthCard>
|
|
81
|
-
</div>
|
|
82
|
-
);
|
|
83
|
-
}
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import Link from "next/link";
|
|
4
|
+
import { useAuth } from "../../hooks/use-auth";
|
|
5
|
+
import { AuthCard } from "../../components/auth-card";
|
|
6
|
+
import { AuthForm } from "../../components/auth-form";
|
|
7
|
+
import { FormField } from "../../components/form-field";
|
|
8
|
+
import { SuccessMessage } from "../../components/success-message";
|
|
9
|
+
import { Button } from "../../components/ui/button";
|
|
10
|
+
import { Input } from "../../components/ui/input";
|
|
11
|
+
import { useState } from "react";
|
|
12
|
+
|
|
13
|
+
const successMessage =
|
|
14
|
+
"If an account exists for this email, you will receive a link to reset your password.";
|
|
15
|
+
|
|
16
|
+
export function ForgotPasswordPage() {
|
|
17
|
+
const { forgotPassword, loading, error, clearError } = useAuth();
|
|
18
|
+
const [email, setEmail] = useState("");
|
|
19
|
+
const [submitted, setSubmitted] = useState(false);
|
|
20
|
+
const [fieldError, setFieldError] = useState<string | undefined>();
|
|
21
|
+
|
|
22
|
+
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
|
23
|
+
e.preventDefault();
|
|
24
|
+
clearError();
|
|
25
|
+
setFieldError(undefined);
|
|
26
|
+
if (!email.trim()) {
|
|
27
|
+
setFieldError("Email is required.");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
await forgotPassword(email.trim());
|
|
31
|
+
setSubmitted(true);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div className="flex min-h-screen flex-col items-center justify-center p-4">
|
|
36
|
+
<AuthCard
|
|
37
|
+
title="Forgot password"
|
|
38
|
+
subtitle="Enter your email and we'll send you a reset link"
|
|
39
|
+
footer={
|
|
40
|
+
<div className="flex w-full justify-center text-sm text-muted-foreground">
|
|
41
|
+
<Link
|
|
42
|
+
href="/login"
|
|
43
|
+
className="underline underline-offset-4 hover:text-foreground"
|
|
44
|
+
>
|
|
45
|
+
Back to sign in
|
|
46
|
+
</Link>
|
|
47
|
+
</div>
|
|
48
|
+
}
|
|
49
|
+
>
|
|
50
|
+
{submitted ? (
|
|
51
|
+
<SuccessMessage>{successMessage}</SuccessMessage>
|
|
52
|
+
) : (
|
|
53
|
+
<AuthForm onSubmit={handleSubmit} loading={loading}>
|
|
54
|
+
{error && (
|
|
55
|
+
<p role="alert" className="text-sm text-destructive">
|
|
56
|
+
Something went wrong. Please try again later.
|
|
57
|
+
</p>
|
|
58
|
+
)}
|
|
59
|
+
<FormField label="Email" htmlFor="forgot-email" error={fieldError} required>
|
|
60
|
+
<Input
|
|
61
|
+
id="forgot-email"
|
|
62
|
+
type="email"
|
|
63
|
+
autoComplete="email"
|
|
64
|
+
placeholder="you@example.com"
|
|
65
|
+
value={email}
|
|
66
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
67
|
+
disabled={loading}
|
|
68
|
+
aria-invalid={!!fieldError}
|
|
69
|
+
/>
|
|
70
|
+
</FormField>
|
|
71
|
+
<Button type="submit" className="w-full" disabled={loading}>
|
|
72
|
+
{loading ? (
|
|
73
|
+
<span className="inline-block size-4 animate-spin rounded-full border-2 border-current border-t-transparent" />
|
|
74
|
+
) : (
|
|
75
|
+
"Send reset link"
|
|
76
|
+
)}
|
|
77
|
+
</Button>
|
|
78
|
+
</AuthForm>
|
|
79
|
+
)}
|
|
80
|
+
</AuthCard>
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
}
|