Auth & User Management
Cookie-based authentication and user lifecycle management. Auth routes use session cookies (withCredentials: true). No manual token storage required.
SDK Setup
1import { NeuctraAuthix } from "@neuctra/authix";
2
3const authix = new NeuctraAuthix({
4 appName: "MyApp",
5 baseUrl: "https://server.authix.neuctra.com/api",
6 publishableKey: "pk_live_xxxxxxxx_xxxxxxxxxxxxxxxx",
7 appId: "your_app_id_here",
8});signupUser
POST /users/signup
| Param | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Display name |
| string | Yes | Email address | |
| password | string | Yes | Password |
| username | string | No | Unique username |
| phone | string | null | No | Phone number |
| address | string | null | No | Address |
| avatarUrl | string | null | No | Avatar URL |
| isActive | boolean | No | Active status |
| role | string | No | User role |
1await authix.signupUser({
2 name: "John Doe",
3 email: "[email protected]",
4 password: "securePassword123",
5});Requires session cookie (withCredentials: true).
loginUser
POST /users/login
| Param | Type | Required | Description |
|---|---|---|---|
| string | Yes | Email address | |
| password | string | Yes | Password |
1await authix.loginUser({
2 email: "[email protected]",
3 password: "securePassword123",
4});Sets HTTP-only session cookie.
logoutUser
POST /users/logout
Returns: { success: boolean }
1await authix.logoutUser();Clears session cookie and reloads page in browser environments.
checkUserSession
GET /users/session
Returns: CheckSessionResponse
1const session = await authix.checkUserSession();Returns { authenticated: false } on server (SSR safe).
getUser
GET /users/:appId/user?id=... or ?username=...
| Param | Type | Required | Description |
|---|---|---|---|
| id | string | No | User ID |
| username | string | No | Username |
1await authix.getUser({ id: "user_id" });Requires appId. Uses session cookie.
getUserProfile
POST /users/profile
| Param | Type | Required | Description |
|---|---|---|---|
| userId | string | Yes | User ID |
1await authix.getUserProfile({ userId: "id" });Accepts { userId }, not JWT.
updateUser
PUT /users/update/:userId
| Param | Type | Required | Description |
|---|---|---|---|
| userId | string | Yes | User ID to update |
| appId | string | Yes | Required to verify app ownership |
| name | string | No | Display name |
| username | string | null | No | Unique username |
| string | No | ||
| password | string | No | Password |
| phone | string | null | No | Phone |
| address | string | null | No | Address |
| avatarUrl | string | null | No | Avatar URL |
| isActive | boolean | No | Active status |
| role | string | No | Role |
| settings | unknown | No | Arbitrary app-defined settings |
| packageInfo | unknown | No | Arbitrary app-defined package info |
| notifications | unknown | No | Arbitrary app-defined notifications |
| extraInfo | unknown | No | Arbitrary app-defined extra info |
1await authix.updateUser({
2 userId: "id",
3 appId: "your_app_id_here",
4 name: "Updated Name",
5});Uses session cookie. 'appId' is required to verify app ownership.
changePassword
PUT /users/change-password/:userId
| Param | Type | Required | Description |
|---|---|---|---|
| userId | string | Yes | User ID |
| currentPassword | string | Yes | Current password |
| newPassword | string | Yes | New password |
1await authix.changePassword({
2 userId: "id",
3 currentPassword: "old",
4 newPassword: "new",
5});User or admin password change.
requestEmailVerificationOTP
POST /users/send-verify-otp/:userId
| Param | Type | Required | Description |
|---|---|---|---|
| userId | string | Yes | User ID |
| string | Yes |
1await authix.requestEmailVerificationOTP({
2 userId: "id",
3 email: "[email protected]",
4});OTP verification flow.
verifyEmail
POST /users/verify-email
| Param | Type | Required | Description |
|---|---|---|---|
| string | Yes | ||
| otp | string | Yes | OTP |
1await authix.verifyEmail({
2 email: "[email protected]",
3 otp: "123456",
4});Email verification endpoint.
requestResetUserPasswordOTP
POST /users/forgot-password
| Param | Type | Required | Description |
|---|---|---|---|
| string | Yes |
1await authix.requestResetUserPasswordOTP({
2 email: "[email protected]",
3});Public endpoint (no session required).
resetUserPassword
POST /users/reset-password
| Param | Type | Required | Description |
|---|---|---|---|
| string | Yes | ||
| otp | string | Yes | OTP |
| newPassword | string | Yes | New password |
1await authix.resetUserPassword({
2 email: "[email protected]",
3 otp: "123456",
4 newPassword: "newPassword",
5});Public password reset flow.
checkIfUserExists
GET /users/check-user/:userId
| Param | Type | Required | Description |
|---|---|---|---|
| userId | string | Yes | User ID |
Returns: CheckUserResponse
1await authix.checkIfUserExists("user_id");API key only check.
deleteUser
DELETE /users/delete/:userId
| Param | Type | Required | Description |
|---|---|---|---|
| userId | string | Yes | User ID |
1await authix.deleteUser({ userId: "id" });Uses session cookie.
Security Model
Neuctra Authix uses secure HTTP-only cookies for authentication. Sessions are handled via withCredentials: true. The SDK auto-injects appId into requests.