mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
auth: refactored sagas to use try-catch
This commit is contained in:
parent
7d2511e7e9
commit
c36494c3f9
22 changed files with 400 additions and 424 deletions
|
@ -1,4 +1,4 @@
|
|||
import axios, { AxiosRequestConfig } from 'axios';
|
||||
import axios, { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios';
|
||||
import { push } from 'connected-react-router';
|
||||
import { API } from '~/constants/api';
|
||||
import { store } from '~/redux/store';
|
||||
|
@ -50,3 +50,5 @@ export const configWithToken = (
|
|||
...config,
|
||||
headers: { ...(config.headers || {}), Authorization: `Bearer ${access}` },
|
||||
});
|
||||
|
||||
export const cleanResult = <T extends any>(response: AxiosResponse<T>): T => response?.data;
|
||||
|
|
|
@ -3,13 +3,13 @@ import { IMAGE_MIME_TYPES } from '~/utils/uploader';
|
|||
|
||||
const isValidEmail = (email: string): boolean =>
|
||||
!!email &&
|
||||
String(email) &&
|
||||
!!String(email) &&
|
||||
!!String(email).match(
|
||||
/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/
|
||||
);
|
||||
|
||||
const isLikeEmail = (email: string): boolean =>
|
||||
!!email && String(email) && !!String(email).match(/^([^\@]+)@([^\@]+)\.([^\@]+)$$/);
|
||||
!!email && !!String(email) && !!String(email).match(/^([^\@]+)@([^\@]+)\.([^\@]+)$$/);
|
||||
|
||||
const isNonEmpty = (value: string): boolean => !!value && value.trim().length > 0;
|
||||
const isLikePhone = isNonEmpty;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue