{"version":3,"sources":["src/app/guards/auth.guard.ts","src/app/layouts/authentication/authentication.component.ts","src/app/layouts/authentication/authentication.component.html","src/app/layouts/dome/dome.component.ts","src/app/layouts/dome/dome.component.html","src/app/app.routes.ts","node_modules/@angular/common/locales/pt.mjs","src/app/helpers/jwt.interceptor.ts","src/app/app.config.ts","src/app/app.component.ts","src/app/app.component.html","src/main.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { Router, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';\nimport { AuthenticationService } from '../services/authentication/authentication.service';\nimport { firstValueFrom } from 'rxjs';\n\n@Injectable({ providedIn: 'root' })\nexport class AuthGuard {\n constructor(\n private router: Router,\n private authenticationService: AuthenticationService\n ) {}\n\n async canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {\n const user = this.authenticationService.userValue;\n const roles: string[] = route?.data?.['roles'];\n\n if (user) {\n this.redirectUser(user, roles);\n return true;\n }\n\n const userRefresh = await firstValueFrom(this.authenticationService.refreshToken());\n if (userRefresh) {\n this.redirectUser(userRefresh, roles);\n return true;\n }\n this.router.navigate(['/login'], { queryParams: { returnUrl: state.url } });\n return false;\n }\n\n private redirectUser(user, roles) {\n if (user.forceChangePassword) {\n this.router.navigate(['/alterar-senha']);\n return false;\n }\n\n if (!user.economicGroup.emitters[0].cadastroCompleto && sessionStorage.getItem('licenca') != '2') {\n this.router.navigate(['/completar-cadastro']);\n return false;\n }\n\n if (roles.length > 0 && !roles.every((role: string) => user.roles.includes(role))) {\n return false;\n }\n return true;\n }\n}\n","import { CommonModule } from '@angular/common';\nimport { Component } from '@angular/core';\nimport { RouterModule } from '@angular/router';\n\n@Component({\n selector: 'app-authentication',\n templateUrl: './authentication.component.html',\n styleUrls: ['./authentication.component.scss'],\n standalone: true,\n imports: [RouterModule, CommonModule],\n})\nexport class AuthenticationComponent {}\n","
© Linx - Todos direitos reservados
\n