You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ghostfolio/apps/client/src/app/pages/auth/auth-page.component.ts

47 lines
1.3 KiB

import {
KEY_STAY_SIGNED_IN,
SettingsStorageService
} from '@ghostfolio/client/services/settings-storage.service';
import { TokenStorageService } from '@ghostfolio/client/services/token-storage.service';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
4 years ago
@Component({
selector: 'gf-auth-page',
templateUrl: './auth-page.html',
styleUrls: ['./auth-page.scss']
})
export class AuthPageComponent implements OnDestroy, OnInit {
private unsubscribeSubject = new Subject<void>();
4 years ago
public constructor(
private route: ActivatedRoute,
private router: Router,
private settingsStorageService: SettingsStorageService,
4 years ago
private tokenStorageService: TokenStorageService
) {}
public ngOnInit() {
this.route.params
.pipe(takeUntil(this.unsubscribeSubject))
.subscribe((params) => {
const jwt = params['jwt'];
this.tokenStorageService.saveToken(
jwt,
this.settingsStorageService.getSetting(KEY_STAY_SIGNED_IN) === 'true'
);
this.router.navigate(['/']);
});
}
4 years ago
public ngOnDestroy() {
this.unsubscribeSubject.next();
this.unsubscribeSubject.complete();
4 years ago
}
}