App Users & JWT Authentication
Decoupled end-user authentication, JWT lifecycles, profile management, and password reset flows.
How are App Users Different from WordPress Admins?
Pottr provides an independent authentication layer designed specifically for end-users of your custom application:
- No WordPress Admin Access: App users cannot log into
/wp-adminand have no core WordPress capabilities. - No
wp_usersBloat: App users are stored in dedicated application authentication tables, keeping WordPress administration clean. - Custom Profile Fields: Blueprints allow declaring custom fields on user accounts (e.g.
full_name,company,avatar_url). - Stateless JWT Tokens: Authenticated via 15-minute HS256 JWT access tokens and 30-day hashed refresh tokens.
App Header Requirement (X-Pottr-App)
Every authentication endpoint requires an application identifier passed in the X-Pottr-App: <app_slug> request header (or an app string in the JSON body).
Authentication Endpoints
1. User Signup
Registers a new app user. Password must be at least 8 characters. Returns 201 Created with tokens.
const res = await fetch('https://example.com/wp-json/pottr/v1/auth/signup', {
method: 'POST',
headers: {
'Authorization': `Bearer ${PUBLIC_KEY}`,
'X-Pottr-App': 'task-manager',
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: 'alex@example.com',
password: 'securePassword123',
full_name: 'Alex Smith'
})
});2. User Login
Authenticates user credentials. Signup and login return the same shape:
{
"user": { "id": 12, "email": "alex@example.com", "full_name": "Alex Smith" },
"access_token": "eyJ...",
"refresh_token": "64_character_hex_refresh_token",
"token_type": "Bearer",
"expires_in": 900
}Send the access token in the X-Pottr-User-Token header (alongside your public key). Passwords are never returned.
3. Current User Profile
4. Token Refresh
Refresh tokens are single-use. Each refresh returns a new access token and a new refresh token; store the new one and discard the old. Presenting an already-used refresh token is treated as theft: Pottr revokes that whole session and returns 401 token_breach_detected.
{
"refresh_token": "64_character_hex_refresh_token"
}5. Logout
Revokes the current device session. Pass ?all=true (or { "all": true }) to sign the user out everywhere. Outstanding access tokens are invalidated immediately.
6. Sessions
Lists the user’s active device sessions with IP, browser and an is_current flag. End one with:
Rate Limits
Signup, login and password-reset routes are rate limited per IP. Exceeding the limit returns 429 rate_limited.
Password Reset Flow
Request Reset Email (
POST /auth/forgot-password): Client submits{ "email": "user@example.com" }. Pottr generates a secure 1-hour single-use transient token and sends a reset email via WordPresswp_mail(). Always returns200 { success: true }to prevent email enumeration.Complete Password Reset (
POST /auth/reset-password): Client submits{ "email": "...", "token": "...", "password": "newPassword" }. Pottr validates the token, updates the password hash, immediately destroys the token, and revokes active sessions.