-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ac2988
commit 29a8251
Showing
9 changed files
with
117 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
"use client"; | ||
|
||
import { Text, Input, Row, Password, Button } from "../../../components/ui"; | ||
import React, { useRef } from "react"; | ||
import { signIn } from "next-auth/react"; | ||
import { useRouter } from "next/navigation"; | ||
|
||
type Props = { | ||
className?: string | null; | ||
callbackUrl?: string | null; | ||
error?: string | null; | ||
}; | ||
|
||
export default function SignInForm(props: Props) { | ||
const router = useRouter(); | ||
const email = useRef(""); | ||
const password = useRef(""); | ||
|
||
const onSubmit = async (e: React.FormEvent<HTMLFormElement>) => { | ||
e.preventDefault(); | ||
const result = await signIn("credentials", { | ||
email: email.current, | ||
password: password.current, | ||
redirect: false, | ||
}); | ||
if (!result?.error) { | ||
router.push(props.callbackUrl ?? "/"); | ||
} | ||
console.log(result); | ||
}; | ||
return ( | ||
<form onSubmit={onSubmit} className="w-full"> | ||
<Text as="label" htmlFor="email" weight="semibold" className="mb-1"> | ||
</Text> | ||
<Input | ||
type="text" | ||
name="email" | ||
id="email" | ||
placeholder="email" | ||
className="mb-4 h-auto" | ||
required | ||
onChange={(e: { target: { value: string } }) => | ||
(email.current = e.target.value) | ||
} | ||
/> | ||
<Row className="mb justify-between"> | ||
<Text as="label" htmlFor="password" weight="semibold"> | ||
Password | ||
</Text> | ||
<Text as="a" variant="link" color="light"> | ||
forgot password? | ||
</Text> | ||
</Row> | ||
<Password | ||
name="password" | ||
id="password" | ||
placeholder="password" | ||
className="mb-4" | ||
required | ||
onChange={(e: { target: { value: string } }) => | ||
(password.current = e.target.value) | ||
} | ||
/> | ||
<Button type="submit" name="Sign in" variant="solid" width="third"> | ||
Sign in | ||
</Button> | ||
</form> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export { default } from "next-auth/middleware"; | ||
export const config = { | ||
matcher: ["/dashboard"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2880,7 +2880,7 @@ | |
resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.2.0.tgz#756641adb587851b5ccb3e095daf27ae581c8406" | ||
integrity sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ== | ||
|
||
"@uug-ai/ui@^1.0.34": | ||
"@uug-ai/[email protected]": | ||
version "1.0.34" | ||
resolved "https://registry.yarnpkg.com/@uug-ai/ui/-/ui-1.0.34.tgz#473b67825631993154f667fa00ac9842c26dae1a" | ||
integrity sha512-TojkW5o3QlrctQBnC1B+C16kexfoCbypW4jHFjHW6IrooS/qH/poWnkAAGzj/U2hqGC1LL/Y4nvz2kyagjn5oQ== | ||
|