diff --git a/src/packages/commons/service/rest.service.ts b/src/packages/commons/service/rest.service.ts index 031c8a2..251d54b 100644 --- a/src/packages/commons/service/rest.service.ts +++ b/src/packages/commons/service/rest.service.ts @@ -6,6 +6,8 @@ import { Observable } from 'rxjs/Observable'; import { Location } from '@angular/common'; import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/catch'; import 'rxjs/add/operator/timeout'; import 'rxjs/add/observable/throw'; @@ -20,7 +22,6 @@ export class RESTService { @Inject(HttpClient) private _httpClient: HttpClient, ) { this.httpHeaders = new HttpHeaders() - .set('Accept', 'application/json') .set('Content-Type', 'application/json'); } @@ -32,12 +33,12 @@ export class RESTService { const headers: HttpHeaders = this.httpHeaders; return this._httpClient - .get(Location.joinWithSlash(this._baseURL, entry), { + .get(Location.joinWithSlash(this._baseURL, entry), { headers: headers, params: params, responseType: 'json', }) - .map(response => response) + .map((response: string) => JSON.parse(response)) .catch((error: HttpErrorResponse) => Observable.throw(ErrorResponse.restError(error))); } @@ -45,12 +46,12 @@ export class RESTService { const headers: HttpHeaders = this.httpHeaders; return this._httpClient - .post(Location.joinWithSlash(this._baseURL, entry), body, { + .post(Location.joinWithSlash(this._baseURL, entry), body, { headers: headers, params: params, responseType: 'json', }) - .map(response => response) + .map((response: string) => JSON.parse(response)) .catch((error: HttpErrorResponse) => Observable.throw(ErrorResponse.restError(error))); } diff --git a/src/packages/member/service/member.service.ts b/src/packages/member/service/member.service.ts index 91dc191..c2f38af 100644 --- a/src/packages/member/service/member.service.ts +++ b/src/packages/member/service/member.service.ts @@ -4,6 +4,7 @@ import { Observable } from 'rxjs/Observable'; import 'rxjs/add/operator/map'; import { RESTService } from 'packages/commons/service/rest.service'; +import { DomainMember } from 'packages/domain/model'; import { Member } from '../model'; @@ -16,16 +17,16 @@ export class MemberService { } - public signin(email: string, password: string): Observable { + public signin(email: string, password: string): Observable { const body = { signinId: email, signinPw: password, }; - return this.restService.post('/account/signin', body); + return this.restService.post('/account/signin', body); } public signup(member: Member): Observable { - return this.restService.post('/account/signup', member); + return this.restService.post('/account/signup', member); } } diff --git a/src/packages/member/store/auth/auth.action.ts b/src/packages/member/store/auth/auth.action.ts index e0e0305..8e5d61e 100644 --- a/src/packages/member/store/auth/auth.action.ts +++ b/src/packages/member/store/auth/auth.action.ts @@ -2,6 +2,7 @@ import { Action } from '@ngrx/store'; import { ErrorResponse } from 'packages/commons/service/error-response'; +import { DomainMember } from 'packages/domain/model'; import { Member } from '../../model'; export enum ActionType { @@ -23,7 +24,7 @@ export class Signin implements Action { export class SigninSuccess implements Action { readonly type = ActionType.SigninSuccess; - constructor(public payload: Member) {} + constructor(public payload: DomainMember) {} } export class SigninFailure implements Action { diff --git a/src/packages/member/store/auth/auth.effect.ts b/src/packages/member/store/auth/auth.effect.ts index 0b159ed..e7063ac 100644 --- a/src/packages/member/store/auth/auth.effect.ts +++ b/src/packages/member/store/auth/auth.effect.ts @@ -16,6 +16,8 @@ import 'rxjs/add/operator/take'; import { ErrorResponse } from 'packages/commons/service/error-response'; +import { DomainMember } from 'packages/domain/model'; + import { Member } from '../../model'; import { MemberService } from '../../service/member.service'; @@ -40,8 +42,8 @@ export class Effects { .ofType(ActionType.Signin) .map((action: Signin) => action.payload) .switchMap(payload => this.memberService.signin(payload.email, payload.password)) - .map(member => { - return new SigninSuccess(member); + .map((domainMember: DomainMember) => { + return new SigninSuccess(domainMember); }) .catch((error: ErrorResponse) => { return of(new SigninFailure(error)); diff --git a/src/packages/member/store/auth/auth.reducer.ts b/src/packages/member/store/auth/auth.reducer.ts index 482944f..89b48df 100644 --- a/src/packages/member/store/auth/auth.reducer.ts +++ b/src/packages/member/store/auth/auth.reducer.ts @@ -29,7 +29,8 @@ export function reducer(state = initialState, action: Actions): State { isSignin: true, error: null, isPending: false, - member: action.payload, + member: action.payload.member, + domain: action.payload.domain, }; } @@ -40,6 +41,7 @@ export function reducer(state = initialState, action: Actions): State { error: action.payload, isPending: false, member: null, + domain: null, }; } @@ -58,6 +60,7 @@ export function reducer(state = initialState, action: Actions): State { error: null, isPending: false, member: null, + domain: null, }; }