Merge branch 'feature/add-basic-authentication' of https://github.com/ajnart/homarr into feature/add-basic-authentication
This commit is contained in:
1
next-env.d.ts
vendored
1
next-env.d.ts
vendored
@@ -1,6 +1,5 @@
|
|||||||
/// <reference types="next" />
|
/// <reference types="next" />
|
||||||
/// <reference types="next/image-types/global" />
|
/// <reference types="next/image-types/global" />
|
||||||
/// <reference types="next/navigation-types/compat/navigation" />
|
|
||||||
|
|
||||||
// NOTE: This file should not be edited
|
// NOTE: This file should not be edited
|
||||||
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"title": "Error",
|
"title": "Error",
|
||||||
"text": "Something went wrong"
|
"text": "Something went wrong, got the following error: {{error}}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Box, createStyles, useMantineTheme } from '@mantine/core';
|
import { Box, createStyles, useMantineTheme } from '@mantine/core';
|
||||||
import { useMouse, useViewportSize } from '@mantine/hooks';
|
import { useMouse } from '@mantine/hooks';
|
||||||
|
|
||||||
import { PolkaElement } from './PolkaElement';
|
import { PolkaElement } from './PolkaElement';
|
||||||
|
|
||||||
@@ -12,6 +12,7 @@ export const FloatingBackground = () => {
|
|||||||
<PolkaElement rotation={95} top={0} left={100} />
|
<PolkaElement rotation={95} top={0} left={100} />
|
||||||
<PolkaElement rotation={10} top={50} right={20} />
|
<PolkaElement rotation={10} top={50} right={20} />
|
||||||
<PolkaElement rotation={-4} bottom={20} left={20} />
|
<PolkaElement rotation={-4} bottom={20} left={20} />
|
||||||
|
<PolkaElement rotation={-10} bottom={0} right={0} />
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
@@ -19,9 +20,7 @@ export const FloatingBackground = () => {
|
|||||||
|
|
||||||
const MouseBackdrop = () => {
|
const MouseBackdrop = () => {
|
||||||
const { x, y } = useMouse();
|
const { x, y } = useMouse();
|
||||||
const { width, height } = useViewportSize();
|
const radius = 40;
|
||||||
const smaller = Math.min(width, height);
|
|
||||||
const radius = Math.max(smaller - 500, 200);
|
|
||||||
return (
|
return (
|
||||||
<Box pos="absolute" top={0} left={0} w="100%" h="100%">
|
<Box pos="absolute" top={0} left={0} w="100%" h="100%">
|
||||||
<Box
|
<Box
|
||||||
|
|||||||
@@ -1,4 +1,14 @@
|
|||||||
import { Button, Card, Flex, PasswordInput, Stack, Text, TextInput, Title } from '@mantine/core';
|
import {
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
Flex,
|
||||||
|
PasswordInput,
|
||||||
|
Popover,
|
||||||
|
Stack,
|
||||||
|
Text,
|
||||||
|
TextInput,
|
||||||
|
Title,
|
||||||
|
} from '@mantine/core';
|
||||||
import { useForm } from '@mantine/form';
|
import { useForm } from '@mantine/form';
|
||||||
import { showNotification, updateNotification } from '@mantine/notifications';
|
import { showNotification, updateNotification } from '@mantine/notifications';
|
||||||
import { IconCheck, IconX } from '@tabler/icons-react';
|
import { IconCheck, IconX } from '@tabler/icons-react';
|
||||||
@@ -9,6 +19,8 @@ import Head from 'next/head';
|
|||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
import { PasswordRequirements } from '~/components/Password/password-requirements';
|
||||||
|
import { FloatingBackground } from '~/components/layout/Background/FloatingBackground';
|
||||||
import { getServerAuthSession } from '~/server/auth';
|
import { getServerAuthSession } from '~/server/auth';
|
||||||
import { prisma } from '~/server/db';
|
import { prisma } from '~/server/db';
|
||||||
import { getServerSideTranslations } from '~/tools/server/getServerSideTranslations';
|
import { getServerSideTranslations } from '~/tools/server/getServerSideTranslations';
|
||||||
@@ -23,13 +35,18 @@ export default function AuthInvitePage() {
|
|||||||
const { i18nZodResolver } = useI18nZodResolver();
|
const { i18nZodResolver } = useI18nZodResolver();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const query = router.query as { token: string };
|
const query = router.query as { token: string };
|
||||||
const { mutateAsync } = api.user.createFromInvite.useMutation();
|
const { mutateAsync, isError } = api.user.createFromInvite.useMutation();
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
const form = useForm<z.infer<typeof signUpFormSchema>>({
|
const form = useForm<z.infer<typeof signUpFormSchema>>({
|
||||||
validateInputOnChange: true,
|
validateInputOnChange: true,
|
||||||
validateInputOnBlur: true,
|
validateInputOnBlur: true,
|
||||||
validate: i18nZodResolver(signUpFormSchema),
|
validate: i18nZodResolver(signUpFormSchema),
|
||||||
|
initialValues: {
|
||||||
|
username: '',
|
||||||
|
password: '',
|
||||||
|
passwordConfirmation: '',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleSubmit = (values: z.infer<typeof signUpFormSchema>) => {
|
const handleSubmit = (values: z.infer<typeof signUpFormSchema>) => {
|
||||||
@@ -68,11 +85,11 @@ export default function AuthInvitePage() {
|
|||||||
router.push('/manage');
|
router.push('/manage');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onError() {
|
onError(error) {
|
||||||
updateNotification({
|
updateNotification({
|
||||||
id: notificationId,
|
id: notificationId,
|
||||||
title: t('notifications.error.title'),
|
title: t('notifications.error.title'),
|
||||||
message: t('notifications.error.text'),
|
message: t('notifications.error.text', { error: error.message }),
|
||||||
color: 'red',
|
color: 'red',
|
||||||
icon: <IconX />,
|
icon: <IconX />,
|
||||||
});
|
});
|
||||||
@@ -90,6 +107,7 @@ export default function AuthInvitePage() {
|
|||||||
</Head>
|
</Head>
|
||||||
|
|
||||||
<Flex h="100dvh" display="flex" w="100%" direction="column" align="center" justify="center">
|
<Flex h="100dvh" display="flex" w="100%" direction="column" align="center" justify="center">
|
||||||
|
<FloatingBackground />
|
||||||
<Card withBorder shadow="md" p="xl" radius="md" w="90%" maw={420}>
|
<Card withBorder shadow="md" p="xl" radius="md" w="90%" maw={420}>
|
||||||
<Title align="center" weight={900}>
|
<Title align="center" weight={900}>
|
||||||
{t('title')}
|
{t('title')}
|
||||||
@@ -107,13 +125,20 @@ export default function AuthInvitePage() {
|
|||||||
withAsterisk
|
withAsterisk
|
||||||
{...form.getInputProps('username')}
|
{...form.getInputProps('username')}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<PasswordInput
|
<PasswordInput
|
||||||
variant="filled"
|
variant="filled"
|
||||||
label={t('form.fields.password.label')}
|
label={t('form.fields.password.label')}
|
||||||
withAsterisk
|
withAsterisk
|
||||||
{...form.getInputProps('password')}
|
{...form.getInputProps('password')}
|
||||||
/>
|
/>
|
||||||
|
<Card
|
||||||
|
withBorder
|
||||||
|
style={{
|
||||||
|
display: form.isValid('password') ? 'none' : 'block',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<PasswordRequirements value={form.values.password} />
|
||||||
|
</Card>
|
||||||
|
|
||||||
<PasswordInput
|
<PasswordInput
|
||||||
variant="filled"
|
variant="filled"
|
||||||
@@ -122,7 +147,7 @@ export default function AuthInvitePage() {
|
|||||||
{...form.getInputProps('passwordConfirmation')}
|
{...form.getInputProps('passwordConfirmation')}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Button fullWidth type="submit" loading={isLoading}>
|
<Button fullWidth type="submit" disabled={!form.isValid()} loading={isLoading}>
|
||||||
{t('form.buttons.submit')}
|
{t('form.buttons.submit')}
|
||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
@@ -182,7 +207,12 @@ export const getServerSideProps: GetServerSideProps = async ({
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
...(await getServerSideTranslations(['authentication/invite'], locale, req, res)),
|
...(await getServerSideTranslations(
|
||||||
|
['authentication/invite', 'password-requirements'],
|
||||||
|
locale,
|
||||||
|
req,
|
||||||
|
res
|
||||||
|
)),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user