added locale backup + en support

This commit is contained in:
_Bastler
2021-03-26 10:17:28 +01:00
parent a9fd56efc6
commit 34755be840
16 changed files with 2724 additions and 1039 deletions
+20 -31
View File
@@ -1,24 +1,16 @@
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import {
CanActivate,
ActivatedRouteSnapshot,
RouterStateSnapshot
} from '@angular/router';
import { AuthService } from '../services/auth.service';
import {Injectable} from '@angular/core';
import {Router} from '@angular/router';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router';
import {AuthService} from '../services/auth.service';
@Injectable({
providedIn: 'root'
})
export class AuthUpdateGuard implements CanActivate {
constructor(private authService: AuthService) { }
constructor(private authService: AuthService) {}
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
this.authService.getAuth().catch(function (error) { });
this.authService.getAuth().catch(function(error) {});
return true;
}
}
@@ -27,15 +19,14 @@ export class AuthUpdateGuard implements CanActivate {
providedIn: 'root'
})
export class AuthGuard implements CanActivate {
constructor(private authService: AuthService, private router: Router) { }
constructor(private authService: AuthService, private router: Router) {}
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
const that = this;
return this.authService.getAuth().then(response => {
return true;
}).catch(function (error) {
that.router.navigateByUrl('/unavailable');
return false;
}).catch(function(error) {
return that.router.parseUrl('/unavailable');
});
}
}
@@ -44,19 +35,18 @@ export class AuthGuard implements CanActivate {
providedIn: 'root'
})
export class AuthenticatedGuard implements CanActivate {
constructor(private authService: AuthService, private router: Router) { }
constructor(private authService: AuthService, private router: Router) {}
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
const that = this;
return this.authService.getAuth().then((data: any) => {
if (!data.authenticated) {
if(!data.authenticated) {
this.router.navigateByUrl('/login');
return false;
}
return true;
}).catch(function (error) {
that.router.navigateByUrl('/unavailable');
return false;
}).catch(function(error) {
return that.router.parseUrl('/unavailable');
});
}
}
@@ -65,19 +55,18 @@ export class AuthenticatedGuard implements CanActivate {
providedIn: 'root'
})
export class AnonymousGuard implements CanActivate {
constructor(private authService: AuthService, private router: Router) { }
constructor(private authService: AuthService, private router: Router) {}
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
const that = this;
return this.authService.getAuth().then((data: any) => {
if (data.authenticated) {
if(data.authenticated) {
this.router.navigateByUrl('/account/info');
return false;
}
return true;
}).catch(function (error) {
that.router.navigateByUrl('/unavailable');
return false;
}).catch(function(error) {
return that.router.parseUrl('/unavailable');
});
}