import React from 'react'; import { PasswordInput, Anchor, Paper, Title, Text, Container, Group, Button } from '@mantine/core'; import { setCookies } from 'cookies-next'; import { useForm } from '@mantine/hooks'; import { showNotification, updateNotification } from '@mantine/notifications'; import axios from 'axios'; import { IconCheck, IconX } from '@tabler/icons'; // TODO: Add links to the wiki articles about the login process. export default function AuthenticationTitle() { 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
{ setCookies('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) { updateNotification({ id: 'load-data', color: 'teal', title: 'Password correct', message: 'Notification will close in 2 seconds, you can close this notification now', icon: , autoClose: 300, onClose: () => { window.location.reload(); }, }); } if (res.data.success === false) { updateNotification({ id: 'load-data', color: 'red', title: 'Password is wrong, please try again.', message: 'Notification will close in 2 seconds, you can close this notification now', icon: , autoClose: 2000, }); } }, 500); }); })} > onClick={(event) => event.preventDefault()} href="#" size="sm"> Forgot password?
); }