feat: remove login page (temp)

This commit is contained in:
Sonny
2024-11-05 22:27:17 +01:00
committed by Sonny
parent 41f82a8070
commit db578dbe51
10 changed files with 17 additions and 122 deletions

View File

@@ -5,7 +5,7 @@ import db from '@adonisjs/lucid/services/db';
import { RouteName } from '@izzyjs/route/types';
export default class UsersController {
private redirectTo: RouteName = 'auth.login';
private redirectTo: RouteName = 'auth';
login({ inertia }: HttpContext) {
return inertia.render('login');
@@ -67,7 +67,7 @@ export default class UsersController {
await auth.use('web').logout();
session.flash('flash', 'Successfully disconnected');
logger.info(`[${auth.user?.email}] disconnected successfully`);
response.redirectToNamedRoute(this.redirectTo);
response.redirect('/');
}
async getAllUsersWithTotalRelations() {

View File

@@ -11,7 +11,7 @@ export default class AuthMiddleware {
/**
* The URL to redirect to, when authentication fails
*/
redirectTo = route('auth.login').url;
redirectTo = route('auth').path;
async handle(
ctx: HttpContext,

View File

@@ -1,5 +1,7 @@
import { route } from '@izzyjs/route/client';
import { Avatar, Group, Menu, Text, UnstyledButton } from '@mantine/core';
import { forwardRef } from 'react';
import { useTranslation } from 'react-i18next';
import { TbChevronRight } from 'react-icons/tb';
import useUser from '~/hooks/use_user';
@@ -44,6 +46,7 @@ const UserButton = forwardRef<HTMLButtonElement, UserButtonProps>(
);
export function MantineUserCard() {
const { t } = useTranslation('common');
const { user, isAuthenticated } = useUser();
return (
isAuthenticated && (
@@ -56,7 +59,9 @@ export function MantineUserCard() {
/>
</Menu.Target>
<Menu.Dropdown>
<Menu.Item>Logout</Menu.Item>
<Menu.Item component="a" href={route('auth.logout').path}>
{t('logout')}
</Menu.Item>
</Menu.Dropdown>
</Menu>
)

View File

@@ -50,8 +50,8 @@ export default function MantineNavbar() {
<MantineLanguageSwitcher />
{!isAuthenticated ? (
<Button
component={Link}
href={route('auth.login').url}
component="a"
href={route('auth').path}
visibleFrom="sm"
w={110}
>
@@ -60,7 +60,7 @@ export default function MantineNavbar() {
) : (
<Button
component={Link}
href={route('dashboard').url}
href={route('dashboard').path}
visibleFrom="sm"
w={110}
>
@@ -102,7 +102,7 @@ export default function MantineNavbar() {
<Group justify="center" grow pb="xl" px="md">
{!isAuthenticated ? (
<Button component={Link} href={route('auth.login').url}>
<Button component="a" href={route('auth').path}>
{t('login')}
</Button>
) : (

View File

@@ -97,7 +97,7 @@ export default function Navbar() {
<ModalSettings openItem={DropdownItemButtonWithPadding} />
</li>
<li>
<Link href={route('auth.login').url}>{t('login')}</Link>
<Link href={route('auth').path}>{t('login')}</Link>
</li>
</>
)}

View File

@@ -8,29 +8,26 @@ import frResourceAbout from './locales/fr/about.json';
import frResourceAdmin from './locales/fr/admin.json';
import frResourceCommon from './locales/fr/common.json';
import frResourceHome from './locales/fr/home.json';
import frResourceLogin from './locales/fr/login.json';
import frResourceLegal from './locales/fr/legal.json';
import frResourcePrivacy from './locales/fr/privacy.json';
import frResourceTerms from './locales/fr/terms.json';
import frResourceLegal from './locales/fr/legal.json';
import { LS_LANG_KEY } from '~/constants';
import enResourceAbout from './locales/en/about.json';
import enResourceAdmin from './locales/en/admin.json';
import enResourceCommon from './locales/en/common.json';
import enResourceHome from './locales/en/home.json';
import enResourceLogin from './locales/en/login.json';
import enResourceLegal from './locales/en/legal.json';
import enResourcePrivacy from './locales/en/privacy.json';
import enResourceTerms from './locales/en/terms.json';
import enResourceLegal from './locales/en/legal.json';
type I18nFR =
| RemoveSuffix<Leaves<typeof frResourceAbout>>
| RemoveSuffix<Leaves<typeof frResourceAdmin>>
| RemoveSuffix<Leaves<typeof frResourceCommon>>
| RemoveSuffix<Leaves<typeof frResourceHome>>
| RemoveSuffix<Leaves<typeof frResourceLogin>>
| RemoveSuffix<Leaves<typeof frResourcePrivacy>>
| RemoveSuffix<Leaves<typeof frResourceTerms>>
| RemoveSuffix<Leaves<typeof frResourceLegal>>;
@@ -42,7 +39,6 @@ export const resources = {
admin: enResourceAdmin,
common: enResourceCommon,
home: enResourceHome,
login: enResourceLogin,
privacy: enResourcePrivacy,
terms: enResourceTerms,
legal: enResourceLegal,
@@ -52,7 +48,6 @@ export const resources = {
admin: frResourceAdmin,
common: frResourceCommon,
home: frResourceHome,
login: frResourceLogin,
privacy: frResourcePrivacy,
terms: frResourceTerms,
legal: frResourceLegal,

View File

@@ -1,6 +0,0 @@
{
"title": "Authentication",
"informative-text": "Authentication required to use MyLinks",
"continue-with": "Continue with {{provider}}",
"accept-terms": "By continuing, you accept the"
}

View File

@@ -1,6 +0,0 @@
{
"title": "Authentification",
"informative-text": "Authentification requise pour utiliser MyLinks",
"continue-with": "Continuer avec {{provider}}",
"accept-terms": "En poursuivant, vous acceptez les"
}

View File

@@ -1,92 +0,0 @@
import styled from '@emotion/styled';
import { Head, Link } from '@inertiajs/react';
import { route } from '@izzyjs/route/client';
import { ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
import { FcGoogle } from 'react-icons/fc';
import Button from '~/components/common/form/_button';
import ContentLayout from '~/components/layouts/content_layout';
import Quotes from '~/components/quotes';
const LoginContainer = styled.div({
width: '100%',
maxWidth: '100%',
whiteSpace: 'nowrap',
marginTop: '50px',
paddingInline: '1rem',
display: 'flex',
alignItems: 'center',
gap: '1.5em',
flexDirection: 'column',
});
const FormWrapper = styled.div(({ theme }) => ({
width: '500px',
maxWidth: '100%',
backgroundColor: theme.colors.secondary,
padding: '2em',
borderRadius: theme.border.radius,
border: `1px solid ${theme.colors.lightGrey}`,
display: 'flex',
gap: '1em',
flex: 1,
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'column',
}));
const InformativeText = styled.p(({ theme }) => ({
width: '100%',
padding: '10px',
textAlign: 'center',
color: theme.colors.darkBlue,
backgroundColor: theme.colors.lightestBlue,
borderRadius: theme.border.radius,
}));
const AgreementText = styled.p(({ theme }) => ({
color: theme.colors.grey,
}));
const ButtonLink = styled(Button.withComponent('a'))({
display: 'flex',
gap: '0.35em',
alignItems: 'center',
justifyContent: 'center',
});
function LoginPage() {
const { t } = useTranslation();
return (
<LoginContainer>
<Head title={t('login:title')} />
<img
src={'/logo-light.png'}
width={300}
height={100}
alt="MyLinks's logo"
/>
<Quotes css={{ marginBottom: '3em' }}>{t('common:slogan')}</Quotes>
<FormWrapper>
<h1>{t('login:title')}</h1>
<InformativeText>{t('login:informative-text')}</InformativeText>
<ButtonLink href={route('auth.google').url}>
<FcGoogle size="1.5em" />{' '}
{t('login:continue-with', { provider: 'Google' })}
</ButtonLink>
</FormWrapper>
<AgreementText>
{t('login:accept-terms')}{' '}
<Link href={route('terms').url}>{t('common:terms')}</Link>
</AgreementText>
</LoginContainer>
);
}
LoginPage.layout = (page: ReactNode) => (
<ContentLayout
children={page}
css={{ display: 'flex', alignItems: 'center' }}
/>
);
export default LoginPage;

View File

@@ -9,8 +9,7 @@ const ROUTES_PREFIX = '/auth';
*/
router
.group(() => {
router.get('/login', [UsersController, 'login']).as('auth.login');
router.get('/google', [UsersController, 'google']).as('auth.google');
router.get('/google', [UsersController, 'google']).as('auth');
router
.get('/callback', [UsersController, 'callbackAuth'])
.as('auth.callback');