Kind: Class
Source: Pams/Web/Pams.WebApp/Client/app/services/security/auth.service.ts (line 35)
Part of: Pams
AuthService manages client-side authentication state, JWT helper setup, branch switching, company lookup, and permission checks in the Pams web application. Route-related code can call canActivate() and verifyLogin() to determine whether a user session is valid.
Implements: CanActivate
Methods
| Method | Signature | Returns |
|---|---|---|
canActivate | canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) | boolean |
switchBranch | switchBranch(branchId: number) | string |
login | login(usernameInput: string, passwordInput: string) | void |
useJwtHelper | useJwtHelper() | void |
verifyLogin | verifyLogin(url: string) | boolean |
HasPermission | HasPermission(data: string, ID: number, SecurityAccessTypeID: number) | any |
GetCompany | GetCompany(domain: string) | void |
HasPermission2 | HasPermission2(PersonUserID: number, SecurityAccessTypeID: number, PageID: number) | any |
logOut | logOut() | void |
Properties
| Property | Type |
|---|---|
userPremissions | UserPremissions[] |
jwtHelper | JwtHelper |
Where it refuses work
AuthServicestops the work with an early return whenitem == undefined || item == null.AuthServicestops the work with an early return whenbranchId == 0.AuthServicestops the work with an early return whenurl == "" && this.LoggedIn.
Diagram
mermaidgraph LR UI[Application UI] --> AuthService[AuthService] AuthService --> Login[login] AuthService --> Jwt[useJwtHelper] AuthService --> Verify[verifyLogin] AuthService --> Guard[canActivate] AuthService --> Branch[switchBranch] AuthService --> Company[GetCompany] AuthService --> Permissions[HasPermission / HasPermission2] AuthService --> Logout[logOut] Guard --> Routes[Protected Routes]
Usage
tsimport { Component } from "@angular/core";
import { AuthService } from "../services/security/auth.service";
@Component({
selector: "app-account-menu",
template: `
<button *ngIf="isLoggedIn()" (click)="changeBranch()">
Switch branch
</button>
<button (click)="signOut()">Log out</button>
`
})
export class AccountMenuComponent {
constructor(private readonly authService: AuthService) {}
isLoggedIn(): boolean {
return this.authService.verifyLogin();
}
canAccessProtectedRoute(): boolean {
return this.authService.canActivate();
}
changeBranch(): string {
return this.authService.switchBranch();
}
signOut(): void {
this.authService.logOut();
}
}
AI Coding Instructions
- Keep authentication and authorization checks routed through
AuthServicerather than duplicating session logic in components. - Preserve the existing method names and casing, including
HasPermission,HasPermission2, andGetCompany. - Call
verifyLogin()orcanActivate()before rendering or navigating to authenticated areas. - Keep JWT-related changes aligned with
useJwtHelper(),login(), andlogOut()so session state is cleared consistently.
Used by
2 references from 2 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.
Imported by (2)
MaritalStatusService—Pams/Web/Pams.WebApp/Client/app/services/common/marital-status.service.ts:1SharedServicesModule—Pams/Web/Pams.WebApp/Client/app/services/shared-service.module.ts:1
Was this page helpful?