mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-15 11:37:57 +01:00
Fix login.
This commit is contained in:
parent
20c4ccc1ff
commit
fc0c03b2bc
@ -25,18 +25,19 @@ export type Model = {
|
|||||||
password: string;
|
password: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type LoginErrorProps = {
|
||||||
|
errorCode: number | undefined;
|
||||||
|
};
|
||||||
|
|
||||||
const defaultModel: Model = { email: '', password: '' };
|
const defaultModel: Model = { email: '', password: '' };
|
||||||
|
|
||||||
const LoginError = () => {
|
const LoginError = ({ errorCode }: LoginErrorProps) => {
|
||||||
// @Todo: This must be reviewed to be based on navigation state.
|
|
||||||
// Login error example: http://localhost:8080/c/login?login.error=2
|
|
||||||
const errorCode = new URLSearchParams(window.location.search).get('login_error');
|
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
let msg: null | string = null;
|
let msg: null | string = null;
|
||||||
if (errorCode) {
|
if (errorCode) {
|
||||||
switch (errorCode) {
|
switch (errorCode) {
|
||||||
case '3':
|
case 3:
|
||||||
msg = intl.formatMessage({
|
msg = intl.formatMessage({
|
||||||
id: 'login.userinactive',
|
id: 'login.userinactive',
|
||||||
defaultMessage:
|
defaultMessage:
|
||||||
@ -56,6 +57,8 @@ const LoginError = () => {
|
|||||||
const LoginPage = (): React.ReactElement => {
|
const LoginPage = (): React.ReactElement => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const [model, setModel] = useState<Model>(defaultModel);
|
const [model, setModel] = useState<Model>(defaultModel);
|
||||||
|
const [loginError, setLoginError] = useState<number | undefined>(undefined);
|
||||||
|
|
||||||
const client: Client = useSelector(activeInstance);
|
const client: Client = useSelector(activeInstance);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
@ -72,7 +75,9 @@ const LoginPage = (): React.ReactElement => {
|
|||||||
{
|
{
|
||||||
onSuccess: () => navigate('/c/maps/'),
|
onSuccess: () => navigate('/c/maps/'),
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
|
// Hardcode error code...
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
setLoginError(2);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -103,7 +108,7 @@ const LoginPage = (): React.ReactElement => {
|
|||||||
<FormattedMessage id="login.desc" defaultMessage="Log into your account" />
|
<FormattedMessage id="login.desc" defaultMessage="Log into your account" />
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
<LoginError />
|
<LoginError errorCode={loginError} />
|
||||||
|
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<form onSubmit={handleOnSubmit}>
|
<form onSubmit={handleOnSubmit}>
|
||||||
|
Loading…
Reference in New Issue
Block a user