Fix history mode store access

prevents local storage access from certain services
when in history mode
This commit is contained in:
Sean Engelhardt 2019-03-25 15:03:26 +01:00
parent 279b8b1d25
commit 4e975af915
3 changed files with 17 additions and 5 deletions

View File

@ -7,6 +7,7 @@ import { User } from '../../shared/models/users/user';
import { environment } from 'environments/environment'; import { environment } from 'environments/environment';
import { DataStoreService } from './data-store.service'; import { DataStoreService } from './data-store.service';
import { OfflineService } from './offline.service'; import { OfflineService } from './offline.service';
import { OpenSlidesStatusService } from './openslides-status.service';
import { ViewUser } from 'app/site/users/models/view-user'; import { ViewUser } from 'app/site/users/models/view-user';
import { OnAfterAppsLoaded } from '../onAfterAppsLoaded'; import { OnAfterAppsLoaded } from '../onAfterAppsLoaded';
import { UserRepositoryService } from '../repositories/users/user-repository.service'; import { UserRepositoryService } from '../repositories/users/user-repository.service';
@ -128,7 +129,8 @@ export class OperatorService implements OnAfterAppsLoaded {
private DS: DataStoreService, private DS: DataStoreService,
private offlineService: OfflineService, private offlineService: OfflineService,
private collectionStringMapper: CollectionStringMapperService, private collectionStringMapper: CollectionStringMapperService,
private storageService: StorageService private storageService: StorageService,
private OSStatus: OpenSlidesStatusService
) { ) {
this.DS.changeObservable.subscribe(newModel => { this.DS.changeObservable.subscribe(newModel => {
if (this._user && newModel instanceof User && this._user.id === newModel.id) { if (this._user && newModel instanceof User && this._user.id === newModel.id) {
@ -344,7 +346,10 @@ export class OperatorService implements OnAfterAppsLoaded {
this.currentWhoAmI = this.getDefaultWhoAmIResponse(); this.currentWhoAmI = this.getDefaultWhoAmIResponse();
} }
this.currentWhoAmI.permissions = this.permissions; this.currentWhoAmI.permissions = this.permissions;
await this.storageService.set(WHOAMI_STORAGE_KEY, this.currentWhoAmI);
if (!this.OSStatus.isInHistoryMode) {
await this.storageService.set(WHOAMI_STORAGE_KEY, this.currentWhoAmI);
}
// publish changes in the operator. // publish changes in the operator.
this.operatorSubject.next(this.user); this.operatorSubject.next(this.user);

View File

@ -82,9 +82,9 @@ export class TimeTravelService {
* all missed auto updates are requested. * all missed auto updates are requested.
*/ */
public async resumeTime(): Promise<void> { public async resumeTime(): Promise<void> {
this.OSStatus.leaveHistoryMode();
await this.DS.set(); await this.DS.set();
await this.OpenSlides.reboot(); await this.OpenSlides.reboot();
this.OSStatus.leaveHistoryMode();
} }
/** /**

View File

@ -4,6 +4,7 @@ import { BehaviorSubject, Observable } from 'rxjs';
import { ConfigService } from './config.service'; import { ConfigService } from './config.service';
import { StorageService } from '../core-services/storage.service'; import { StorageService } from '../core-services/storage.service';
import { OpenSlidesStatusService } from '../core-services/openslides-status.service';
/** /**
* The login data send by the server. * The login data send by the server.
@ -65,7 +66,11 @@ export class LoginDataService {
* policy and legal notice, when their config values change. * policy and legal notice, when their config values change.
* @param configService * @param configService
*/ */
public constructor(private configService: ConfigService, private storageService: StorageService) { public constructor(
private configService: ConfigService,
private storageService: StorageService,
private OSStatus: OpenSlidesStatusService
) {
this.configService.get<string>('general_event_privacy_policy').subscribe(value => { this.configService.get<string>('general_event_privacy_policy').subscribe(value => {
this._privacy_policy.next(value); this._privacy_policy.next(value);
this.storeLoginData(); this.storeLoginData();
@ -118,6 +123,8 @@ export class LoginDataService {
theme: this._theme.getValue() theme: this._theme.getValue()
}; };
} }
this.storageService.set(LOGIN_DATA_STORAGE_KEY, loginData); if (!this.OSStatus.isInHistoryMode) {
this.storageService.set(LOGIN_DATA_STORAGE_KEY, loginData);
}
} }
} }