Kind: Class
Source: Pams/Web/Pams.Web/Client/app/services/security/auth.service.ts (line 74)
Part of: Pams
AuthService manages client-side authentication state and access checks for the PAMS web application. It exposes methods for login verification, token access, branch switching, OTP and trusted-machine flows, and route activation decisions.
Implements: CanActivate
Methods
| Method | Signature | Returns |
|---|---|---|
getToken | getToken() | string |
canActivate | canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) | boolean |
switchBranch | switchBranch(branchId: number) | string |
login | login(usernameInput: string, passwordInput: string, rememberMe: boolean, cookiesCode: string) | void |
saveUserLoggedInInformation | saveUserLoggedInInformation() | void |
verify | verify(code: undefined, id: undefined) | void |
verifiedOTPlogin | verifiedOTPlogin(username: undefined, password: undefined, id: undefined, grantCode: undefined, grantIP: undefined, isTwoFactorVerified: undefined) | void |
trustedMachine | trustedMachine(grantCode: string) | void |
useJwtHelper | useJwtHelper() | void |
verifyLogin | verifyLogin(url: string) | boolean |
getSubscriptionPackages | getSubscriptionPackages() | void |
HasPermission | HasPermission(data: string, ID: number, SecurityAccessTypeID: number) | any |
GetCompany | GetCompany(domain: string) | void |
HasPermission2 | HasPermission2(PersonUserID: number, SecurityAccessTypeID: number, PageID: number) | any |
userPermissionsForNewList | userPermissionsForNewList() | void |
getPermissionsForSheet | getPermissionsForSheet(moduleId: number, objId: number) | any |
setListOfNewPermission | setListOfNewPermission(value: ListOfNewResponse) | void |
setExportLogs | setExportLogs(moduleId: number) | void |
checkErrorResponse | checkErrorResponse(Response: undefined, module: string) | string |
clearStoredData | clearStoredData() | void |
getNotificationCount | getNotificationCount() | Observable<any> |
logOut | logOut() | void |
Properties
| Property | Type |
|---|---|
jwtHelper | any |
userPremissions | UserPremissions[] |
_listOfNewPermission | ListOfNewResponse |
listOfNewPermission | any |
SubscriptionPackages | number[] |
Where it refuses work
AuthServicestops the work with an early return whenitem === undefined || item === null.AuthServicestops the work with an early return whenurl === 'home' || url === ''.AuthServicestops the work with an early return whenbranchId === 0.AuthServicestops the work with an early return whenurl === '' && this.LoggedIn.AuthServicestops the work with an early return whenSecurityAccessType.AuthServicestops the work with an early return whenmodule == 'users'.
Diagram
mermaidgraph LR Client[Client Component] --> AuthService[AuthService] AuthService --> Login[login] AuthService --> Verification[verify / verifyLogin] AuthService --> OTP[verifiedOTPlogin] AuthService --> TrustedMachine[trustedMachine] AuthService --> Token[getToken] AuthService --> RouteGuard[canActivate] AuthService --> Branch[switchBranch] AuthService --> Jwt[useJwtHelper] AuthService --> Session[saveUserLoggedInInformation]
Usage
tsimport { AuthService } from './services/security/auth.service';
export class AccountComponent {
constructor(private readonly authService: AuthService) {}
signIn(): void {
this.authService.login();
}
canAccessProtectedRoute(): boolean {
return this.authService.canActivate();
}
getCurrentToken(): string {
return this.authService.getToken();
}
changeBranch(): string {
return this.authService.switchBranch();
}
validateLogin(): boolean {
return this.authService.verifyLogin();
}
}
AI Coding Instructions
- Keep authentication and session-related operations inside
AuthServicerather than duplicating token or login-state logic in components. - Call
canActivate()orverifyLogin()before allowing protected client-side actions or navigation. - Use
getToken()as the single access point for the current authentication token. - Preserve the existing login flow when changing
login(),verify(),verifiedOTPlogin(), ortrustedMachine(), since these methods may depend on shared session state. - Update branch-related behavior through
switchBranch()so branch state remains consistent with the authenticated user context.
Used by
117 references from 117 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.
Imported by (117)
AppRoutingModule—Pams/Web/Pams.Web/Client/app/app-routing.module.ts:1AppComponent—Pams/Web/Pams.Web/Client/app/app.component.ts:1MrqInquiryComponent—Pams/Web/Pams.Web/Client/app/components/MRQ/mrq-details/mrq-inquiry/mrq-inquiry.component.ts:1BlogsComponent—Pams/Web/Pams.Web/Client/app/components/blogs/blogs.component.ts:1AccountManagersComponent—Pams/Web/Pams.Web/Client/app/components/configuration/account-managers/account-managers.component.ts:1CompanyCurrencyComponent—Pams/Web/Pams.Web/Client/app/components/configuration/commercial/company-currency/company-currency.component.ts:1DeliveryTermsComponent—Pams/Web/Pams.Web/Client/app/components/configuration/commercial/delivery-terms/delivery-terms.component.ts:1GuaranteeTypesComponent—Pams/Web/Pams.Web/Client/app/components/configuration/commercial/guarantee-types/guarantee-types.component.ts:1
…and 109 more.
Was this page helpful?