|
@ -9,14 +9,14 @@ import { ViewMode } from '@prisma/client'; |
|
|
import { EMPTY } from 'rxjs'; |
|
|
import { EMPTY } from 'rxjs'; |
|
|
import { catchError } from 'rxjs/operators'; |
|
|
import { catchError } from 'rxjs/operators'; |
|
|
|
|
|
|
|
|
import { DataService } from '../services/data.service'; |
|
|
|
|
|
import { SettingsStorageService } from '../services/settings-storage.service'; |
|
|
import { SettingsStorageService } from '../services/settings-storage.service'; |
|
|
import { UserService } from '../services/user/user.service'; |
|
|
import { UserService } from '../services/user/user.service'; |
|
|
|
|
|
|
|
|
@Injectable({ providedIn: 'root' }) |
|
|
@Injectable({ providedIn: 'root' }) |
|
|
export class AuthGuard implements CanActivate { |
|
|
export class AuthGuard implements CanActivate { |
|
|
|
|
|
private static PUBLIC_PAGE_ROUTES = ['/about', '/pricing', '/resources']; |
|
|
|
|
|
|
|
|
constructor( |
|
|
constructor( |
|
|
private dataService: DataService, |
|
|
|
|
|
private router: Router, |
|
|
private router: Router, |
|
|
private settingsStorageService: SettingsStorageService, |
|
|
private settingsStorageService: SettingsStorageService, |
|
|
private userService: UserService |
|
|
private userService: UserService |
|
@ -35,7 +35,10 @@ export class AuthGuard implements CanActivate { |
|
|
.get() |
|
|
.get() |
|
|
.pipe( |
|
|
.pipe( |
|
|
catchError(() => { |
|
|
catchError(() => { |
|
|
if (state.url !== '/start') { |
|
|
if (AuthGuard.PUBLIC_PAGE_ROUTES.includes(state.url)) { |
|
|
|
|
|
resolve(true); |
|
|
|
|
|
return EMPTY; |
|
|
|
|
|
} else if (state.url !== '/start') { |
|
|
this.router.navigate(['/start']); |
|
|
this.router.navigate(['/start']); |
|
|
resolve(false); |
|
|
resolve(false); |
|
|
return EMPTY; |
|
|
return EMPTY; |
|
|