Skip to content

Commit 1d005ad

Browse files
committed
fixup! add forgot password in login
1 parent cb11c65 commit 1d005ad

File tree

5 files changed

+166
-207
lines changed

5 files changed

+166
-207
lines changed

src/app/apiFetch/User.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export const changeUserPassword = (body: UserInterfaces.ChangeUserPassword) => {
121121
method: 'POST',
122122
})
123123
.then((response) => {
124-
return headResponseWrapper(response, HeadReqType.USERNAME);
124+
return response;
125125
})
126126
.then((data) => {
127127
return data;

src/app/apiFetch/utils/index.ts

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -30,39 +30,42 @@ export function jsonResponseWrapper(response: any) {
3030
}
3131

3232
export function headResponseWrapper(response: any, headReqType: HeadReqType) {
33-
return new Promise((resolve, reject) => {
34-
let type: string = resType.SUCCESS;
35-
let error: string = '';
36-
switch (response.status) {
37-
case 302:
38-
error =
39-
headReqType === HeadReqType.EMAIL
40-
? 'Email already registered.'
41-
: 'Username already taken.';
42-
type = resType.ERROR;
43-
break;
44-
case 409:
45-
error =
46-
headReqType === HeadReqType.PROFILE
47-
? 'Update not successful. Please try again'
48-
: 'Please try again';
49-
type = resType.ERROR;
50-
break;
51-
case 401:
52-
error =
53-
headReqType === HeadReqType.PASSWORD
54-
? 'Incorrect old password.'
55-
: 'Please try again with correct password';
56-
type = resType.ERROR;
57-
break;
58-
case 500:
59-
case 403:
60-
error = headReqType === HeadReqType.OTHERS ? '' : '';
61-
type = resType.ERROR;
62-
}
63-
resolve({
64-
error,
65-
type,
33+
return response.text().then((data: any) => {
34+
return new Promise((resolve, reject) => {
35+
let type: string = resType.SUCCESS;
36+
let error: string = '';
37+
switch (response.status) {
38+
case 302:
39+
error =
40+
headReqType === HeadReqType.EMAIL
41+
? 'Email already registered.'
42+
: 'Username already taken.';
43+
type = resType.ERROR;
44+
break;
45+
case 409:
46+
error =
47+
headReqType === HeadReqType.PROFILE
48+
? 'Update not successful. Please try again'
49+
: 'Please try again';
50+
type = resType.ERROR;
51+
break;
52+
case 401:
53+
error =
54+
headReqType === HeadReqType.PASSWORD
55+
? 'Incorrect old password.'
56+
: 'Please try again with correct password';
57+
type = resType.ERROR;
58+
break;
59+
case 500:
60+
case 403:
61+
error = headReqType === HeadReqType.OTHERS ? '' : '';
62+
type = resType.ERROR;
63+
}
64+
resolve({
65+
error,
66+
type,
67+
body: data,
68+
});
6669
});
6770
});
6871
}

0 commit comments

Comments
 (0)