-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathauth.service.ts
More file actions
executable file
·53 lines (53 loc) · 1.65 KB
/
auth.service.ts
File metadata and controls
executable file
·53 lines (53 loc) · 1.65 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
import { Http, Headers, URLSearchParams, RequestOptions } from '@angular/http';
import { Injectable } from '@angular/core';
// Others
import { RequestService } from '../shared/request/request.service';
const AUTH_ENDPOINT = 'api/auths.json?action=';
@Injectable()
export class AuthService {
appkey: any = this.request.getAppkey();
prefixUrl: any = this.request.getPrefixUrl();
constructor(
public request: RequestService,
) {}
private postRequest(type, body) {
return this.request.post(AUTH_ENDPOINT + type, body, {
'Content-Type': 'application/x-www-form-urlencoded'
});
}
verifyRegistration(data) {
let email = data.email;
let key = data.key;
return this.postRequest('verify_registration', { email, key });
}
register(data) {
return this.postRequest('registration', {
password: data.password,
user_id: data.user_id,
key: data.key,
});
}
loginAuth(email, password) {
return this.postRequest('authentication', `data[User][email]=${email}&data[User][password]=${password}`);
}
forgotPassword(email) {
return this.postRequest('forgot_password', { email });
}
verifyUserKeyEmail(key, email) {
return this.postRequest('verify_reset_password', { key, email });
}
resetUserPassword(key, email, password, verify_password) {
return this.postRequest('reset_password', { key, email, password, verify_password });
}
magicLinkLogin(auth_token) {
return this.request.post('api/auths.json', { auth_token }, {
'Content-Type': 'application/x-www-form-urlencoded'
});
}
getUser() {
return this.request.get('api/users.json');
}
isAuthenticated() {
return true;
}
}