Skip to content

Commit

Permalink
Merge pull request #134 from Maawan/main
Browse files Browse the repository at this point in the history
fix : User token authentication issue (#124) and pressing enter on the signin page should sign the user #123
  • Loading branch information
hkirat authored Mar 6, 2024
2 parents 1151506 + e7014d8 commit 0b98937
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/components/Signin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ const Signin = () => {
const router = useRouter();
const email = useRef('');
const password = useRef('');
const handleSubmit = async (e: React.FormEvent<HTMLButtonElement>) => {
e.preventDefault();

const handleSubmit = async (e?: React.FormEvent<HTMLButtonElement>) => {
if(e){
e.preventDefault();
}

if (!email.current || !password.current) {
setRequiredError({
emailReq: email.current ? false : true,
Expand All @@ -33,6 +36,7 @@ const Signin = () => {
return;
}


const res = await signIn('credentials', {
username: email.current,
password: password.current,
Expand Down Expand Up @@ -92,7 +96,12 @@ const Signin = () => {
}));
password.current = e.target.value;
}}
/>
onKeyDown={async (e)=>{
if(e.key === "Enter"){
setIsPasswordVisible(false);
handleSubmit();
}}}
/>
<button
className="inset-y-0 right-0 flex items-center px-4 text-gray-600"
onClick={togglePasswordVisibility}
Expand Down

0 comments on commit 0b98937

Please sign in to comment.