fix(console): add missing login interface texts, update dependencies, cleanup storage (#2430)

* name

* core cli

* material cdk

* chore(deps): bump libphonenumber-js from 1.9.23 to 1.9.34 in /console (#2386)

Bumps [libphonenumber-js](https://gitlab.com/catamphetamine/libphonenumber-js) from 1.9.23 to 1.9.34.
- [Release notes](https://gitlab.com/catamphetamine/libphonenumber-js/tags)
- [Changelog](https://gitlab.com/catamphetamine/libphonenumber-js/blob/master/CHANGELOG.md)
- [Commits](https://gitlab.com/catamphetamine/libphonenumber-js/compare/v1.9.23...v1.9.34)

---
updated-dependencies:
- dependency-name: libphonenumber-js
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump jasmine-core from 3.7.1 to 3.9.0 in /console (#2373)

Bumps [jasmine-core](https://github.com/jasmine/jasmine) from 3.7.1 to 3.9.0.
- [Release notes](https://github.com/jasmine/jasmine/releases)
- [Changelog](https://github.com/jasmine/jasmine/blob/main/RELEASE.md)
- [Commits](https://github.com/jasmine/jasmine/compare/v3.7.1...v3.9.0)

---
updated-dependencies:
- dependency-name: jasmine-core
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump rxjs from 6.6.7 to 7.3.0 in /console (#2366)

Bumps [rxjs](https://github.com/reactivex/rxjs) from 6.6.7 to 7.3.0.
- [Release notes](https://github.com/reactivex/rxjs/releases)
- [Changelog](https://github.com/ReactiveX/rxjs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/reactivex/rxjs/compare/6.6.7...7.3.0)

---
updated-dependencies:
- dependency-name: rxjs
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* add missing login texts, fix application table

* storage cleanup

* storage location local

* org session storage, remember in local

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
Max Peintner
2021-09-30 06:33:58 +00:00
committed by GitHub
co-authored by dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
parent 440030b20b
commit 7579bf56f6
19 changed files with 762 additions and 547 deletions
@@ -187,6 +187,7 @@ export class GrpcAuthService {
}
public setActiveOrg(org: Org.AsObject): void {
// Set organization in localstorage to get the last used organization in a new tab
this.storage.setItem(StorageKey.organization, org, StorageLocation.local);
this.storage.setItem(StorageKey.organization, org, StorageLocation.session);
this._activeOrgChanged.next(org);
@@ -3,10 +3,9 @@ import { OAuthModuleConfig } from 'angular-oauth2-oidc';
import { Observable } from 'rxjs';
import { Org } from '../../proto/generated/zitadel/org_pb';
import { StorageService } from '../storage.service';
import { StorageKey, StorageLocation, StorageService } from '../storage.service';
const orgKey = 'x-zitadel-orgid';
const ORG_STORAGE_KEY = 'organization';
export abstract class HttpOrgInterceptor implements HttpInterceptor {
private org!: Org.AsObject;
@@ -18,7 +17,7 @@ export abstract class HttpOrgInterceptor implements HttpInterceptor {
private storageService: StorageService,
protected oauthModuleConfig: OAuthModuleConfig,
) {
const org: Org.AsObject | null = (this.storageService.getItem(ORG_STORAGE_KEY));
const org: Org.AsObject | null = (this.storageService.getItem(StorageKey.organization, StorageLocation.session));
if (org) {
this.org = org;
@@ -2,31 +2,30 @@ import { Injectable } from '@angular/core';
import { Request, UnaryInterceptor, UnaryResponse } from 'grpc-web';
import { Org } from 'src/app/proto/generated/zitadel/org_pb';
import { StorageService } from '../storage.service';
import { StorageKey, StorageLocation, StorageService } from '../storage.service';
const ORG_HEADER_KEY = 'x-zitadel-orgid';
const ORG_STORAGE_KEY = 'organization';
@Injectable({ providedIn: 'root' })
export class OrgInterceptor<TReq = unknown, TResp = unknown> implements UnaryInterceptor<TReq, TResp> {
constructor(private readonly storageService: StorageService) { }
constructor(private readonly storageService: StorageService) { }
public intercept(request: Request<TReq, TResp>, invoker: any): Promise<UnaryResponse<TReq, TResp>> {
const metadata = request.getMetadata();
public intercept(request: Request<TReq, TResp>, invoker: any): Promise<UnaryResponse<TReq, TResp>> {
const metadata = request.getMetadata();
const org: Org.AsObject | null = (this.storageService.getItem(ORG_STORAGE_KEY));
const org: Org.AsObject | null = (this.storageService.getItem(StorageKey.organization, StorageLocation.session));
if (org) {
metadata[ORG_HEADER_KEY] = `${org.id}`;
}
return invoker(request).then((response: any) => {
return response;
}).catch((error: any) => {
if (error.code === 7 && error.message.startsWith('Organisation doesn\'t exist')) {
this.storageService.removeItem(ORG_STORAGE_KEY);
}
return Promise.reject(error);
});
if (org) {
metadata[ORG_HEADER_KEY] = `${org.id}`;
}
return invoker(request).then((response: any) => {
return response;
}).catch((error: any) => {
if (error.code === 7 && error.message.startsWith('Organisation doesn\'t exist')) {
this.storageService.removeItem(StorageKey.organization, StorageLocation.session);
}
return Promise.reject(error);
});
}
}
+28 -28
View File
@@ -4,48 +4,48 @@ import { OAuthStorage } from 'angular-oauth2-oidc';
const STORAGE_PREFIX = 'zitadel';
@Injectable({
providedIn: 'root',
providedIn: 'root',
})
export class StorageService implements OAuthStorage {
private sessionStorage: Storage = window.sessionStorage;
private localStorage: Storage = window.localStorage;
private sessionStorage: Storage = window.sessionStorage;
private localStorage: Storage = window.localStorage;
constructor() { }
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 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 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 removeItem(key: string, location: StorageLocation = StorageLocation.session): void {
this.getStorage(location).removeItem(this.getPrefixedKey(key));
}
public getPrefixedKey(key: string): string {
return `${STORAGE_PREFIX}:${key}`;
}
public getPrefixedKey(key: string): string {
return `${STORAGE_PREFIX}:${key}`;
}
private getStorage(location: StorageLocation): Storage {
return location === StorageLocation.session
? this.sessionStorage
: this.localStorage;
}
private getStorage(location: StorageLocation): Storage {
return location === StorageLocation.session
? this.sessionStorage
: this.localStorage;
}
}
export class StorageConfig {
clientId: string = '';
storage: Storage = window.sessionStorage;
clientId: string = '';
storage: Storage = window.sessionStorage;
}
export enum StorageKey {
organization = 'organization',
organization = 'organization',
}
export enum StorageLocation {