36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import { Component } from '@angular/core';
|
|
import { Router, RouterModule, RouterOutlet, ActivatedRoute } from '@angular/router';
|
|
import { Authentication } from './services/Authentication';
|
|
import { CommonModule, Location } from '@angular/common';
|
|
import { HttpClient } from '@angular/common/http';
|
|
import { isDevMode } from '@angular/core';
|
|
|
|
@Component({
|
|
selector: 'app-root',
|
|
imports: [RouterOutlet, CommonModule, RouterModule],
|
|
templateUrl: './app.html',
|
|
styleUrl: './app.css'
|
|
})
|
|
export class App {
|
|
|
|
devMode: boolean = false;
|
|
loginToken: string | null = null;
|
|
|
|
constructor( private http: HttpClient, public auth: Authentication, private router: Router, private route: ActivatedRoute, private location: Location){
|
|
this.devMode = isDevMode();
|
|
this.route.queryParams.subscribe(params => {
|
|
this.loginToken = params['LoginToken'];
|
|
console.log("LoginToken : " + this.loginToken);
|
|
if (this.loginToken){
|
|
this.http.post( "api/account/loginticket", JSON.stringify(this.loginToken), { headers: {'Content-Type': 'application/json'} } ).subscribe({
|
|
next: async() => {
|
|
await this.auth.loadLoginState();
|
|
const pathWithoutQuery = this.location.path().split('?')[0];
|
|
this.location.replaceState(pathWithoutQuery);
|
|
}
|
|
})
|
|
}
|
|
});
|
|
}
|
|
}
|