mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-10 03:23:07 +00:00
70373: Stop impersonating button in navbar + clear cookie on logout
This commit is contained in:
@@ -1754,6 +1754,8 @@
|
|||||||
|
|
||||||
"nav.statistics.header": "Statistics",
|
"nav.statistics.header": "Statistics",
|
||||||
|
|
||||||
|
"nav.stop-impersonating": "Stop impersonating EPerson",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"orgunit.listelement.badge": "Organizational Unit",
|
"orgunit.listelement.badge": "Organizational Unit",
|
||||||
|
@@ -402,7 +402,7 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
|
|||||||
* Stop impersonating the EPerson
|
* Stop impersonating the EPerson
|
||||||
*/
|
*/
|
||||||
stopImpersonating() {
|
stopImpersonating() {
|
||||||
this.authService.stopImpersonating();
|
this.authService.stopImpersonatingAndRefresh();
|
||||||
this.isImpersonated = false;
|
this.isImpersonated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -201,6 +201,7 @@ export class AuthEffects {
|
|||||||
.pipe(
|
.pipe(
|
||||||
ofType(AuthActionTypes.LOG_OUT),
|
ofType(AuthActionTypes.LOG_OUT),
|
||||||
switchMap(() => {
|
switchMap(() => {
|
||||||
|
this.authService.stopImpersonating();
|
||||||
return this.authService.logout().pipe(
|
return this.authService.logout().pipe(
|
||||||
map((value) => new LogOutSuccessAction()),
|
map((value) => new LogOutSuccessAction()),
|
||||||
catchError((error) => observableOf(new LogOutErrorAction(error)))
|
catchError((error) => observableOf(new LogOutErrorAction(error)))
|
||||||
|
@@ -513,6 +513,13 @@ export class AuthService {
|
|||||||
*/
|
*/
|
||||||
stopImpersonating() {
|
stopImpersonating() {
|
||||||
this.storage.remove(IMPERSONATING_COOKIE);
|
this.storage.remove(IMPERSONATING_COOKIE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop impersonating EPerson and refresh the store/ui
|
||||||
|
*/
|
||||||
|
stopImpersonatingAndRefresh() {
|
||||||
|
this.stopImpersonating();
|
||||||
this.refreshAfterLogout();
|
this.refreshAfterLogout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
<ds-search-navbar></ds-search-navbar>
|
<ds-search-navbar></ds-search-navbar>
|
||||||
<ds-lang-switch></ds-lang-switch>
|
<ds-lang-switch></ds-lang-switch>
|
||||||
<ds-auth-nav-menu></ds-auth-nav-menu>
|
<ds-auth-nav-menu></ds-auth-nav-menu>
|
||||||
|
<ds-impersonate-navbar></ds-impersonate-navbar>
|
||||||
<div class="pl-2">
|
<div class="pl-2">
|
||||||
<button class="navbar-toggler" type="button" (click)="toggleNavbar()"
|
<button class="navbar-toggler" type="button" (click)="toggleNavbar()"
|
||||||
aria-controls="collapsingNav"
|
aria-controls="collapsingNav"
|
||||||
|
@@ -0,0 +1,7 @@
|
|||||||
|
<ul class="navbar-nav" *ngIf="(isAuthenticated$ | async) && isImpersonating">
|
||||||
|
<li class="nav-item">
|
||||||
|
<button class="btn btn-sm btn-dark" ngbTooltip="{{'nav.stop-impersonating' | translate}}" (click)="stopImpersonating()">
|
||||||
|
<i class="fa fa-user-secret"></i>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
@@ -0,0 +1,42 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { select, Store } from '@ngrx/store';
|
||||||
|
import { AppState } from '../../app.reducer';
|
||||||
|
import { AuthService } from '../../core/auth/auth.service';
|
||||||
|
import { Observable } from 'rxjs/internal/Observable';
|
||||||
|
import { isAuthenticated } from '../../core/auth/selectors';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-impersonate-navbar',
|
||||||
|
templateUrl: 'impersonate-navbar.component.html'
|
||||||
|
})
|
||||||
|
/**
|
||||||
|
* Navbar component for actions to take concerning impersonating users
|
||||||
|
*/
|
||||||
|
export class ImpersonateNavbarComponent implements OnInit {
|
||||||
|
/**
|
||||||
|
* Whether or not the user is authenticated.
|
||||||
|
* @type {Observable<string>}
|
||||||
|
*/
|
||||||
|
isAuthenticated$: Observable<boolean>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the user currently impersonating another user?
|
||||||
|
*/
|
||||||
|
isImpersonating: boolean;
|
||||||
|
|
||||||
|
constructor(private store: Store<AppState>,
|
||||||
|
private authService: AuthService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.isAuthenticated$ = this.store.pipe(select(isAuthenticated));
|
||||||
|
this.isImpersonating = this.authService.isImpersonating();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop impersonating the user
|
||||||
|
*/
|
||||||
|
stopImpersonating() {
|
||||||
|
this.authService.stopImpersonatingAndRefresh();
|
||||||
|
}
|
||||||
|
}
|
@@ -191,6 +191,7 @@ import { ItemVersionsNoticeComponent } from './item/item-versions/notice/item-ve
|
|||||||
import { ClaimedTaskActionsLoaderComponent } from './mydspace-actions/claimed-task/switcher/claimed-task-actions-loader.component';
|
import { ClaimedTaskActionsLoaderComponent } from './mydspace-actions/claimed-task/switcher/claimed-task-actions-loader.component';
|
||||||
import { ClaimedTaskActionsDirective } from './mydspace-actions/claimed-task/switcher/claimed-task-actions.directive';
|
import { ClaimedTaskActionsDirective } from './mydspace-actions/claimed-task/switcher/claimed-task-actions.directive';
|
||||||
import { ClaimedTaskActionsEditMetadataComponent } from './mydspace-actions/claimed-task/edit-metadata/claimed-task-actions-edit-metadata.component';
|
import { ClaimedTaskActionsEditMetadataComponent } from './mydspace-actions/claimed-task/edit-metadata/claimed-task-actions-edit-metadata.component';
|
||||||
|
import { ImpersonateNavbarComponent } from './impersonate-navbar/impersonate-navbar.component';
|
||||||
|
|
||||||
const MODULES = [
|
const MODULES = [
|
||||||
// Do NOT include UniversalModule, HttpModule, or JsonpModule here
|
// Do NOT include UniversalModule, HttpModule, or JsonpModule here
|
||||||
@@ -367,7 +368,8 @@ const COMPONENTS = [
|
|||||||
LogInContainerComponent,
|
LogInContainerComponent,
|
||||||
ItemVersionsComponent,
|
ItemVersionsComponent,
|
||||||
PublicationSearchResultListElementComponent,
|
PublicationSearchResultListElementComponent,
|
||||||
ItemVersionsNoticeComponent
|
ItemVersionsNoticeComponent,
|
||||||
|
ImpersonateNavbarComponent
|
||||||
];
|
];
|
||||||
|
|
||||||
const ENTRY_COMPONENTS = [
|
const ENTRY_COMPONENTS = [
|
||||||
|
Reference in New Issue
Block a user