auth
parent
2456a0ab6d
commit
a2f0a71bf4
|
@ -1,4 +1,3 @@
|
||||||
import { LoginOutlined } from "@ant-design/icons";
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
|
@ -7,7 +6,6 @@ import {
|
||||||
Modal,
|
Modal,
|
||||||
Result,
|
Result,
|
||||||
Space,
|
Space,
|
||||||
Tabs,
|
|
||||||
Typography,
|
Typography,
|
||||||
notification,
|
notification,
|
||||||
} from "antd";
|
} from "antd";
|
||||||
|
@ -34,29 +32,17 @@ const AuthenticationMethod = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Authentication() {
|
export default function Authentication() {
|
||||||
const { t, i18n } = useTranslation();
|
|
||||||
const [form] = Form.useForm();
|
|
||||||
|
|
||||||
const [notificationApi, notificationContextHolder] =
|
const [notificationApi, notificationContextHolder] =
|
||||||
notification.useNotification();
|
notification.useNotification();
|
||||||
|
|
||||||
const [selectedMethod, setSelectedMethod] = useState(
|
const [selectedMethod, setSelectedMethod] = useState(
|
||||||
AuthenticationMethod.LOGIN
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
{notificationContextHolder}
|
{notificationContextHolder}
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
open={true}
|
open={true}
|
||||||
mask={false}
|
mask={false}
|
||||||
|
@ -106,6 +92,7 @@ const LoginStep = {
|
||||||
PENDING_DELETION: 3,
|
PENDING_DELETION: 3,
|
||||||
INIT_LOGIN: 4,
|
INIT_LOGIN: 4,
|
||||||
BANNED: 5,
|
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
|
// First step: account name -> get state of account by backend
|
||||||
|
@ -131,11 +118,14 @@ function Login({ switchMethod, notificationApi }) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!accountName) return;
|
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
|
// reset step if account name changed for handling the state of the account
|
||||||
if (step === LoginStep.PASSWORD || step === LoginStep.INIT_LOGIN) {
|
if (step === LoginStep.PASSWORD || step === LoginStep.INIT_LOGIN) {
|
||||||
console.log("reset step", accountName);
|
|
||||||
setStep(LoginStep.ACCOUNT_NAME);
|
setStep(LoginStep.ACCOUNT_NAME);
|
||||||
}
|
}
|
||||||
}, [accountName]);
|
}, [accountName]);
|
||||||
|
@ -157,7 +147,7 @@ function Login({ switchMethod, notificationApi }) {
|
||||||
type="primary"
|
type="primary"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
console.log("reactivate account");
|
console.log("reactivate account");
|
||||||
setStep(LoginStep.PASSWORD);
|
setStep(LoginStep._BACK_TO_PASSWORD);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t("authentication.login.stateAccountPendingDeletion.button")}
|
{t("authentication.login.stateAccountPendingDeletion.button")}
|
||||||
|
|
Loading…
Reference in New Issue