Skip to content

AuthService

reference
2 min readUpdated

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

MethodSignatureReturns
getTokengetToken()string
canActivatecanActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot)boolean
switchBranchswitchBranch(branchId: number)string
loginlogin(usernameInput: string, passwordInput: string, rememberMe: boolean, cookiesCode: string)void
saveUserLoggedInInformationsaveUserLoggedInInformation()void
verifyverify(code: undefined, id: undefined)void
verifiedOTPloginverifiedOTPlogin(username: undefined, password: undefined, id: undefined, grantCode: undefined, grantIP: undefined, isTwoFactorVerified: undefined)void
trustedMachinetrustedMachine(grantCode: string)void
useJwtHelperuseJwtHelper()void
verifyLoginverifyLogin(url: string)boolean
getSubscriptionPackagesgetSubscriptionPackages()void
HasPermissionHasPermission(data: string, ID: number, SecurityAccessTypeID: number)any
GetCompanyGetCompany(domain: string)void
HasPermission2HasPermission2(PersonUserID: number, SecurityAccessTypeID: number, PageID: number)any
userPermissionsForNewListuserPermissionsForNewList()void
getPermissionsForSheetgetPermissionsForSheet(moduleId: number, objId: number)any
setListOfNewPermissionsetListOfNewPermission(value: ListOfNewResponse)void
setExportLogssetExportLogs(moduleId: number)void
checkErrorResponsecheckErrorResponse(Response: undefined, module: string)string
clearStoredDataclearStoredData()void
getNotificationCountgetNotificationCount()Observable<any>
logOutlogOut()void

Properties

PropertyType
jwtHelperany
userPremissionsUserPremissions[]
_listOfNewPermissionListOfNewResponse
listOfNewPermissionany
SubscriptionPackagesnumber[]

Where it refuses work

  • AuthService stops the work with an early return when item === undefined || item === null.
  • AuthService stops the work with an early return when url === 'home' || url === ''.
  • AuthService stops the work with an early return when branchId === 0.
  • AuthService stops the work with an early return when url === '' && this.LoggedIn.
  • AuthService stops the work with an early return when SecurityAccessType.
  • AuthService stops the work with an early return when module == 'users'.

Diagram

mermaid
graph 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

ts
import { 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 AuthService rather than duplicating token or login-state logic in components.
  • Call canActivate() or verifyLogin() 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(), or trustedMachine(), 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)

  • AppRoutingModulePams/Web/Pams.Web/Client/app/app-routing.module.ts:1
  • AppComponentPams/Web/Pams.Web/Client/app/app.component.ts:1
  • MrqInquiryComponentPams/Web/Pams.Web/Client/app/components/MRQ/mrq-details/mrq-inquiry/mrq-inquiry.component.ts:1
  • BlogsComponentPams/Web/Pams.Web/Client/app/components/blogs/blogs.component.ts:1
  • AccountManagersComponentPams/Web/Pams.Web/Client/app/components/configuration/account-managers/account-managers.component.ts:1
  • CompanyCurrencyComponentPams/Web/Pams.Web/Client/app/components/configuration/commercial/company-currency/company-currency.component.ts:1
  • DeliveryTermsComponentPams/Web/Pams.Web/Client/app/components/configuration/commercial/delivery-terms/delivery-terms.component.ts:1
  • GuaranteeTypesComponentPams/Web/Pams.Web/Client/app/components/configuration/commercial/guarantee-types/guarantee-types.component.ts:1

…and 109 more.

Was this page helpful?

Download as PDF