master
alex 2024-01-28 18:51:14 +01:00
parent 2456a0ab6d
commit a2f0a71bf4
1 changed files with 8 additions and 18 deletions

View File

@ -1,4 +1,3 @@
import { LoginOutlined } from "@ant-design/icons";
import {
Button,
Checkbox,
@ -7,7 +6,6 @@ import {
Modal,
Result,
Space,
Tabs,
Typography,
notification,
} from "antd";
@ -34,29 +32,17 @@ const AuthenticationMethod = {
};
export default function Authentication() {
const { t, i18n } = useTranslation();
const [form] = Form.useForm();
const [notificationApi, notificationContextHolder] =
notification.useNotification();
const [selectedMethod, setSelectedMethod] = useState(
AuthenticationMethod.LOGIN
);
const [isRequesting, setIsRequesting] = useState(false);
const showErrorNotification = (errStatus) => {
if (errStatus === 400) {
notificationApi["error"]({
message: t("login.request.400.title"),
description: t("login.request.400.description"),
});
}
};
return (
<>
{notificationContextHolder}
<Modal
open={true}
mask={false}
@ -106,6 +92,7 @@ const LoginStep = {
PENDING_DELETION: 3,
INIT_LOGIN: 4,
BANNED: 5,
_BACK_TO_PASSWORD: 6, // needed for going back from pending deletion to password step as the useEffect for the account name is triggered and would set the step to account name
};
// First step: account name -> get state of account by backend
@ -131,11 +118,14 @@ function Login({ switchMethod, notificationApi }) {
useEffect(() => {
if (!accountName) return;
console.log("accountName here", step);
// triggered if step was set to pending deletion and the user wants to reactivate the account
if (step === LoginStep._BACK_TO_PASSWORD) {
setStep(LoginStep.PASSWORD);
return;
}
// reset step if account name changed for handling the state of the account
if (step === LoginStep.PASSWORD || step === LoginStep.INIT_LOGIN) {
console.log("reset step", accountName);
setStep(LoginStep.ACCOUNT_NAME);
}
}, [accountName]);
@ -157,7 +147,7 @@ function Login({ switchMethod, notificationApi }) {
type="primary"
onClick={() => {
console.log("reactivate account");
setStep(LoginStep.PASSWORD);
setStep(LoginStep._BACK_TO_PASSWORD);
}}
>
{t("authentication.login.stateAccountPendingDeletion.button")}