diff --git a/src/app/commons/store/signin-init/signin-init.effect.ts b/src/app/commons/store/signin-init/signin-init.effect.ts index 4089535..4f45e82 100644 --- a/src/app/commons/store/signin-init/signin-init.effect.ts +++ b/src/app/commons/store/signin-init/signin-init.effect.ts @@ -37,14 +37,18 @@ export class Effects { @Effect({ dispatch: false }) signinSuccess$ = this.actions$ .ofType(ActionType.SigninSuccess) + .map((action: SigninSuccess) => action.payload) .do( - () => { - let queryString: string; - if (this.cookieService.check('AuthToken')) { - const authToken = this.cookieService.get('AuthToken'); - console.log(`AuthToken: ${authToken}`); - queryString = `AuthToken=${authToken}`; - } + (result: Map) => { + const authToken = result['authToken']; + // console.log(`authToken: ${authToken}`); + + const expires = new Date(); + expires.setDate(expires.getDate() + 1); + this.cookieService.set('authToken', authToken, expires, '/'); + + const queryString = `authToken=${authToken}`; + this.rpcClient.connect(queryString); } ); diff --git a/src/packages/core/rest/client/RESTClient.ts b/src/packages/core/rest/client/RESTClient.ts index 346f117..0d986da 100644 --- a/src/packages/core/rest/client/RESTClient.ts +++ b/src/packages/core/rest/client/RESTClient.ts @@ -35,11 +35,15 @@ export class RESTClient { reportProgress?: boolean; withCredentials?: boolean; }): Observable { - options.withCredentials = true; + // options.withCredentials = true; return this._httpClient - .request(method, Location.joinWithSlash(this._baseURL, entry), options) - .map((response: string) => JSON.parse(response)) + .request(method, Location.joinWithSlash(this._baseURL, entry), options) + .map( + (response: T) => { + return response; + } + ) .catch((error: HttpErrorResponse) => { const aryMsg = error.error.message.split('|'); const resError: RESTError = { diff --git a/src/packages/member/service/member.service.ts b/src/packages/member/service/member.service.ts index f44552d..561b263 100644 --- a/src/packages/member/service/member.service.ts +++ b/src/packages/member/service/member.service.ts @@ -17,13 +17,13 @@ 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.restClient.request('post', '/account/signin', { + return this.restClient.request('post', '/account/signin', { body: body, }); } diff --git a/src/packages/member/store/auth/auth.action.ts b/src/packages/member/store/auth/auth.action.ts index b8dde70..b079b9a 100644 --- a/src/packages/member/store/auth/auth.action.ts +++ b/src/packages/member/store/auth/auth.action.ts @@ -24,7 +24,7 @@ export class Signin implements Action { export class SigninSuccess implements Action { readonly type = ActionType.SigninSuccess; - constructor(public payload: DomainMember) {} + constructor(public payload: any) {} } 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 cfadff0..9989d14 100644 --- a/src/packages/member/store/auth/auth.effect.ts +++ b/src/packages/member/store/auth/auth.effect.ts @@ -47,8 +47,8 @@ export class Effects { this._options = payload.options; return this.memberService.signin(payload.email, payload.password); }) - .map((domainMember: DomainMember) => { - return new SigninSuccess(domainMember); + .map((result: any) => { + return new SigninSuccess(result); }) .catch((error: RESTError) => { 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 318b027..e687516 100644 --- a/src/packages/member/store/auth/auth.reducer.ts +++ b/src/packages/member/store/auth/auth.reducer.ts @@ -10,6 +10,7 @@ import { } from './auth.state'; import { Member } from '../../model'; +import { DomainMember } from '../../../domain/model'; export function reducer(state = initialState, action: Actions): State { switch (action.type) { @@ -22,13 +23,14 @@ export function reducer(state = initialState, action: Actions): State { } case ActionType.SigninSuccess: { + const domainMember = action.payload['domainMember']; return { ...state, signined: true, error: null, pending: false, - member: action.payload.member, - domain: action.payload.domain, + member: domainMember.member, + domain: domainMember.domain, }; }