added locale backup + en support
This commit is contained in:
+20
-31
@@ -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');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user