Merge remote-tracking branch 'origin/master'

urls
Max Ehrlicher-Schmidt 4 years ago
commit 20eaf2ba85

@ -11,6 +11,7 @@ export class AuthService {
public loggedIn: BehaviorSubject<boolean>; public loggedIn: BehaviorSubject<boolean>;
private readonly REQUEST_TOKEN = 'requestToken'; private readonly REQUEST_TOKEN = 'requestToken';
private readonly REFRESH_TOKEN = 'refreshToken'; private readonly REFRESH_TOKEN = 'refreshToken';
private readonly EMAIL = 'email';
constructor(private http: HttpClient) { constructor(private http: HttpClient) {
this.loggedIn = new BehaviorSubject<boolean>(false); this.loggedIn = new BehaviorSubject<boolean>(false);
@ -37,6 +38,7 @@ export class AuthService {
// store request and refresh token in local storage to keep user logged in between page refreshes // store request and refresh token in local storage to keep user logged in between page refreshes
this.storeTokens(response); this.storeTokens(response);
this.checkIfUserIsLoggedIn(); this.checkIfUserIsLoggedIn();
this.storeEmail(email);
}) })
); );
} }
@ -55,6 +57,14 @@ export class AuthService {
); );
} }
storeEmail(email: string) {
localStorage.setItem(this.EMAIL, email);
}
getEmail() {
localStorage.getItem(this.EMAIL);
}
refreshToken() { refreshToken() {
return this.http return this.http
.post<any>(`${environment.authUrl}/new-token`, { .post<any>(`${environment.authUrl}/new-token`, {
@ -87,5 +97,6 @@ export class AuthService {
private removeTokens() { private removeTokens() {
localStorage.removeItem(this.REQUEST_TOKEN); localStorage.removeItem(this.REQUEST_TOKEN);
localStorage.removeItem(this.REFRESH_TOKEN); localStorage.removeItem(this.REFRESH_TOKEN);
localStorage.removeItem(this.EMAIL)
} }
} }

Loading…
Cancel
Save