Remove login form, only allow the SudoVanilla Gateway

This commit is contained in:
Korbs 2024-12-19 16:24:17 -05:00
parent 5686e9db83
commit 8a0c3a0745

View file

@ -4,17 +4,13 @@ import {
Card, Card,
Center, Center,
CheckIcon, CheckIcon,
Divider,
Group, Group,
Modal, Modal,
PasswordInput,
PinInput, PinInput,
Text, Text,
TextInput,
Title, Title,
} from '@mantine/core'; } from '@mantine/core';
import { useForm } from '@mantine/form'; import { useForm } from '@mantine/form';
import { IconBrandDiscordFilled, IconBrandGithub, IconBrandGoogle, IconKey } from '@tabler/icons-react';
import useFetch from 'hooks/useFetch'; import useFetch from 'hooks/useFetch';
import Head from 'next/head'; import Head from 'next/head';
import Link from 'next/link'; import Link from 'next/link';
@ -24,7 +20,6 @@ export { getServerSideProps } from 'middleware/getServerSideProps';
export default function Login({ export default function Login({
title, title,
user_registration,
oauth_registration, oauth_registration,
bypass_local_login, bypass_local_login,
oauth_providers: unparsed, oauth_providers: unparsed,
@ -40,20 +35,6 @@ export default function Login({
const oauth_providers = JSON.parse(unparsed); const oauth_providers = JSON.parse(unparsed);
const show_local_login =
router.query.local === 'true' || !(bypass_local_login && oauth_providers?.length > 0);
const icons = {
GitHub: IconBrandGithub,
Discord: IconBrandDiscordFilled,
Google: IconBrandGoogle,
Authentik: IconKey,
};
for (const provider of oauth_providers) {
provider.Icon = icons[provider.name];
}
const form = useForm({ const form = useForm({
initialValues: { initialValues: {
username: '', username: '',
@ -124,7 +105,7 @@ export default function Login({
return ( return (
<> <>
<Head> <Head>
<title>{full_title}</title> <title>SudoVanilla Zipline</title>
</Head> </Head>
<Modal <Modal
opened={totpOpen} opened={totpOpen}
@ -166,11 +147,6 @@ export default function Login({
</Button> </Button>
</Modal> </Modal>
<Center sx={{ height: '100vh' }}> <Center sx={{ height: '100vh' }}>
<Card radius='md'>
<Title size={30} align='left'>
{bypass_local_login ? ` Login to ${title} with` : title}
</Title>
{oauth_registration && ( {oauth_registration && (
<> <>
<Group grow> <Group grow>
@ -178,55 +154,19 @@ export default function Login({
<Button <Button
key={i} key={i}
size='sm' size='sm'
variant='outline' variant='filled'
radius='md' radius='lg'
fullWidth fullWidth
leftIcon={<Icon size='1rem' />}
my='xs' my='xs'
component={Link} component={Link}
href={url} href={url}
> >
{name} Login via SudoVanilla Gateway
</Button> </Button>
))} ))}
</Group> </Group>
{show_local_login && <Divider my='xs' label='or' labelPosition='center' />}
</> </>
)} )}
{show_local_login && (
<form onSubmit={form.onSubmit((v) => onSubmit(v))}>
<TextInput
my='xs'
radius='md'
size='md'
id='username'
label='Username'
{...form.getInputProps('username')}
/>
<PasswordInput
my='xs'
radius='md'
size='md'
id='password'
label='Password'
{...form.getInputProps('password')}
/>
<Group position='apart'>
{user_registration && (
<Anchor size='xs' href='/auth/register' component={Link}>
Don&apos;t have an account? Register
</Anchor>
)}
<Button size='sm' p='xs' radius='md' my='xs' type='submit' loading={loading}>
Login
</Button>
</Group>
</form>
)}
</Card>
</Center> </Center>
</> </>
); );