fix
This commit is contained in:
parent
d008b50892
commit
2d293d8b12
|
|
@ -1,15 +1,27 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable, PLATFORM_ID, Inject } from '@angular/core';
|
||||||
import { CanActivate, Router } from '@angular/router';
|
import { CanActivate, Router } from '@angular/router';
|
||||||
import { AuthService } from '../services/auth.service';
|
import { AuthService } from '../services/auth.service';
|
||||||
import { createLogger } from '../utils/utils';
|
import { isPlatformBrowser } from '@angular/common';
|
||||||
const logger = createLogger('AuthGuard');
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class AuthGuard implements CanActivate {
|
export class AuthGuard implements CanActivate {
|
||||||
constructor(private authService: AuthService, private router: Router) {}
|
|
||||||
|
constructor(
|
||||||
|
private authService: AuthService,
|
||||||
|
private router: Router,
|
||||||
|
@Inject(PLATFORM_ID) private platformId: Object
|
||||||
|
) {}
|
||||||
|
|
||||||
async canActivate(): Promise<boolean> {
|
async canActivate(): Promise<boolean> {
|
||||||
|
// 1. SSR CHECK: Wenn wir auf dem Server sind, immer erlauben!
|
||||||
|
// Der Server soll nicht redirecten, sondern einfach das HTML rendern.
|
||||||
|
if (!isPlatformBrowser(this.platformId)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. CLIENT CHECK: Das läuft nur im Browser
|
||||||
const token = await this.authService.getToken();
|
const token = await this.authService.getToken();
|
||||||
if (token) {
|
if (token) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ environment.production = true;
|
||||||
environment.apiBaseUrl = 'https://api.bizmatch.net';
|
environment.apiBaseUrl = 'https://api.bizmatch.net';
|
||||||
|
|
||||||
environment.mailinfoUrl = 'https://www.bizmatch.net';
|
environment.mailinfoUrl = 'https://www.bizmatch.net';
|
||||||
environment.imageBaseUrl = 'https://api.bizmatch.net'; // Ggf. auch auskommentieren, wenn Bilder lokal liegen
|
environment.imageBaseUrl = 'https://www.bizmatch.net';// Ggf. auch auskommentieren, wenn Bilder lokal liegen
|
||||||
|
|
||||||
environment.POSTHOG_KEY = 'phc_eUIcIq0UPVzEDtZLy78klKhGudyagBz3goDlKx8SQFe';
|
environment.POSTHOG_KEY = 'phc_eUIcIq0UPVzEDtZLy78klKhGudyagBz3goDlKx8SQFe';
|
||||||
environment.POSTHOG_HOST = 'https://eu.i.posthog.com';
|
environment.POSTHOG_HOST = 'https://eu.i.posthog.com';
|
||||||
Loading…
Reference in New Issue