forked from softboy99/fles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth.ts
More file actions
97 lines (86 loc) · 1.6 KB
/
auth.ts
File metadata and controls
97 lines (86 loc) · 1.6 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import {User} from './model/User';
import {api} from './api/APIService';
let _user: User | null = null;
export default {
_user,
loggedIn() {
return !!_user;
},
async logIn(userName:string, password:string) {
return api.login({userName,password})
.then(response=>{
_user = response.data;
return {
isOk: true,
data: _user
};
}).catch(reason=>{
return {
isOk: false,
message: "Authentication failed"
};
})
},
async logOut() {
this._user = null;
},
async getUser() {
try {
// Send request
return {
isOk: true,
data: this._user
};
}
catch {
return {
isOk: false
};
}
},
async resetPassword(email:string) {
try {
// Send request
console.log(email);
return {
isOk: true
};
}
catch {
return {
isOk: false,
message: "Failed to reset password"
};
}
},
async changePassword(email:string, recoveryCode:string) {
try {
// Send request
console.log(email, recoveryCode);
return {
isOk: true
};
}
catch {
return {
isOk: false,
message: "Failed to change password"
}
}
},
async createAccount(email:string, password:string) {
try {
// Send request
console.log(email, password);
return {
isOk: true
};
}
catch {
return {
isOk: false,
message: "Failed to create account"
};
}
}
};