added in interceptor
This commit is contained in:
1 parent
fa86988436
commit
0db9fc75dc
2 files changed
+7
-5
No files matched your search
@@ -12,8 +12,7 @@ const initialState = {
|
|||||||
|
|
||||||
export const register = createAsyncThunk("auth/register", async (form, thunkApi) => {
|
export const register = createAsyncThunk("auth/register", async (form, thunkApi) => {
|
||||||
try {
|
try {
|
||||||
const newForm = {...form, email: form.email.toLowerCase()}
|
const res = await networkService.registerUser(form);
|
||||||
const res = await networkService.registerUser(newForm);
|
|
||||||
return res.data;
|
return res.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response.data) {
|
if (error.response.data) {
|
||||||
@@ -29,8 +28,7 @@ export const register = createAsyncThunk("auth/register", async (form, thunkApi)
|
|||||||
|
|
||||||
export const login = createAsyncThunk("auth/login", async (form, thunkApi) => {
|
export const login = createAsyncThunk("auth/login", async (form, thunkApi) => {
|
||||||
try {
|
try {
|
||||||
const newForm = {...form, email: form.email.toLowerCase()}
|
const res = await networkService.loginUser(form);
|
||||||
const res = await networkService.loginUser(newForm);
|
|
||||||
return res.data;
|
return res.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) {
|
if (error.response && error.response.data) {
|
||||||
@@ -100,7 +98,8 @@ export const forgotPassword = createAsyncThunk(
|
|||||||
"auth/forgotPassword",
|
"auth/forgotPassword",
|
||||||
async (form, thunkApi) => {
|
async (form, thunkApi) => {
|
||||||
try {
|
try {
|
||||||
const res = await networkService.forgotPassword(form);
|
const newForm = {...form, email: form.toLowerCase()};
|
||||||
|
const res = await networkService.forgotPassword(newForm);
|
||||||
return res.data;
|
return res.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response.data) {
|
if (error.response.data) {
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ class NetworkService {
|
|||||||
this.axiosInstance.interceptors.request.use(
|
this.axiosInstance.interceptors.request.use(
|
||||||
(config) => {
|
(config) => {
|
||||||
const currentLanguage = i18next.language || "en";
|
const currentLanguage = i18next.language || "en";
|
||||||
|
if (config.data?.email) {
|
||||||
|
config.data.email = config.data.email.toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
const { authToken } = store.getState().auth;
|
const { authToken } = store.getState().auth;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user