2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-29 12:06:44 +00:00

feat(frontend): show if redirecting inline (#9122)

* https://github.com/inventree/InvenTree/pull/6293

* refactor to a shared component

* refactoring container stuff to a wrapper

* move title to wrapper

* move logoff and loader to wrapper

* mvoe functions to general auth

* seperate login and register into seperate pages

* unify auth styling

* rename component

* adapt to new look

* check if registration is enabled

* feat(frontend):show if redirecting

* reduce diff

* fix missing import

* remove double warning
This commit is contained in:
Matthias Mair 2025-03-16 23:03:42 +01:00 committed by GitHub
parent a453c9b286
commit 897afd029b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,7 +1,7 @@
import { Trans, t } from '@lingui/macro'; import { Trans, t } from '@lingui/macro';
import { Anchor, Divider, Text } from '@mantine/core'; import { Anchor, Divider, Loader, Text } from '@mantine/core';
import { useToggle } from '@mantine/hooks'; import { useToggle } from '@mantine/hooks';
import { useEffect, useMemo } from 'react'; import { useEffect, useMemo, useState } from 'react';
import { useLocation, useNavigate, useSearchParams } from 'react-router-dom'; import { useLocation, useNavigate, useSearchParams } from 'react-router-dom';
import { setApiDefaults } from '../../App'; import { setApiDefaults } from '../../App';
import { AuthFormOptions } from '../../components/forms/AuthFormOptions'; import { AuthFormOptions } from '../../components/forms/AuthFormOptions';
@ -27,6 +27,7 @@ export default function Login() {
state.server, state.server,
state.fetchServerApiState state.fetchServerApiState
]); ]);
const [isLoggingIn, setIsLoggingIn] = useState<boolean>(false);
const hostname = const hostname =
hostList[hostKey] === undefined ? t`No selection` : hostList[hostKey]?.name; hostList[hostKey] === undefined ? t`No selection` : hostList[hostKey]?.name;
const [hostEdit, setHostEdit] = useToggle([false, true] as const); const [hostEdit, setHostEdit] = useToggle([false, true] as const);
@ -73,6 +74,7 @@ export default function Login() {
// check if we got login params (login and password) // check if we got login params (login and password)
if (searchParams.has('login') && searchParams.has('password')) { if (searchParams.has('login') && searchParams.has('password')) {
setIsLoggingIn(true);
doBasicLogin( doBasicLogin(
searchParams.get('login') ?? '', searchParams.get('login') ?? '',
searchParams.get('password') ?? '', searchParams.get('password') ?? '',
@ -94,6 +96,10 @@ export default function Login() {
) : ( ) : (
<> <>
<Wrapper titleText={t`Login`} smallPadding> <Wrapper titleText={t`Login`} smallPadding>
{isLoggingIn ? (
<Loader />
) : (
<>
<AuthenticationForm /> <AuthenticationForm />
{both_reg_enabled === false && ( {both_reg_enabled === false && (
<Text ta='center' size={'xs'} mt={'md'}> <Text ta='center' size={'xs'} mt={'md'}>
@ -109,7 +115,9 @@ export default function Login() {
</Anchor> </Anchor>
</Text> </Text>
)} )}
{LoginMessage} {LoginMessage}{' '}
</>
)}
</Wrapper> </Wrapper>
<AuthFormOptions hostname={hostname} toggleHostEdit={setHostEdit} /> <AuthFormOptions hostname={hostname} toggleHostEdit={setHostEdit} />
</> </>