Skip to main content

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 the single source of truth for all authentication, session state, and account data in the YUSEN LIMO Warehouse System. It is defined as a plain JavaScript object in assets/auth.js and attached to the global window at page load. No server is involved — every account record, every session token, and every credential is read from and written to browser Local Storage under two keys: warehouseAuthAccounts (the account array) and warehouseAuthSession (the active session object).

Login Flow

1

User opens index.html

The login page is the application entry point. assets/login.js attaches a DOMContentLoaded listener and immediately calls AuthService.isAuthenticated(). If a valid session already exists in Local Storage, the user is forwarded to pages/dashboard.html without seeing the form.
2

User submits credentials

On form submit, login.js reads the userId and password field values, trims whitespace, and calls:
const result = window.AuthService.authenticateUser(userId, password);
The submit button is disabled and its label changes to 'Signing in...' for the duration of the call.
3

AuthService looks up the account

Inside authenticateUser, the method calls readAccounts(), which parses the JSON array stored at warehouseAuthAccounts. If that key is absent or unparseable, the in-memory seededAccounts array is returned as a fallback so the application always has at least two valid accounts to check against.
4

Successful match: session is stamped and persisted

When both userId and password match a stored account record, authenticateUser writes the current ISO timestamp back to lastLogin on that account, persists the updated account array, then builds a session object containing only the fields needed for UI rendering:
{
  "userId": "admin001",
  "role": "admin",
  "name": "Juan Cruz",
  "employeeId": "ADM-001",
  "position": "Administrator"
}
The session object is serialised with JSON.stringify and written to warehouseAuthSession via persistSession(). The method then returns:
{ success: true, user: session }
5

login.js redirects to the dashboard

When result.success is true, login.js sets:
window.location.href = 'pages/dashboard.html';
All subsequent authenticated pages read the role and identity from warehouseAuthSession via AuthService.getCurrentUser().
6

Failed match: error is displayed

When result.success is false, login.js re-enables the submit button and writes result.message into the #loginError element on the page. The user remains on index.html.

Session Utilities

AuthService.isAuthenticated()

Returns true if warehouseAuthSession exists in Local Storage and the parsed object has a non-empty userId property. Returns false in all other cases, including when localStorage is unavailable.
if (AuthService.isAuthenticated()) {
  // user has an active session
}

AuthService.getCurrentUser()

Returns a shallow copy of the current session object, or null if no valid session exists. Use this on every authenticated page to read the logged-in user’s userId, role, name, employeeId, and position.
const user = AuthService.getCurrentUser();
// { userId: 'admin001', role: 'admin', name: 'Juan Cruz', ... }

AuthService.logout()

Calls the internal clearSession() helper, which removes warehouseAuthSession from Local Storage with localStorage.removeItem(). Returns true. After calling logout(), isAuthenticated() will return false and getCurrentUser() will return null.
AuthService.logout();
window.location.href = '../index.html';

Default Seeded Accounts

When warehouseAuthAccounts is absent or empty, AuthService falls back to the following built-in credentials. These accounts are defined directly in assets/auth.js and require no setup step.
UsernamePasswordRole
admin001Admin@123admin
emp001Employee@123employee
AuthService.initializeAuth() is called automatically at the bottom of assets/auth.js when the script is first parsed, so accounts are always available before login.js runs.

Error Messages from authenticateUser

authenticateUser(userId, password) performs input validation before touching Local Storage. The table below lists every distinct message value the method can return alongside the condition that triggers it.
Conditionsuccessmessage
Both userId and password are emptyfalse'Please enter your User ID and Password.'
userId is empty, password is providedfalse'Invalid User ID.'
userId is provided, password is emptyfalse'Incorrect password.'
userId does not match any stored accountfalse'Invalid User ID.'
userId matches but password is wrongfalse'Incorrect password.'
Credentials are validtrue(no message — user session object is returned)
Note that a missing userId and an unrecognised userId return the same message ('Invalid User ID.') — this is intentional and prevents user enumeration.

Storage Keys Used by the Auth Module

Local Storage KeyContents
warehouseAuthAccountsJSON array of all user account objects
warehouseAuthSessionJSON object representing the active session
Passwords are stored as plaintext strings inside warehouseAuthAccounts in browser Local Storage. Any script running on the same origin can read them with localStorage.getItem('warehouseAuthAccounts'). This is acceptable for a local prototype but must not be used in a production deployment. See the migration path page for guidance on moving to server-side hashed credentials and token-based sessions.

Build docs developers (and LLMs) love