71 lines
1.9 KiB
TypeScript
71 lines
1.9 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { Observable } from 'rxjs/Observable';
|
|
|
|
import 'rxjs/add/operator/map';
|
|
|
|
import { RESTService } from '@loafer/ng-rest';
|
|
import { RPCService } from '@loafer/ng-rpc';
|
|
import { DomainMember } from '@overflow/commons-typescript/model/domain';
|
|
|
|
import { Member } from '@overflow/commons-typescript/model/member';
|
|
|
|
@Injectable()
|
|
export class MemberService {
|
|
|
|
public constructor(
|
|
private restService: RESTService,
|
|
private rpcService: RPCService,
|
|
) {
|
|
|
|
}
|
|
|
|
public signin(email: string, password: string): Observable<any> {
|
|
return this.restService.request<any>('post', '/account/signin', {
|
|
body: {
|
|
signinID: email,
|
|
signinPW: password,
|
|
},
|
|
});
|
|
}
|
|
|
|
public signin_cookie(authToken: string): Observable<DomainMember> {
|
|
return this.restService.request<DomainMember>('post', '/account/signin_cookie', {
|
|
body: {
|
|
authToken: authToken,
|
|
},
|
|
});
|
|
}
|
|
|
|
public signup(member: Member, password: string): Observable<Member> {
|
|
return this.restService.request<Member>('post', '/account/signup', {
|
|
body: {
|
|
member: member,
|
|
password: password,
|
|
},
|
|
});
|
|
}
|
|
|
|
public modify(member: Member): Observable<Member> {
|
|
return this.rpcService.call<Member>('MemberService.modify', member, '');
|
|
}
|
|
|
|
public sendEmailResetPassword(email: string): Observable<Member> {
|
|
// return this.rpcService.call<Member>('MemberService.sendEmailForPassword', email);
|
|
return this.restService.request<Member>('post', '/account/send_email_pw', {
|
|
body: {
|
|
signinID: email,
|
|
},
|
|
});
|
|
}
|
|
public resetPassword(token: string, pw: string, confirmPw: string): Observable<Member> {
|
|
// return this.rpcService.call<Member>('MemberService.sendEmailForPassword', email);
|
|
return this.restService.request<Member>('post', '/account/reset_password', {
|
|
body: {
|
|
token: token,
|
|
pw: pw,
|
|
confirmPw: confirmPw,
|
|
},
|
|
});
|
|
}
|
|
}
|