This commit is contained in:
crusader 2018-03-13 15:48:06 +09:00
parent 2281d5fab7
commit 5394da470a
6 changed files with 27 additions and 17 deletions

View File

@ -37,14 +37,18 @@ export class Effects {
@Effect({ dispatch: false }) @Effect({ dispatch: false })
signinSuccess$ = this.actions$ signinSuccess$ = this.actions$
.ofType(ActionType.SigninSuccess) .ofType(ActionType.SigninSuccess)
.map((action: SigninSuccess) => action.payload)
.do( .do(
() => { (result: Map<string, any>) => {
let queryString: string; const authToken = result['authToken'];
if (this.cookieService.check('AuthToken')) { // console.log(`authToken: ${authToken}`);
const authToken = this.cookieService.get('AuthToken');
console.log(`AuthToken: ${authToken}`); const expires = new Date();
queryString = `AuthToken=${authToken}`; expires.setDate(expires.getDate() + 1);
} this.cookieService.set('authToken', authToken, expires, '/');
const queryString = `authToken=${authToken}`;
this.rpcClient.connect(queryString); this.rpcClient.connect(queryString);
} }
); );

View File

@ -35,11 +35,15 @@ export class RESTClient {
reportProgress?: boolean; reportProgress?: boolean;
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<T> { }): Observable<T> {
options.withCredentials = true; // options.withCredentials = true;
return this._httpClient return this._httpClient
.request(method, Location.joinWithSlash(this._baseURL, entry), options) .request<T>(method, Location.joinWithSlash(this._baseURL, entry), options)
.map((response: string) => <T>JSON.parse(response)) .map(
(response: T) => {
return response;
}
)
.catch((error: HttpErrorResponse) => { .catch((error: HttpErrorResponse) => {
const aryMsg = error.error.message.split('|'); const aryMsg = error.error.message.split('|');
const resError: RESTError = { const resError: RESTError = {

View File

@ -17,13 +17,13 @@ export class MemberService {
} }
public signin(email: string, password: string): Observable<DomainMember> { public signin(email: string, password: string): Observable<any> {
const body = { const body = {
signinId: email, signinId: email,
signinPw: password, signinPw: password,
}; };
return this.restClient.request<DomainMember>('post', '/account/signin', { return this.restClient.request<any>('post', '/account/signin', {
body: body, body: body,
}); });
} }

View File

@ -24,7 +24,7 @@ export class Signin implements Action {
export class SigninSuccess implements Action { export class SigninSuccess implements Action {
readonly type = ActionType.SigninSuccess; readonly type = ActionType.SigninSuccess;
constructor(public payload: DomainMember) {} constructor(public payload: any) {}
} }
export class SigninFailure implements Action { export class SigninFailure implements Action {

View File

@ -47,8 +47,8 @@ export class Effects {
this._options = payload.options; this._options = payload.options;
return this.memberService.signin(payload.email, payload.password); return this.memberService.signin(payload.email, payload.password);
}) })
.map((domainMember: DomainMember) => { .map((result: any) => {
return new SigninSuccess(domainMember); return new SigninSuccess(result);
}) })
.catch((error: RESTError) => { .catch((error: RESTError) => {
return of(new SigninFailure(error)); return of(new SigninFailure(error));

View File

@ -10,6 +10,7 @@ import {
} from './auth.state'; } from './auth.state';
import { Member } from '../../model'; import { Member } from '../../model';
import { DomainMember } from '../../../domain/model';
export function reducer(state = initialState, action: Actions): State { export function reducer(state = initialState, action: Actions): State {
switch (action.type) { switch (action.type) {
@ -22,13 +23,14 @@ export function reducer(state = initialState, action: Actions): State {
} }
case ActionType.SigninSuccess: { case ActionType.SigninSuccess: {
const domainMember = action.payload['domainMember'];
return { return {
...state, ...state,
signined: true, signined: true,
error: null, error: null,
pending: false, pending: false,
member: action.payload.member, member: domainMember.member,
domain: action.payload.domain, domain: domainMember.domain,
}; };
} }