-
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
Showing
6 changed files
with
32 additions
and
32 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 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 |
---|---|---|
@@ -1,36 +1,36 @@ | ||
"use client" | ||
'use client' | ||
|
||
import { FormEvent, useState } from 'react' | ||
import { FormEvent } from 'react' | ||
import { signIn } from 'next-auth/react' | ||
import { useSearchParams } from 'next/navigation' | ||
|
||
import TextInput from '@/components/TextInput/TextInput' | ||
import PrimaryButton from '@/app/components/PrimaryButton/PrimaryButton' | ||
|
||
export default async function LogIn({ }) { | ||
export default function LogIn() { | ||
const searchParams = useSearchParams() | ||
|
||
const error = searchParams.get('error') | ||
|
||
async function handleSignIn(event: FormEvent<HTMLFormElement>) { | ||
event.preventDefault() | ||
|
||
const formData = new FormData(event.currentTarget); | ||
await signIn('credentials', { | ||
username: formData.get('username'), | ||
password: formData.get('password'), | ||
redirect: true, | ||
callbackUrl: searchParams.get('callbackUrl') || '/users/me' | ||
}) | ||
event.preventDefault() | ||
|
||
const formData = new FormData(event.currentTarget) | ||
|
||
await signIn('credentials', { | ||
username: formData.get('username'), | ||
password: formData.get('password'), | ||
redirect: true, | ||
callbackUrl: searchParams.get('callbackUrl') || '/users/me' | ||
}) | ||
} | ||
|
||
return <> | ||
<form onSubmit={handleSignIn}> | ||
<TextInput label='Brukernavn' name='username' type='text'/> | ||
<TextInput label='Passord' name='password' type='password'/> | ||
<PrimaryButton>Logg inn</PrimaryButton> | ||
<p style={{color: "red"}}>{error == "CredentialsSignin" ? "Feil brukernavn eller passord :(" : ""}</p> | ||
</form> | ||
<form onSubmit={handleSignIn}> | ||
<TextInput label='Brukernavn' name="username" type="text"/> | ||
<TextInput label="Passord" name="password" type="password"/> | ||
<PrimaryButton>Logg inn</PrimaryButton> | ||
<p style={{ color: 'red' }}>{error === 'CredentialsSignin' ? 'Feil brukernavn eller passord :(' : ''}</p> | ||
</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
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