ing
This commit is contained in:
@@ -3,16 +3,16 @@ import { Action } from '@ngrx/store';
|
||||
import { RESTClientError } from '@loafer/ng-rest';
|
||||
|
||||
import { DomainMember } from '@overflow/commons-typescript/model/domain';
|
||||
import { Member } from '@overflow/commons-typescript/model/member';
|
||||
|
||||
export enum ActionType {
|
||||
SigninSuccess = '[auth.auth] SigninSuccess',
|
||||
SigninFailure = '[auth.auth] SigninFailure',
|
||||
|
||||
SigninCookieSuccess = '[auth.auth] SigninCookieSuccess',
|
||||
SigninCookieFailure = '[auth.auth] SigninCookieFailure',
|
||||
|
||||
SignoutSuccess = '[auth.auth] SignoutSuccess',
|
||||
SignoutFailure = '[auth.auth] SignoutFailure',
|
||||
|
||||
ModifySuccess = '[auth.auth] ModifySuccess',
|
||||
}
|
||||
|
||||
export class SigninSuccess implements Action {
|
||||
@@ -21,39 +21,26 @@ export class SigninSuccess implements Action {
|
||||
constructor(public payload: {authToken: string, domainMember: DomainMember, returnURL: string}) {}
|
||||
}
|
||||
|
||||
export class SigninFailure implements Action {
|
||||
readonly type = ActionType.SigninFailure;
|
||||
|
||||
constructor(public payload: RESTClientError) {}
|
||||
}
|
||||
|
||||
export class SigninCookieSuccess implements Action {
|
||||
readonly type = ActionType.SigninCookieSuccess;
|
||||
|
||||
constructor(public payload: {domainMember: DomainMember, returnURL: string}) {}
|
||||
}
|
||||
|
||||
export class SigninCookieFailure implements Action {
|
||||
readonly type = ActionType.SigninCookieFailure;
|
||||
|
||||
constructor(public payload: RESTClientError) {}
|
||||
}
|
||||
|
||||
export class SignoutSuccess implements Action {
|
||||
readonly type = ActionType.SignoutSuccess;
|
||||
}
|
||||
|
||||
export class SignoutFailure implements Action {
|
||||
readonly type = ActionType.SignoutFailure;
|
||||
export class ModifySuccess implements Action {
|
||||
readonly type = ActionType.ModifySuccess;
|
||||
|
||||
constructor(public payload: RESTClientError) {}
|
||||
constructor(public payload: Member) {}
|
||||
}
|
||||
|
||||
|
||||
export type Actions =
|
||||
| SigninSuccess
|
||||
| SigninFailure
|
||||
| SigninCookieSuccess
|
||||
| SigninCookieFailure
|
||||
| SignoutSuccess
|
||||
| SignoutFailure
|
||||
| ModifySuccess
|
||||
;
|
||||
@@ -17,13 +17,6 @@ export function reducer(state: State = initialState, action: Actions): State {
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.SigninFailure: {
|
||||
return {
|
||||
signined: false,
|
||||
domainMember: null,
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.SigninCookieSuccess: {
|
||||
return {
|
||||
signined: true,
|
||||
@@ -31,13 +24,6 @@ export function reducer(state: State = initialState, action: Actions): State {
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.SigninCookieFailure: {
|
||||
return {
|
||||
signined: false,
|
||||
domainMember: null,
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.SignoutSuccess: {
|
||||
return {
|
||||
signined: false,
|
||||
@@ -45,7 +31,8 @@ export function reducer(state: State = initialState, action: Actions): State {
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.SignoutFailure: {
|
||||
case ActionType.ModifySuccess: {
|
||||
state.domainMember.member = action.payload;
|
||||
return {
|
||||
...state,
|
||||
};
|
||||
@@ -5,14 +5,14 @@ import {
|
||||
|
||||
import { MODULE } from '../auth.constant';
|
||||
|
||||
import * as AuthContainerStore from './container/auth';
|
||||
import * as AuthStore from './auth';
|
||||
|
||||
export interface State {
|
||||
auth_container: AuthContainerStore.State;
|
||||
auth_container: AuthStore.State;
|
||||
}
|
||||
|
||||
export const REDUCERS = {
|
||||
auth_container: AuthContainerStore.reducer,
|
||||
auth_container: AuthStore.reducer,
|
||||
};
|
||||
|
||||
export const EFFECTS = [
|
||||
@@ -20,7 +20,7 @@ export const EFFECTS = [
|
||||
|
||||
export const selectState = createFeatureSelector<State>(MODULE.name);
|
||||
|
||||
export const AuthContainerSelector = AuthContainerStore.getSelectors(createSelector(
|
||||
export const AuthSelector = AuthStore.getSelectors(createSelector(
|
||||
selectState,
|
||||
(state: State) => state.auth_container
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user