pass error from telegram server to client
This commit is contained in:
parent
6de1e1823f
commit
1ea939f41f
@ -79,7 +79,7 @@ export class LdapTfaController extends LdapController {
|
||||
},
|
||||
})
|
||||
.then((res) => reply.status(200).send(res.data))
|
||||
.catch((error) => reply.status(500).send(error));
|
||||
.catch((error) => reply.status(500).send(error.response.data));
|
||||
}
|
||||
|
||||
@Get('/telegram-confirm')
|
||||
|
||||
@ -5,8 +5,9 @@ import styles from './Form.module.scss';
|
||||
import { publicRuntimeConfig } from '@/config/runtime';
|
||||
import { FormStateContext } from '@/context/form-state';
|
||||
import { useSocket } from '@/hooks/socket';
|
||||
import type { TelegramUrlResponse } from '@/types/error';
|
||||
import type { LdapUser } from '@/types/user';
|
||||
import axios from 'axios';
|
||||
import axios, { isAxiosError } from 'axios';
|
||||
import Image from 'next/image';
|
||||
import type { PropsWithChildren } from 'react';
|
||||
import { useContext, useEffect } from 'react';
|
||||
@ -157,12 +158,18 @@ export const Form = {
|
||||
type: 'set-step',
|
||||
});
|
||||
})
|
||||
.catch(() =>
|
||||
dispatch({
|
||||
payload: { error: ERROR_SERVER },
|
||||
.catch((error_) => {
|
||||
let error = ERROR_SERVER;
|
||||
|
||||
if (isAxiosError<TelegramUrlResponse>(error_) && error_.response?.data?.message) {
|
||||
error = error_.response?.data?.message;
|
||||
}
|
||||
|
||||
return dispatch({
|
||||
payload: { error },
|
||||
type: 'set-error',
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (step === 'telegram') {
|
||||
|
||||
3
apps/web/types/error.ts
Normal file
3
apps/web/types/error.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export type TelegramUrlResponse = {
|
||||
message: string;
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user