ing
This commit is contained in:
parent
2281d5fab7
commit
5394da470a
|
@ -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<string, any>) => {
|
||||
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);
|
||||
}
|
||||
);
|
||||
|
|
|
@ -35,11 +35,15 @@ export class RESTClient {
|
|||
reportProgress?: boolean;
|
||||
withCredentials?: boolean;
|
||||
}): Observable<T> {
|
||||
options.withCredentials = true;
|
||||
// options.withCredentials = true;
|
||||
|
||||
return this._httpClient
|
||||
.request(method, Location.joinWithSlash(this._baseURL, entry), options)
|
||||
.map((response: string) => <T>JSON.parse(response))
|
||||
.request<T>(method, Location.joinWithSlash(this._baseURL, entry), options)
|
||||
.map(
|
||||
(response: T) => {
|
||||
return response;
|
||||
}
|
||||
)
|
||||
.catch((error: HttpErrorResponse) => {
|
||||
const aryMsg = error.error.message.split('|');
|
||||
const resError: RESTError = {
|
||||
|
|
|
@ -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 = {
|
||||
signinId: email,
|
||||
signinPw: password,
|
||||
};
|
||||
|
||||
return this.restClient.request<DomainMember>('post', '/account/signin', {
|
||||
return this.restClient.request<any>('post', '/account/signin', {
|
||||
body: body,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user