blob: 31c8acead0c81129d10707ae08b2201e9871dd6a (
plain) (
blame)
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
|
import { BinaryLike } from 'crypto';
import { hash } from '../helpers/password-helpers';
export default class UserApi {
server: any;
local: any;
constructor(server: any, local: any) {
this.server = server;
this.local = local;
}
login(email: string, password: BinaryLike) {
return this.server.login(email, hash(password));
}
logout() {
return this;
}
signup(data: { password: BinaryLike }) {
Object.assign(data, {
password: hash(data.password),
});
return this.server.signup(data);
}
password(email: string) {
return this.server.retrievePassword(email);
}
invite(data: any) {
return this.server.inviteUser(data);
}
getInfo() {
return this.server.userInfo();
}
updateInfo(data: { oldPassword: string; newPassword: string }) {
const userData = data;
if (userData.oldPassword && userData.newPassword) {
userData.oldPassword = hash(userData.oldPassword);
userData.newPassword = hash(userData.newPassword);
}
return this.server.updateUserInfo(userData);
}
getLegacyServices() {
return this.server.getLegacyServices();
}
delete() {
return this.server.deleteAccount();
}
}
|