Documentation Index
Fetch the complete documentation index at: https://mintlify.com/raceliciouss/YUSEN-LIMO-WAREHOUSE/llms.txt
Use this file to discover all available pages before exploring further.
AuthService is a global singleton object defined in assets/auth.js and attached to the window object at script load time. It is the single source of truth for authentication state and user account management throughout the YUSEN LIMO Warehouse System.
Accessing AuthService
Becauseauth.js executes an IIFE that assigns window.AuthService, you can reference the object from any script or browser console tab that loads the file:
AuthService.initializeAuth() is called automatically the moment auth.js is parsed, so the account store is always ready before any other code runs.
Storage Keys
AuthService uses two dedicated Local Storage keys internally. You should not write to these keys directly — always go through the API methods described below.
| Key | Purpose |
|---|---|
warehouseAuthAccounts | Serialized array of all user account objects |
warehouseAuthSession | Serialized session object for the currently logged-in user |
Method Reference
AuthService.initializeAuth()
Reads the account list from warehouseAuthAccounts and returns it as an array of normalized account objects. If the key is missing or the stored array is empty, it seeds and persists the two default accounts before returning them.
Call this once on page load (it is called automatically by auth.js, but can be called again safely to obtain the current accounts array).
Array<AccountObject> — normalized account objects (see shape below).
Default seeded accounts:
| userId | password | role | name | employeeId |
|---|---|---|---|---|
admin001 | Admin@123 | admin | Juan Cruz | ADM-001 |
emp001 | Employee@123 | employee | Joseph Dela Cruz | EMP-001 |
AuthService.authenticateUser(userId, password)
Validates the provided credentials against the stored account list. On success, writes a session object to warehouseAuthSession and updates the account’s lastLogin timestamp.
The unique login identifier for the account (e.g.
"admin001").The account password. Compared as a plain-text string after trimming whitespace from both ends.
{ success: boolean, user?: SessionObject, message?: string }
| Outcome | success | Included fields |
|---|---|---|
| Both fields empty | false | message: 'Please enter your User ID and Password.' |
| userId blank only | false | message: 'Invalid User ID.' |
| password blank only | false | message: 'Incorrect password.' |
| userId not found | false | message: 'Invalid User ID.' |
| Password mismatch | false | message: 'Incorrect password.' |
| Valid credentials | true | user: { userId, role, name, employeeId, position } |
AuthService.isAuthenticated()
Returns true if warehouseAuthSession contains a valid session object with a non-empty userId. Returns false if the key is missing, unparseable, or contains a session without a userId.
boolean
AuthService.getCurrentUser()
Returns a copy of the current session object, or null if no session exists.
SessionObject | null
The returned SessionObject has the following shape:
AuthService.logout()
Removes warehouseAuthSession from Local Storage, effectively ending the session. Returns true unconditionally.
true
AuthService.getAccounts()
Returns all accounts currently stored in warehouseAuthAccounts as an array of normalized account objects. Each object is a copy — mutating the returned array has no effect on storage.
Array<AccountObject>
Each AccountObject has the following shape:
AuthService.createUser(userData)
Creates a new user account and persists it. Requires the calling session to belong to an admin user.
Plain object containing the new account’s fields.
Unique employee identifier (e.g.
"EMP-002"). Must not already exist in the account list (case-insensitive comparison).Full display name for the user.
Login username. Must not already exist in the account list (case-insensitive comparison).
Plain-text password for the new account.
Optional confirmation value. If present, must match
password exactly; otherwise the call fails."admin" or "employee" (default: "employee")."active" or "inactive" (default: "active").{ success: boolean, user?: AccountObject, message: string }
AuthService.updateUser(userId, updates)
Updates an existing account identified by userId. Only admin users can call this method. The employeeId and createdAt fields are always preserved from the original record and cannot be changed through updates.
The
userId of the account to update.An object containing any subset of fields to change. Supported fields:
name, userId (rename), password, role, status, position.An admin cannot change their own
role to "employee" while they are the currently logged-in user. Doing so returns { success: false, message: 'You cannot change your own role to Employee while logged in.' }.{ success: boolean, user?: AccountObject, message: string }
AuthService.deleteUser(userId)
Permanently removes a user account from storage. Requires an admin session.
The
userId of the account to delete.- The target account is the currently logged-in admin.
- The target is the last remaining admin account.
{ success: boolean, message: string }
AuthService.resetPassword(userId)
Resets the target account’s password to the system default "Password123". Requires an admin session.
The
userId of the account whose password should be reset.{ success: boolean, message: string }
AuthService.toggleUserStatus(userId)
Flips the status field of the target account between "active" and "inactive". Requires an admin session.
The
userId of the account to toggle.{ success: boolean, message: string, status: string }
The returned status field reflects the new value after the toggle.
AuthService.changePassword(currentPassword, newPassword, confirmPassword)
Allows the currently logged-in user to change their own password. All three arguments are required and trimmed before comparison.
The user’s existing password. Must match the value stored in the account record.
The desired new password.
Must be identical to
newPassword. If the two differ, the call returns a failure response without modifying storage.{ success: boolean, message: string }
AuthService.getUserManagementList()
Returns all accounts with a guaranteed, normalized status field ("active" or "inactive"). Intended for the admin User Management table.
Array<AccountObject> — identical shape to getAccounts(), with status always present and lowercase.