mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-05 22:02:15 +00:00
# Which Problems Are Solved The new breadcrumbs were causing problems with some more advanced Zitadel setups. This pr removes the new breadcrumbs to revert to the old navigation behaviour. # How the Problems Are Solved Most of the changes could be kept but those specific to the navigation where mostly reverted. # Additional Changes Updated some dependencies. # Additional Context - Closes #10863
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { OAuthStorage } from 'angular-oauth2-oidc';
|
|
|
|
const STORAGE_PREFIX = 'zitadel';
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class StorageService implements OAuthStorage {
|
|
private sessionStorage: Storage = window.sessionStorage;
|
|
private localStorage: Storage = window.localStorage;
|
|
|
|
constructor() {}
|
|
|
|
public setItem<TValue = string>(key: string, value: TValue, location: StorageLocation = StorageLocation.session): void {
|
|
this.getStorage(location).setItem(this.getPrefixedKey(key), JSON.stringify(value));
|
|
}
|
|
|
|
public getItem<TResult = string>(key: string, location: StorageLocation = StorageLocation.session): TResult | null {
|
|
const result = this.getStorage(location).getItem(this.getPrefixedKey(key));
|
|
if (result) {
|
|
return JSON.parse(result);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public removeItem(key: string, location: StorageLocation = StorageLocation.session): void {
|
|
this.getStorage(location).removeItem(this.getPrefixedKey(key));
|
|
}
|
|
|
|
public getPrefixedKey(key: string): string {
|
|
return `${STORAGE_PREFIX}:${key}`;
|
|
}
|
|
|
|
private getStorage(location: StorageLocation): Storage {
|
|
return location === StorageLocation.session ? this.sessionStorage : this.localStorage;
|
|
}
|
|
}
|
|
|
|
export class StorageConfig {
|
|
clientId: string = '';
|
|
storage: Storage = window.sessionStorage;
|
|
}
|
|
|
|
export enum StorageKey {
|
|
organization = 'organization',
|
|
organizationId = 'organizationId',
|
|
}
|
|
|
|
export enum StorageLocation {
|
|
session,
|
|
local,
|
|
}
|