Refactored logout
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Willem Dantuma
2020-06-25 18:52:13 +02:00
parent f89209c555
commit fe2650c4fd
6 changed files with 30 additions and 10 deletions

View File

@@ -18,6 +18,7 @@ export const INITROOTSUCCESS = '[Explorer] InitRootSuccess';
export const OPENMODAL = '[AppCommon] OpenModal';
export const CLOSEMODAL = '[AppCommon] CloseModal';
export const LOGIN = '[AppCommon] Login';
export const LOGOUT = '[AppCommon] Logout';
export const ESCAPE = '[AppCommon] Escape';
export const LOADITEMTYPES = '[AppCommon] LoadItemTypes';
@@ -116,6 +117,12 @@ export class Login implements Action {
constructor(public url: string) { }
}
export class Logout implements Action {
readonly type = LOGOUT;
constructor() { }
}
export class Escape implements Action {
readonly type = ESCAPE;
@@ -247,6 +254,7 @@ export type Actions = OpenModal
| InitRootSuccess
| CloseModal
| Login
| Logout
| ItemChangedEvent
| ItemAddedEvent
| ItemDeletedEvent
@@ -273,3 +281,4 @@ export type Actions = OpenModal
| InitUserPackagesSuccess
| ToggleAccountMenu;

View File

@@ -26,7 +26,7 @@ export class UserMenuComponent implements OnInit {
logout(event:MouseEvent) {
event.preventDefault();
this.oauthService.logOut();
this.store.dispatch(new appActions.Logout());
}

View File

@@ -25,10 +25,18 @@ export class AppCommonEffects {
withLatestFrom(this.store$.select(appCommonReducers.selectGetInitialized)),
mergeMap(([action, initialized]) => {
var a = (action as appCommonActions.Login);
this.oauthService$.initCodeFlow(a.url);
this.oauthService$.initCodeFlow(a.url,{"prompt":"login"});
return [];
}));
@Effect({ dispatch: false })
logout$: Observable<Action> = this.actions$.pipe(
ofType(appCommonActions.LOGOUT),
mergeMap((action) => {
this.oauthService$.logOut(true);
return [];
}));
@Effect()
loadItemTypes$: Observable<Action> = this.actions$.pipe(
ofType(appCommonActions.LOADITEMTYPES),

View File

@@ -106,6 +106,9 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
return tassign(state,{userPackages:packages});
}
case appCommonActions.LOGOUT:{
return tassign(state,{user:null});
}
default: {
return state;
}