Settings working now. Everything working now.
Time for docker and beta test
This commit is contained in:
@ -1,14 +1,14 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {BehaviorSubject, Observable} from 'rxjs';
|
||||
import {map} from 'rxjs/operators';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import {User} from '../core/user';
|
||||
import { User } from '../core/user';
|
||||
import { environment } from '../../environments/environment';
|
||||
|
||||
const loginUrl = '/token';
|
||||
const refreshUrl = '/refresh';
|
||||
const JWT_USER = 'JWT_USER';
|
||||
const ACCESS_TOKEN_REFRESH_MINUTES = 10; // refresh token 10 minutes before expiry
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
export class AuthService {
|
||||
@ -60,10 +60,7 @@ export class AuthService {
|
||||
}
|
||||
|
||||
needsRefreshing(): boolean {
|
||||
|
||||
// We use this line to debug token refreshing
|
||||
// console.log("\n", Date.now(), ": Date.now()\n", this.user.exp * 1000, ": user.exp\n",(this.user.exp - (ACCESS_TOKEN_REFRESH_MINUTES * 60)) * 1000, ": comp");
|
||||
return Date.now() > (this.user.exp - (ACCESS_TOKEN_REFRESH_MINUTES * 60)) * 1000;
|
||||
return Date.now() > (this.user.exp - (environment.ACCESS_TOKEN_REFRESH_MINUTES * 60)) * 1000;
|
||||
}
|
||||
|
||||
expired(): boolean {
|
||||
@ -76,10 +73,6 @@ export class AuthService {
|
||||
this.currentUserSubject.next(null);
|
||||
}
|
||||
|
||||
getJwtToken() {
|
||||
return JSON.parse(localStorage.getItem(JWT_USER)).access_token;
|
||||
}
|
||||
|
||||
refreshToken() {
|
||||
return this.http.post<any>(refreshUrl, {})
|
||||
.pipe(map(u => u.access_token))
|
||||
|
||||
Reference in New Issue
Block a user