mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-05 22:02:15 +00:00
fix(console): text color shades, ui fixes, state handle restore (#3698)
* common project grant dialog, info box, label policy * text styles, statehandler fix * dialog, btn alignment, i18n * search-user theme colors * filter formfield sizing * redirect uris * shortcut layout * settings grid type rest, shortcuts linking * login policy, reset button consistency, metadata * permission checks
This commit is contained in:
@@ -1,37 +1,36 @@
|
||||
import { Location } from '@angular/common';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { Router } from '@angular/router';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
export abstract class StatehandlerProcessorService {
|
||||
public abstract createState(url: string): Observable<string | undefined>;
|
||||
public abstract createState(url: string): string;
|
||||
public abstract restoreState(state?: string): void;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class StatehandlerProcessorServiceImpl implements StatehandlerProcessorService {
|
||||
constructor(private location: Location) {}
|
||||
constructor(private location: Location, private router: Router) {}
|
||||
|
||||
public createState(url: string): Observable<string> {
|
||||
public createState(url: string): string {
|
||||
const externalUrl = this.location.prepareExternalUrl(url);
|
||||
const urlId = uuidv4();
|
||||
|
||||
sessionStorage.setItem(urlId, externalUrl);
|
||||
|
||||
return of(urlId);
|
||||
return urlId;
|
||||
}
|
||||
|
||||
public restoreState(state?: string): void {
|
||||
if (state === undefined) {
|
||||
return;
|
||||
} else {
|
||||
const url = sessionStorage.getItem(state);
|
||||
if (url === null) {
|
||||
return;
|
||||
} else {
|
||||
sessionStorage.removeItem(state);
|
||||
// window.location.replace(window.location.origin + url);
|
||||
this.router.navigate([url]);
|
||||
}
|
||||
}
|
||||
|
||||
const url = sessionStorage.getItem(state);
|
||||
if (url === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
sessionStorage.removeItem(state);
|
||||
window.location.href = window.location.origin + url;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,9 @@ export class StatehandlerServiceImpl implements StatehandlerService, OnDestroy {
|
||||
map(() => oauthService.state),
|
||||
takeUntil(this.unsubscribe$),
|
||||
)
|
||||
.subscribe((state) => processor.restoreState(state));
|
||||
.subscribe((state) => {
|
||||
processor.restoreState(state);
|
||||
});
|
||||
}
|
||||
|
||||
public initStateHandler(): void {
|
||||
@@ -47,9 +49,11 @@ export class StatehandlerServiceImpl implements StatehandlerService, OnDestroy {
|
||||
switchMap((url: string) => {
|
||||
if (url.includes('?login_hint=')) {
|
||||
const newUrl = this.removeParam('login_hint', url);
|
||||
return of(newUrl);
|
||||
return of(this.processor.createState(newUrl));
|
||||
} else if (url) {
|
||||
return of(this.processor.createState(url));
|
||||
} else {
|
||||
return this.processor.createState(url);
|
||||
return of(undefined);
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user