mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 07:03:25 +00:00
feat: remove login page (temp)
This commit is contained in:
@@ -5,7 +5,7 @@ import db from '@adonisjs/lucid/services/db';
|
|||||||
import { RouteName } from '@izzyjs/route/types';
|
import { RouteName } from '@izzyjs/route/types';
|
||||||
|
|
||||||
export default class UsersController {
|
export default class UsersController {
|
||||||
private redirectTo: RouteName = 'auth.login';
|
private redirectTo: RouteName = 'auth';
|
||||||
|
|
||||||
login({ inertia }: HttpContext) {
|
login({ inertia }: HttpContext) {
|
||||||
return inertia.render('login');
|
return inertia.render('login');
|
||||||
@@ -67,7 +67,7 @@ export default class UsersController {
|
|||||||
await auth.use('web').logout();
|
await auth.use('web').logout();
|
||||||
session.flash('flash', 'Successfully disconnected');
|
session.flash('flash', 'Successfully disconnected');
|
||||||
logger.info(`[${auth.user?.email}] disconnected successfully`);
|
logger.info(`[${auth.user?.email}] disconnected successfully`);
|
||||||
response.redirectToNamedRoute(this.redirectTo);
|
response.redirect('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAllUsersWithTotalRelations() {
|
async getAllUsersWithTotalRelations() {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default class AuthMiddleware {
|
|||||||
/**
|
/**
|
||||||
* The URL to redirect to, when authentication fails
|
* The URL to redirect to, when authentication fails
|
||||||
*/
|
*/
|
||||||
redirectTo = route('auth.login').url;
|
redirectTo = route('auth').path;
|
||||||
|
|
||||||
async handle(
|
async handle(
|
||||||
ctx: HttpContext,
|
ctx: HttpContext,
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { Avatar, Group, Menu, Text, UnstyledButton } from '@mantine/core';
|
import { Avatar, Group, Menu, Text, UnstyledButton } from '@mantine/core';
|
||||||
import { forwardRef } from 'react';
|
import { forwardRef } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
import { TbChevronRight } from 'react-icons/tb';
|
import { TbChevronRight } from 'react-icons/tb';
|
||||||
import useUser from '~/hooks/use_user';
|
import useUser from '~/hooks/use_user';
|
||||||
|
|
||||||
@@ -44,6 +46,7 @@ const UserButton = forwardRef<HTMLButtonElement, UserButtonProps>(
|
|||||||
);
|
);
|
||||||
|
|
||||||
export function MantineUserCard() {
|
export function MantineUserCard() {
|
||||||
|
const { t } = useTranslation('common');
|
||||||
const { user, isAuthenticated } = useUser();
|
const { user, isAuthenticated } = useUser();
|
||||||
return (
|
return (
|
||||||
isAuthenticated && (
|
isAuthenticated && (
|
||||||
@@ -56,7 +59,9 @@ export function MantineUserCard() {
|
|||||||
/>
|
/>
|
||||||
</Menu.Target>
|
</Menu.Target>
|
||||||
<Menu.Dropdown>
|
<Menu.Dropdown>
|
||||||
<Menu.Item>Logout</Menu.Item>
|
<Menu.Item component="a" href={route('auth.logout').path}>
|
||||||
|
{t('logout')}
|
||||||
|
</Menu.Item>
|
||||||
</Menu.Dropdown>
|
</Menu.Dropdown>
|
||||||
</Menu>
|
</Menu>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ export default function MantineNavbar() {
|
|||||||
<MantineLanguageSwitcher />
|
<MantineLanguageSwitcher />
|
||||||
{!isAuthenticated ? (
|
{!isAuthenticated ? (
|
||||||
<Button
|
<Button
|
||||||
component={Link}
|
component="a"
|
||||||
href={route('auth.login').url}
|
href={route('auth').path}
|
||||||
visibleFrom="sm"
|
visibleFrom="sm"
|
||||||
w={110}
|
w={110}
|
||||||
>
|
>
|
||||||
@@ -60,7 +60,7 @@ export default function MantineNavbar() {
|
|||||||
) : (
|
) : (
|
||||||
<Button
|
<Button
|
||||||
component={Link}
|
component={Link}
|
||||||
href={route('dashboard').url}
|
href={route('dashboard').path}
|
||||||
visibleFrom="sm"
|
visibleFrom="sm"
|
||||||
w={110}
|
w={110}
|
||||||
>
|
>
|
||||||
@@ -102,7 +102,7 @@ export default function MantineNavbar() {
|
|||||||
|
|
||||||
<Group justify="center" grow pb="xl" px="md">
|
<Group justify="center" grow pb="xl" px="md">
|
||||||
{!isAuthenticated ? (
|
{!isAuthenticated ? (
|
||||||
<Button component={Link} href={route('auth.login').url}>
|
<Button component="a" href={route('auth').path}>
|
||||||
{t('login')}
|
{t('login')}
|
||||||
</Button>
|
</Button>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ export default function Navbar() {
|
|||||||
<ModalSettings openItem={DropdownItemButtonWithPadding} />
|
<ModalSettings openItem={DropdownItemButtonWithPadding} />
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<Link href={route('auth.login').url}>{t('login')}</Link>
|
<Link href={route('auth').path}>{t('login')}</Link>
|
||||||
</li>
|
</li>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -8,29 +8,26 @@ import frResourceAbout from './locales/fr/about.json';
|
|||||||
import frResourceAdmin from './locales/fr/admin.json';
|
import frResourceAdmin from './locales/fr/admin.json';
|
||||||
import frResourceCommon from './locales/fr/common.json';
|
import frResourceCommon from './locales/fr/common.json';
|
||||||
import frResourceHome from './locales/fr/home.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 frResourcePrivacy from './locales/fr/privacy.json';
|
||||||
import frResourceTerms from './locales/fr/terms.json';
|
import frResourceTerms from './locales/fr/terms.json';
|
||||||
import frResourceLegal from './locales/fr/legal.json';
|
|
||||||
|
|
||||||
import { LS_LANG_KEY } from '~/constants';
|
import { LS_LANG_KEY } from '~/constants';
|
||||||
import enResourceAbout from './locales/en/about.json';
|
import enResourceAbout from './locales/en/about.json';
|
||||||
import enResourceAdmin from './locales/en/admin.json';
|
import enResourceAdmin from './locales/en/admin.json';
|
||||||
import enResourceCommon from './locales/en/common.json';
|
import enResourceCommon from './locales/en/common.json';
|
||||||
import enResourceHome from './locales/en/home.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 enResourcePrivacy from './locales/en/privacy.json';
|
||||||
import enResourceTerms from './locales/en/terms.json';
|
import enResourceTerms from './locales/en/terms.json';
|
||||||
import enResourceLegal from './locales/en/legal.json';
|
|
||||||
|
|
||||||
type I18nFR =
|
type I18nFR =
|
||||||
| RemoveSuffix<Leaves<typeof frResourceAbout>>
|
| RemoveSuffix<Leaves<typeof frResourceAbout>>
|
||||||
| RemoveSuffix<Leaves<typeof frResourceAdmin>>
|
| RemoveSuffix<Leaves<typeof frResourceAdmin>>
|
||||||
| RemoveSuffix<Leaves<typeof frResourceCommon>>
|
| RemoveSuffix<Leaves<typeof frResourceCommon>>
|
||||||
| RemoveSuffix<Leaves<typeof frResourceHome>>
|
| RemoveSuffix<Leaves<typeof frResourceHome>>
|
||||||
| RemoveSuffix<Leaves<typeof frResourceLogin>>
|
|
||||||
| RemoveSuffix<Leaves<typeof frResourcePrivacy>>
|
| RemoveSuffix<Leaves<typeof frResourcePrivacy>>
|
||||||
| RemoveSuffix<Leaves<typeof frResourceTerms>>
|
| RemoveSuffix<Leaves<typeof frResourceTerms>>
|
||||||
| RemoveSuffix<Leaves<typeof frResourceLegal>>;
|
| RemoveSuffix<Leaves<typeof frResourceLegal>>;
|
||||||
@@ -42,7 +39,6 @@ export const resources = {
|
|||||||
admin: enResourceAdmin,
|
admin: enResourceAdmin,
|
||||||
common: enResourceCommon,
|
common: enResourceCommon,
|
||||||
home: enResourceHome,
|
home: enResourceHome,
|
||||||
login: enResourceLogin,
|
|
||||||
privacy: enResourcePrivacy,
|
privacy: enResourcePrivacy,
|
||||||
terms: enResourceTerms,
|
terms: enResourceTerms,
|
||||||
legal: enResourceLegal,
|
legal: enResourceLegal,
|
||||||
@@ -52,7 +48,6 @@ export const resources = {
|
|||||||
admin: frResourceAdmin,
|
admin: frResourceAdmin,
|
||||||
common: frResourceCommon,
|
common: frResourceCommon,
|
||||||
home: frResourceHome,
|
home: frResourceHome,
|
||||||
login: frResourceLogin,
|
|
||||||
privacy: frResourcePrivacy,
|
privacy: frResourcePrivacy,
|
||||||
terms: frResourceTerms,
|
terms: frResourceTerms,
|
||||||
legal: frResourceLegal,
|
legal: frResourceLegal,
|
||||||
|
|||||||
@@ -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"
|
|
||||||
}
|
|
||||||
@@ -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"
|
|
||||||
}
|
|
||||||
@@ -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;
|
|
||||||
@@ -9,8 +9,7 @@ const ROUTES_PREFIX = '/auth';
|
|||||||
*/
|
*/
|
||||||
router
|
router
|
||||||
.group(() => {
|
.group(() => {
|
||||||
router.get('/login', [UsersController, 'login']).as('auth.login');
|
router.get('/google', [UsersController, 'google']).as('auth');
|
||||||
router.get('/google', [UsersController, 'google']).as('auth.google');
|
|
||||||
router
|
router
|
||||||
.get('/callback', [UsersController, 'callbackAuth'])
|
.get('/callback', [UsersController, 'callbackAuth'])
|
||||||
.as('auth.callback');
|
.as('auth.callback');
|
||||||
|
|||||||
Reference in New Issue
Block a user