show default telegram error | remove sending error from api
This commit is contained in:
parent
cc8b59011c
commit
e41d6e3c46
@ -79,7 +79,7 @@ export class LdapTfaController extends LdapController {
|
||||
},
|
||||
})
|
||||
.then((res) => reply.status(200).send(res.data))
|
||||
.catch((error) => reply.status(500).send(error.response.data));
|
||||
.catch(() => reply.status(500).send());
|
||||
}
|
||||
|
||||
@Get('/telegram-confirm')
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
import type { FormData } from '../lib/types';
|
||||
import { useSocket } from './socket';
|
||||
import { redirect } from '@/components/Form/lib/utils';
|
||||
import { ERROR_INVALID_CREDENTIALS, ERROR_SERVER } from '@/constants/errors';
|
||||
import {
|
||||
ERROR_INVALID_CREDENTIALS,
|
||||
ERROR_SERVER,
|
||||
ERROR_TELEGRAM_SEND_MESSAGE,
|
||||
} from '@/constants/errors';
|
||||
import { FormStateContext } from '@/context/form-state';
|
||||
import type { TelegramUrlResponse } from '@/types/error';
|
||||
import type { LdapUser } from '@/types/user';
|
||||
import axios, { isAxiosError } from 'axios';
|
||||
import axios from 'axios';
|
||||
import { useContext, useEffect } from 'react';
|
||||
|
||||
export function useLogin() {
|
||||
@ -48,18 +51,12 @@ export function useTelegramLogin() {
|
||||
type: 'set-step',
|
||||
});
|
||||
})
|
||||
.catch((error_) => {
|
||||
let error = ERROR_SERVER;
|
||||
|
||||
if (isAxiosError<TelegramUrlResponse>(error_) && error_.response?.data?.message) {
|
||||
error = error_.response?.data?.message;
|
||||
}
|
||||
|
||||
return dispatch({
|
||||
payload: { error },
|
||||
.catch(() =>
|
||||
dispatch({
|
||||
payload: { error: ERROR_TELEGRAM_SEND_MESSAGE },
|
||||
type: 'set-error',
|
||||
});
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return { handleTelegramLogin };
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
export const ERROR_INVALID_CREDENTIALS = 'Неверный логин или пароль';
|
||||
export const ERROR_SERVER = 'Не удалось войти. Повторите попытку позже';
|
||||
export const ERROR_TELEGRAM_SEND_MESSAGE = 'Не удалось отправить сообщение в Telegram';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user