Authentication API
Login, token verification, and password management
Authentication API
Authentication endpoints for staff members to login, verify tokens, and manage passwords.
Base URL: https://ycwadelaide.adenmgb.com
POST /api/auth/login
Authenticate a staff user and receive a JWT token.
Headers:
Request Body:
Success Response (200 OK):
Error Responses:
- 401 Unauthorized - Invalid credentials
- 500 Internal Server Error - Login failed
Notes:
- Token expires after 7 days
- Store token securely (Keychain/Keystore)
- Include token in
Authorization: Bearer <token>header for all authenticated requests
GET /api/auth/check
Verify if the current token is valid and get updated user information.
Headers:
Success Response (200 OK):
Error Response (401 Unauthorized):
Use Cases:
- Verify token validity on app startup
- Refresh user information
- Check user permissions before showing features
- Validate authentication before making requests
POST /api/auth/logout
Logout endpoint (stateless - token removal is client-side).
Headers:
Success Response (200 OK):
Notes:
- This endpoint is optional - token removal can be done client-side
- Remove token from secure storage on logout
- Clear user data from memory
POST /api/auth/change-password
Change the current user's password.
Headers:
Request Body:
Success Response (200 OK):
Error Responses:
- 400 Bad Request - Current password is incorrect
- 401 Unauthorized - Invalid or missing token
- 404 Not Found - User not found
- 500 Internal Server Error - Failed to change password
Notes:
- Validate password strength client-side before submitting
currentPasswordis required to verify identity- Password is hashed using SHA-256 before storage
JWT Token Details
Token Format
The JWT token consists of three parts: header.payload.signature
Token Structure
Header:
Payload:
Token Expiration
- Expiration Time: 7 days from issue time (
iat) - Expiration Check: Tokens are validated server-side
- Refresh: No refresh endpoint - user must login again when token expires
Token Usage
Include the token in the Authorization header for all authenticated requests:
Example Usage
JavaScript/Fetch: