Remove defaultAuthStatus from all environment configurations.
This commit is contained in:
parent
de1876c90c
commit
da17cf9696
|
|
@ -2,7 +2,6 @@ import {Injectable} from '@angular/core';
|
||||||
import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree} from '@angular/router';
|
import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree} from '@angular/router';
|
||||||
import {Observable} from 'rxjs';
|
import {Observable} from 'rxjs';
|
||||||
import {AuthService} from '@services/auth.service';
|
import {AuthService} from '@services/auth.service';
|
||||||
import {environment} from '@environment';
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
|
|
@ -19,9 +18,6 @@ export class AuthGuard implements CanActivate {
|
||||||
route: ActivatedRouteSnapshot,
|
route: ActivatedRouteSnapshot,
|
||||||
state: RouterStateSnapshot
|
state: RouterStateSnapshot
|
||||||
): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
||||||
if (environment.defaultAuthStatus) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!this.authService.checkAuthStatus()) {
|
if (!this.authService.checkAuthStatus()) {
|
||||||
return this.router.createUrlTree(['/']);
|
return this.router.createUrlTree(['/']);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,19 +5,18 @@ import {catchError, tap} from 'rxjs/operators';
|
||||||
import {MatSnackBar} from '@angular/material/snack-bar';
|
import {MatSnackBar} from '@angular/material/snack-bar';
|
||||||
import {JwtHelperService} from '@auth0/angular-jwt';
|
import {JwtHelperService} from '@auth0/angular-jwt';
|
||||||
import {JwtClaims} from '@custom-types/jwt_interface'
|
import {JwtClaims} from '@custom-types/jwt_interface'
|
||||||
import {environment} from '@environment';
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class AuthService {
|
export class AuthService {
|
||||||
private isAuthenticatedSubject = new BehaviorSubject<boolean>(environment.defaultAuthStatus);
|
private isAuthenticatedSubject = new BehaviorSubject<boolean>(false);
|
||||||
public isAuthenticated$ = this.isAuthenticatedSubject.asObservable();
|
public isAuthenticated$ = this.isAuthenticatedSubject.asObservable();
|
||||||
|
|
||||||
private userClaimsSubject = new BehaviorSubject<JwtClaims | null>(null);
|
private userClaimsSubject = new BehaviorSubject<JwtClaims | null>(null);
|
||||||
public userClaims$ = this.userClaimsSubject.asObservable();
|
public userClaims$ = this.userClaimsSubject.asObservable();
|
||||||
private jwtHelper = new JwtHelperService();
|
private jwtHelper = new JwtHelperService();
|
||||||
private _username = signal<string | null>(environment.defaultAuthStatus ? 'akastijn' : null);
|
private _username = signal<string | null>(null);
|
||||||
public readonly username = this._username.asReadonly();
|
public readonly username = this._username.asReadonly();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
|
@ -136,9 +135,6 @@ export class AuthService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getUuid(): string | null {
|
public getUuid(): string | null {
|
||||||
if (environment.defaultAuthStatus) {
|
|
||||||
return '55e46bc3-2a29-4c53-850f-dbd944dc5c5f';
|
|
||||||
}
|
|
||||||
const jwtClaims = this.userClaimsSubject.getValue();
|
const jwtClaims = this.userClaimsSubject.getValue();
|
||||||
if (jwtClaims === null) {
|
if (jwtClaims === null) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
export const environment = {
|
export const environment = {
|
||||||
production: true,
|
production: true,
|
||||||
apiUrl: 'https://beta.alttd.com',
|
apiUrl: 'https://beta.alttd.com',
|
||||||
defaultAuthStatus: false
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
export const environment = {
|
export const environment = {
|
||||||
production: false,
|
production: false,
|
||||||
apiUrl: 'http://localhost:8080',
|
apiUrl: 'http://localhost:8080',
|
||||||
defaultAuthStatus: true
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
export const environment = {
|
export const environment = {
|
||||||
production: true,
|
production: true,
|
||||||
apiUrl: 'https://alttd.com',
|
apiUrl: 'https://alttd.com',
|
||||||
defaultAuthStatus: false
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
export const environment = {
|
export const environment = {
|
||||||
production: true,
|
production: true,
|
||||||
apiUrl: 'https://alttd.com',
|
apiUrl: 'https://alttd.com',
|
||||||
defaultAuthStatus: false
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user