import React from 'react'; import { PasswordInput, Anchor, Paper, Title, Text, Container, Group, Button } from '@mantine/core'; import { setCookie } from 'cookies-next'; import { showNotification, updateNotification } from '@mantine/notifications'; import axios from 'axios'; import { IconCheck, IconX } from '@tabler/icons'; import { useRouter } from 'next/router'; import { useForm } from '@mantine/form'; // TODO: Add links to the wiki articles about the login process. export default function AuthenticationTitle() { const router = useRouter(); const form = useForm({ initialValues: { password: '', }, }); return ( ({ fontFamily: `Greycliff CF, ${theme.fontFamily}`, fontWeight: 900 })} > Welcome back! Please enter the{' '} href="#" size="sm" onClick={(event) => event.preventDefault()}> password
{ setCookie('password', values.password, { maxAge: 60 * 60 * 24 * 30, sameSite: 'lax', }); showNotification({ id: 'load-data', loading: true, title: 'Checking your password', message: 'Your password is being checked...', autoClose: false, disallowClose: true, }); axios .post('/api/configs/tryPassword', { tried: values.password, }) .then((res) => { setTimeout(() => { if (res.data.success === true) { router.push('/'); updateNotification({ id: 'load-data', color: 'teal', title: 'Password correct, redirecting you...', message: undefined, icon: , autoClose: 1000, }); } if (res.data.success === false) { updateNotification({ id: 'load-data', color: 'red', title: 'Password is wrong, please try again.', message: undefined, icon: , autoClose: 2000, }); } }, 500); }); })} >
); }