los-auth
Version:
Libreria de autenticacion para las aplicaciones internas de la empresa LOS
41 lines • 1.42 kB
JavaScript
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { LosAuthService } from './los-auth.service';
var LosAuthGuardService = /** @class */ (function () {
function LosAuthGuardService(authService, route) {
this.authService = authService;
this.route = route;
}
LosAuthGuardService.prototype.canActivate = function (next, state) {
var _this = this;
this.authService.isLogged().subscribe(function (logged) {
if (logged) {
_this.authService.hasPermission(next.losAuthRoles).subscribe(function (hasPermission) {
if (hasPermission) {
return true;
}
else {
//Redirect to home
return false;
}
});
}
else {
//Redirect to login
return false;
}
});
return true;
};
LosAuthGuardService.decorators = [
{ type: Injectable },
];
/** @nocollapse */
LosAuthGuardService.ctorParameters = function () { return [
{ type: LosAuthService, },
{ type: Router, },
]; };
return LosAuthGuardService;
}());
export { LosAuthGuardService };
//# sourceMappingURL=los-auth-guard.service.js.map