initialization of logout is modified
This commit is contained in:
parent
44e576fc72
commit
81c3cbe43a
@ -66,6 +66,10 @@ export const logoutConfirmationDismiss = createAction(
|
||||
'[Account::Authentication] Logout Confirmation Dismiss'
|
||||
);
|
||||
|
||||
export const logoutInitialize = createAction(
|
||||
'[Account::Authentication] Logout Initialize'
|
||||
);
|
||||
|
||||
export const postLogin = createAction(
|
||||
'[Account::Authentication] Post Login',
|
||||
props<{
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, Inject } from '@angular/core';
|
||||
import { Injectable, Inject, NgZone } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { of, Observable } from 'rxjs';
|
||||
@ -36,7 +36,8 @@ import {
|
||||
changePasswordFailure,
|
||||
changePasswordSuccess,
|
||||
increaseLoginFailCount,
|
||||
initialLoginFailCount
|
||||
initialLoginFailCount,
|
||||
logoutInitialize
|
||||
} from './actions';
|
||||
import {
|
||||
LoginInfo,
|
||||
@ -52,6 +53,7 @@ import {
|
||||
ServiceProtocolService,
|
||||
UserPasswordSetResponse
|
||||
} from '@ucap-webmessenger/protocol-service';
|
||||
import { AuthenticationProtocolService } from '@ucap-webmessenger/protocol-authentication';
|
||||
|
||||
@Injectable()
|
||||
export class Effects {
|
||||
@ -122,21 +124,33 @@ export class Effects {
|
||||
this.actions$.pipe(
|
||||
ofType(loginRedirect),
|
||||
tap(authed => {
|
||||
this.router.navigate(['/account/login']);
|
||||
this.ngZone.run(() => {
|
||||
this.router.navigate(['/account/login']).then(() => {
|
||||
this.store.dispatch(logoutInitialize());
|
||||
location.reload();
|
||||
});
|
||||
});
|
||||
})
|
||||
),
|
||||
{ dispatch: false }
|
||||
);
|
||||
|
||||
logout$ = createEffect(() =>
|
||||
this.actions$.pipe(
|
||||
ofType(logout),
|
||||
map(action => action),
|
||||
map(() => {
|
||||
this.appAuthenticationService.logout();
|
||||
return loginRedirect();
|
||||
})
|
||||
)
|
||||
logout$ = createEffect(
|
||||
() => {
|
||||
return this.actions$.pipe(
|
||||
ofType(logout),
|
||||
switchMap(action => {
|
||||
return this.authenticationProtocolService.logout({}).pipe(
|
||||
map(res => {
|
||||
this.appAuthenticationService.logout();
|
||||
this.store.dispatch(loginRedirect());
|
||||
}),
|
||||
catchError(error => of(error))
|
||||
);
|
||||
})
|
||||
);
|
||||
},
|
||||
{ dispatch: false }
|
||||
);
|
||||
|
||||
logoutConfirmation$ = createEffect(() =>
|
||||
@ -288,11 +302,13 @@ export class Effects {
|
||||
|
||||
constructor(
|
||||
private actions$: Actions,
|
||||
private ngZone: NgZone,
|
||||
private router: Router,
|
||||
private store: Store<any>,
|
||||
private sessionStorageService: SessionStorageService,
|
||||
private piService: PiService,
|
||||
private appAuthenticationService: AppAuthenticationService,
|
||||
private authenticationProtocolService: AuthenticationProtocolService,
|
||||
private serviceProtocolService: ServiceProtocolService,
|
||||
private dialogService: DialogService,
|
||||
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
|
||||
|
@ -3,7 +3,9 @@ import { State, initialState } from './state';
|
||||
import {
|
||||
loginSuccess,
|
||||
increaseLoginFailCount,
|
||||
initialLoginFailCount
|
||||
initialLoginFailCount,
|
||||
logout,
|
||||
logoutInitialize
|
||||
} from './actions';
|
||||
|
||||
export const reducer = createReducer(
|
||||
@ -21,10 +23,17 @@ export const reducer = createReducer(
|
||||
loginFailCount: state.loginFailCount + 1
|
||||
};
|
||||
}),
|
||||
|
||||
on(initialLoginFailCount, (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
loginFailCount: 0
|
||||
};
|
||||
}),
|
||||
|
||||
on(logoutInitialize, (state, action) => {
|
||||
return {
|
||||
...initialState
|
||||
};
|
||||
})
|
||||
);
|
||||
|
@ -11,6 +11,8 @@ import {
|
||||
clearRightDrawer
|
||||
} from './actions';
|
||||
|
||||
import * as AuthenticationStore from '@app/store/account/authentication';
|
||||
|
||||
export const reducer = createReducer(
|
||||
initialState,
|
||||
on(selectedRoom, (state, action) => {
|
||||
@ -64,5 +66,11 @@ export const reducer = createReducer(
|
||||
...state,
|
||||
selectedRightDrawer: null
|
||||
};
|
||||
}),
|
||||
|
||||
on(AuthenticationStore.logoutInitialize, (state, action) => {
|
||||
return {
|
||||
...initialState
|
||||
};
|
||||
})
|
||||
);
|
||||
|
@ -128,12 +128,13 @@ export const reducer = createReducer(
|
||||
};
|
||||
}),
|
||||
|
||||
on(AuthenticationStore.logout, (state, action) => {
|
||||
on(ChatStore.clearSelectedRoom, (state, action) => {
|
||||
return {
|
||||
...initialState
|
||||
};
|
||||
}),
|
||||
on(ChatStore.clearSelectedRoom, (state, action) => {
|
||||
|
||||
on(AuthenticationStore.logoutInitialize, (state, action) => {
|
||||
return {
|
||||
...initialState
|
||||
};
|
||||
|
@ -17,7 +17,7 @@ export const reducer = createReducer(
|
||||
reg: action.res
|
||||
};
|
||||
}),
|
||||
on(AuthenticationStore.logout, (state, action) => {
|
||||
on(AuthenticationStore.logoutInitialize, (state, action) => {
|
||||
return {
|
||||
...initialState
|
||||
};
|
||||
|
@ -49,7 +49,7 @@ export const reducer = createReducer(
|
||||
};
|
||||
}),
|
||||
|
||||
on(AuthenticationStore.logout, (state, action) => {
|
||||
on(AuthenticationStore.logoutInitialize, (state, action) => {
|
||||
return {
|
||||
...initialState
|
||||
};
|
||||
|
@ -64,12 +64,13 @@ export const reducer = createReducer(
|
||||
};
|
||||
}),
|
||||
|
||||
on(AuthenticationStore.logout, (state, action) => {
|
||||
on(ChatStore.clearSelectedRoom, (state, action) => {
|
||||
return {
|
||||
...initialState
|
||||
};
|
||||
}),
|
||||
on(ChatStore.clearSelectedRoom, (state, action) => {
|
||||
|
||||
on(AuthenticationStore.logoutInitialize, (state, action) => {
|
||||
return {
|
||||
...initialState
|
||||
};
|
||||
|
@ -42,7 +42,7 @@ export const reducer = createReducer(
|
||||
};
|
||||
}),
|
||||
|
||||
on(AuthenticationStore.logout, (state, action) => {
|
||||
on(AuthenticationStore.logoutInitialize, (state, action) => {
|
||||
return {
|
||||
...initialState
|
||||
};
|
||||
|
@ -30,6 +30,8 @@ import * as RoomStore from '@app/store/messenger/room';
|
||||
import { RoomInfo } from '@ucap-webmessenger/protocol-room';
|
||||
import { StringUtil } from '@ucap-webmessenger/ui';
|
||||
|
||||
import * as AuthenticationStore from '@app/store/account/authentication';
|
||||
|
||||
export const reducer = createReducer(
|
||||
initialState,
|
||||
on(buddy2Success, (state, action) => {
|
||||
@ -283,5 +285,11 @@ export const reducer = createReducer(
|
||||
...state,
|
||||
buddy2: adapterBuddy2.upsertOne(userInfo, { ...state.buddy2 })
|
||||
};
|
||||
}),
|
||||
|
||||
on(AuthenticationStore.logoutInitialize, (state, action) => {
|
||||
return {
|
||||
...initialState
|
||||
};
|
||||
})
|
||||
);
|
||||
|
@ -1,4 +1,7 @@
|
||||
import { createReducer, on } from '@ngrx/store';
|
||||
|
||||
import * as AuthenticationStore from '@app/store/account/authentication';
|
||||
|
||||
import { initialState } from './state';
|
||||
import { companyListSuccess } from './actions';
|
||||
|
||||
@ -9,5 +12,11 @@ export const reducer = createReducer(
|
||||
...state,
|
||||
companyList: action.companyList
|
||||
};
|
||||
}),
|
||||
|
||||
on(AuthenticationStore.logoutInitialize, (state, action) => {
|
||||
return {
|
||||
...initialState
|
||||
};
|
||||
})
|
||||
);
|
||||
|
@ -2,6 +2,8 @@ import { createReducer, on } from '@ngrx/store';
|
||||
import { initialState } from './state';
|
||||
import { versionInfo2Success } from './actions';
|
||||
|
||||
import * as AuthenticationStore from '@app/store/account/authentication';
|
||||
|
||||
export const reducer = createReducer(
|
||||
initialState,
|
||||
on(versionInfo2Success, (state, action) => {
|
||||
@ -19,5 +21,11 @@ export const reducer = createReducer(
|
||||
fileDownloadUrl: action.res.downloadUrl,
|
||||
serverIp: action.res.serverIp
|
||||
};
|
||||
}),
|
||||
|
||||
on(AuthenticationStore.logoutInitialize, (state, action) => {
|
||||
return {
|
||||
...initialState
|
||||
};
|
||||
})
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user