diff --git a/apps/client/src/app/components/header/header.component.ts b/apps/client/src/app/components/header/header.component.ts index b730810cb..4465b2b6a 100644 --- a/apps/client/src/app/components/header/header.component.ts +++ b/apps/client/src/app/components/header/header.component.ts @@ -87,7 +87,7 @@ export class HeaderComponent implements OnChanges { public openLoginDialog(): void { if(this.webAuthnService.isEnabled()){ this.webAuthnService.verifyWebAuthn().subscribe(({ authToken }) => { - this.setToken(authToken); + this.setToken(authToken, false); }); return; } @@ -114,14 +114,14 @@ export class HeaderComponent implements OnChanges { takeUntil(this.unsubscribeSubject) ) .subscribe(({ authToken }) => { - this.setToken(authToken); + this.setToken(authToken, data.staySignedIn); }); } }); } - public setToken(aToken: string) { - this.tokenStorageService.saveToken(aToken); + public setToken(aToken: string, staySignedIn: boolean) { + this.tokenStorageService.saveToken(aToken, staySignedIn); this.router.navigate(['/']); } diff --git a/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.html b/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.html index 56fe52173..8460a3c9e 100644 --- a/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.html +++ b/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.html @@ -19,6 +19,7 @@ [(ngModel)]="data.accessToken" > + Stay signed in
diff --git a/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.module.ts b/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.module.ts index 201c66ca5..7701f4602 100644 --- a/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.module.ts +++ b/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.module.ts @@ -6,6 +6,7 @@ import { MatButtonModule } from '@angular/material/button'; import { MatDialogModule } from '@angular/material/dialog'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatInputModule } from '@angular/material/input'; +import { MatCheckboxModule} from "@angular/material/checkbox"; import { LoginWithAccessTokenDialog } from './login-with-access-token-dialog.component'; @@ -16,6 +17,7 @@ import { LoginWithAccessTokenDialog } from './login-with-access-token-dialog.com CommonModule, FormsModule, MatButtonModule, + MatCheckboxModule, MatDialogModule, MatFormFieldModule, MatInputModule, diff --git a/apps/client/src/app/services/token-storage.service.ts b/apps/client/src/app/services/token-storage.service.ts index fa3866ab0..660658b6a 100644 --- a/apps/client/src/app/services/token-storage.service.ts +++ b/apps/client/src/app/services/token-storage.service.ts @@ -11,11 +11,13 @@ export class TokenStorageService { public constructor(private userService: UserService) {} public getToken(): string { - return window.sessionStorage.getItem(TOKEN_KEY); + return window.localStorage.getItem(TOKEN_KEY) || window.sessionStorage.getItem(TOKEN_KEY); } - public saveToken(token: string): void { - window.sessionStorage.removeItem(TOKEN_KEY); + public saveToken(token: string, staySignedIn: boolean = false): void { + if (staySignedIn) { + window.localStorage.setItem(TOKEN_KEY, token); + } window.sessionStorage.setItem(TOKEN_KEY, token); } @@ -23,6 +25,7 @@ export class TokenStorageService { const utmSource = window.sessionStorage.getItem('utm_source'); window.sessionStorage.clear(); + window.localStorage.removeItem(TOKEN_KEY); this.userService.remove();