-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlogin.ts
More file actions
68 lines (56 loc) · 1.49 KB
/
login.ts
File metadata and controls
68 lines (56 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import api from '@/api/instance';
import { ApiErrorResponse } from '@/types/apiTypes';
export interface LoginPayload {
email: string;
password: string;
}
export type LoginResponse = {
accessToken: string;
refreshToken: string;
needToChangePassword: boolean;
};
export interface FowardPwdPayload {
email: string;
phoneNumber: string;
}
export type FowardPwdResponse = {
shelterUserId: number;
needToChangePassword: boolean;
};
export interface PwdChangePayload {
password: string;
}
export interface PwdChangeResponse {
shelterUserId: number;
needToChangePassword: boolean;
}
export const loginShelter = async (data: LoginPayload) => {
const response = await api
.post(`auth/shelter/login`, {
json: data
})
.then(res => res.json<LoginResponse>());
return response;
};
export const isExist = async (value: string, type: string) => {
const response = await api
.get(`auth/shelter/exist?value=${value}&type=${type}`)
.then(res => res.json<Promise<Record<'isExist', boolean>>>());
return response;
};
export const fowardPwdLink = async (data: FowardPwdPayload) => {
const response = await api
.post(`auth/shelter/reset-password`, {
json: data
})
.then(res => res.json<FowardPwdResponse>());
return response;
};
export const pwdChange = async (data: PwdChangePayload) => {
const response = await api
.post(`auth/shelter/change-password`, {
json: data
})
.then(res => res.json<PwdChangeResponse>());
return response;
};