Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
derevnjuk committed Sep 1, 2021
2 parents b852ae1 + 155c0af commit 1003483
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
4 changes: 4 additions & 0 deletions public/public/assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1732,3 +1732,7 @@ section {
display: contents;
cursor: pointer;
}

.error-text {
color: #ff0000;
}
10 changes: 9 additions & 1 deletion public/src/api/makeApiRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ export function makeApiRequest<T>(
if (error.response.status === 401) {
sessionStorage.removeItem('email');
sessionStorage.removeItem('token');
window.location.reload();
return {
...error,
errorText:
'Authentication failed, please check your credentials and try again'
};
}
return {
...error,
errorText: 'Something went wrong. Please try again later'
};
});
}
1 change: 1 addition & 0 deletions public/src/interfaces/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export enum LoginFormMode {
export interface LoginResponse {
email: string;
ldapProfileLink: string;
errorText: string | null;
}

export interface RegistrationUser {
Expand Down
10 changes: 7 additions & 3 deletions public/src/pages/auth/Login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const Login: FC = () => {

const [loginResponse, setLoginResponse] = useState<LoginResponse | null>();
const [ldapResponse, setLdapResponse] = useState<Array<RegistrationUser>>([]);
const [errorText, setErrorText] = useState<string | null>();

const [mode, setMode] = useState<LoginFormMode>(LoginFormMode.BASIC);
const [csrf, setCsrf] = useState<string>();
Expand Down Expand Up @@ -74,9 +75,12 @@ export const Login: FC = () => {
getUser(params, config)
.then((data: LoginResponse) => {
setLoginResponse(data);
return data.email;
return data;
})
.then((email) => sessionStorage.setItem('email', email));
.then(({ email, errorText }) => {
setErrorText(errorText);
sessionStorage.setItem('email', email);
});
};

const sendLdap = () => {
Expand Down Expand Up @@ -181,7 +185,7 @@ export const Login: FC = () => {
onInput={onInput}
/>
</div>

{errorText && <div className="error-text">{errorText}</div>}
<div className="form-group">
<label>Password</label>
<input
Expand Down

0 comments on commit 1003483

Please sign in to comment.