expiry display, not yet working
This commit is contained in:
parent
2312f21d77
commit
657d85538e
@ -28,6 +28,7 @@
|
||||
</button>
|
||||
<span>Nober Grundbesitz GbR Hausverwaltung</span>
|
||||
<span class="spacer"></span>
|
||||
<span class="gittagversion">Expires in: {{expiresIn}} seconds</span>
|
||||
<span class="gittagversion">GITTAGVERSION</span>
|
||||
<a *ngIf="!authenticated" mat-button routerLink="/login">Login</a>
|
||||
<a *ngIf="authenticated" mat-button routerLink="/logout">Logout</a>
|
||||
|
@ -5,6 +5,8 @@ import { map, shareReplay } from 'rxjs/operators';
|
||||
import { TokenService } from '../token.service';
|
||||
import { NavigationEnd, Router } from '@angular/router';
|
||||
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-navigation',
|
||||
templateUrl: './navigation.component.html',
|
||||
@ -13,6 +15,7 @@ import { NavigationEnd, Router } from '@angular/router';
|
||||
export class NavigationComponent {
|
||||
|
||||
public authenticated: boolean
|
||||
expiresIn: number
|
||||
|
||||
isHandset$: Observable<boolean> = this.breakpointObserver.observe(Breakpoints.Handset)
|
||||
.pipe(
|
||||
@ -33,6 +36,7 @@ export class NavigationComponent {
|
||||
|
||||
ngOnInit() {
|
||||
this.authenticated = this.tokenService.checkAuthenticated()
|
||||
this.expiresIn = 600
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ import { MessageService } from './message.service';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { UserCreds } from './userCreds'
|
||||
import jwt_decode from 'jwt-decode'
|
||||
import { Observable } from 'rxjs';
|
||||
import { ComplexOuterSubscriber } from 'rxjs/internal/innerSubscribe';
|
||||
|
||||
|
||||
|
||||
@ -45,7 +47,7 @@ export class TokenService {
|
||||
}
|
||||
|
||||
async login(login: string, password: string) {
|
||||
this.messageService.add(`TokenService: trying to login and obtain token`);
|
||||
this.messageService.add(`TokenService: trying to login and obtain token`)
|
||||
const userCreds : UserCreds = {
|
||||
"application": "hv2",
|
||||
"login": login,
|
||||
@ -62,7 +64,7 @@ export class TokenService {
|
||||
|
||||
async refresh() {
|
||||
try {
|
||||
this.messageService.add(`TokenService: trying to refresh tokens`);
|
||||
this.messageService.add(`TokenService: trying to refresh tokens`)
|
||||
const refreshToken = localStorage.getItem(TokenService.Id_RefreshToken_Key)
|
||||
const tokenTuple: TokenTuple = await this.http.post<TokenTuple>(
|
||||
"https://authservice.hottis.de/refresh",
|
||||
@ -79,5 +81,23 @@ export class TokenService {
|
||||
}
|
||||
}
|
||||
|
||||
expiryUpdate() : Observable<number> {
|
||||
const exUp = new Observable<number>((observer) => {
|
||||
let i = 600
|
||||
|
||||
while (i != 0) {
|
||||
observer.next(i)
|
||||
i -= 1
|
||||
await new Promise(f => setTimeout(f, 1000))
|
||||
}
|
||||
observer.complete()
|
||||
|
||||
return {
|
||||
unsubscribe() {
|
||||
}
|
||||
}
|
||||
})
|
||||
return exUp
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user