Browse Source

login: Fix login message from server.

main
StalinistApologist 4 months ago
parent
commit
e806fc2499
  1. 6
      src/components/login.tsx
  2. 4
      src/utils.ts

6
src/components/login.tsx

@ -450,7 +450,7 @@ export class Login extends Component<any, State> {
api
.post<LoginResponse>('user/login', this.state.loginForm)
.then(res => {
const data = res.data;
const { data } = res;
console.log(data);
if (data.requires_2fa) {
this.setState({
@ -467,8 +467,8 @@ export class Login extends Component<any, State> {
.catch((err: Error | AxiosError) => {
const res = (err as AxiosError).response;
if (res) {
const data = res.data as { error: string };
toast(i18n.t(data.error), 'danger');
const { message } = res.data;
toast(i18n.t(message), 'danger');
} else {
console.log(err);
}

4
src/utils.ts

@ -538,8 +538,8 @@ export function isCommentType(item: Comment | PrivateMessage): item is Comment {
export function toast(text: string, background = 'success'): void {
let backgroundColor = `var(--${background})`;
Toastify({
text: text,
backgroundColor: backgroundColor,
text,
backgroundColor,
gravity: 'bottom',
position: 'left',
}).showToast();

Loading…
Cancel
Save