ini
This commit is contained in:
@@ -0,0 +1,596 @@
|
||||
{
|
||||
"info": {
|
||||
"name": "AuthHex Mobile API Collection",
|
||||
"description": "Mobile authentication flow - OTP-based registration and login",
|
||||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
|
||||
"_postman_id": "auth-hex-mobile-api-collection",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"variable": [
|
||||
{
|
||||
"key": "baseUrl",
|
||||
"value": "https://localhost:7001/api",
|
||||
"description": "Base URL for AuthHex API"
|
||||
},
|
||||
{
|
||||
"key": "accessToken",
|
||||
"value": "",
|
||||
"description": "JWT Access Token - set automatically after login"
|
||||
},
|
||||
{
|
||||
"key": "refreshToken",
|
||||
"value": "",
|
||||
"description": "JWT Refresh Token - set automatically after login"
|
||||
},
|
||||
{
|
||||
"key": "mobileNumber",
|
||||
"value": "+94771234567",
|
||||
"description": "Mobile number for testing"
|
||||
},
|
||||
{
|
||||
"key": "referenceNumber",
|
||||
"value": "",
|
||||
"description": "OTP Reference Number - set automatically"
|
||||
}
|
||||
],
|
||||
"item": [
|
||||
{
|
||||
"name": "Health Check",
|
||||
"item": [
|
||||
{
|
||||
"name": "API Status",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/status",
|
||||
"host": ["{{baseUrl}}"],
|
||||
"path": ["status"]
|
||||
},
|
||||
"description": "Check if API is running"
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Mobile Registration Flow",
|
||||
"item": [
|
||||
{
|
||||
"name": "Step 1: Check Mobile Availability",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"functionName\": \"isAvailable\",\n \"payload\": {\n \"Identifier\": \"{{mobileNumber}}\"\n }\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/alt",
|
||||
"host": ["{{baseUrl}}"],
|
||||
"path": ["alt"]
|
||||
},
|
||||
"description": "Check if mobile number is available for registration"
|
||||
},
|
||||
"response": [],
|
||||
"event": [
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"exec": [
|
||||
"var jsonData = pm.response.json();",
|
||||
"if (jsonData.data && jsonData.data.IsAvailable) {",
|
||||
" pm.environment.set('mobileAvailable', true);",
|
||||
" console.log('Mobile number is available');",
|
||||
"} else {",
|
||||
" console.log('Mobile number already exists');",
|
||||
"}"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Step 2: Send Mobile OTP (New User)",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"functionName\": \"sendOtp\",\n \"payload\": {\n \"identifier\": \"{{mobileNumber}}\",\n \"numberOfDigits\": 6,\n \"newUser\": true\n }\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/alt",
|
||||
"host": ["{{baseUrl}}"],
|
||||
"path": ["alt"]
|
||||
},
|
||||
"description": "Send OTP to mobile number for new user registration"
|
||||
},
|
||||
"response": [],
|
||||
"event": [
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"exec": [
|
||||
"var jsonData = pm.response.json();",
|
||||
"if (jsonData.data && jsonData.data.Data && jsonData.data.Data.ReferenceNumber) {",
|
||||
" pm.environment.set('referenceNumber', jsonData.data.Data.ReferenceNumber);",
|
||||
" console.log('Reference Number: ' + jsonData.data.Data.ReferenceNumber);",
|
||||
"}"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Step 3: Verify OTP (New User)",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"functionName\": \"VerifyOTP\",\n \"payload\": {\n \"referenceNumber\": \"{{referenceNumber}}\",\n \"otpCode\": \"123456\",\n \"newUser\": true,\n \"identifier\": \"{{mobileNumber}}\",\n \"deviceName\": \"iPhone 14 Pro\"\n }\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/alt",
|
||||
"host": ["{{baseUrl}}"],
|
||||
"path": ["alt"]
|
||||
},
|
||||
"description": "Verify OTP for new user registration. Returns verification token."
|
||||
},
|
||||
"response": [],
|
||||
"event": [
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"exec": [
|
||||
"var jsonData = pm.response.json();",
|
||||
"if (jsonData.data && jsonData.data.verificationToken) {",
|
||||
" pm.environment.set('verificationToken', jsonData.data.verificationToken);",
|
||||
" console.log('OTP Verified - Registration can proceed');",
|
||||
"}"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Step 4: Complete Registration",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"functionName\": \"registerUser\",\n \"payload\": {\n \"fullName\": \"John Doe\",\n \"userName\": \"johndoe_mobile\",\n \"mobileNumber\": \"{{mobileNumber}}\",\n \"nic\": \"199512345678\",\n \"password\": \"SecurePass123!\",\n \"roleId\": \"00000000-0000-0000-0000-000000000001\",\n \"userTypeId\": \"00000000-0000-0000-0000-000000000001\",\n \"chkUser\": false\n }\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/user",
|
||||
"host": ["{{baseUrl}}"],
|
||||
"path": ["user"]
|
||||
},
|
||||
"description": "Complete user registration with verified mobile number"
|
||||
},
|
||||
"response": [],
|
||||
"event": [
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"exec": [
|
||||
"var jsonData = pm.response.json();",
|
||||
"if (jsonData.statusCode === 200) {",
|
||||
" console.log('User registered successfully');",
|
||||
"}"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Alternative: Direct Registration",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"fullName\": \"Jane Smith\",\n \"userName\": \"janesmith_mobile\",\n \"mobileNumber\": \"+94779876543\",\n \"nic\": \"199612345678\",\n \"password\": \"SecurePass123!\",\n \"roleId\": \"00000000-0000-0000-0000-000000000001\",\n \"userTypeId\": \"00000000-0000-0000-0000-000000000001\",\n \"chkUser\": true\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/registerUser",
|
||||
"host": ["{{baseUrl}}"],
|
||||
"path": ["registerUser"]
|
||||
},
|
||||
"description": "Direct registration endpoint - bypasses OTP verification"
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Mobile Login Flow",
|
||||
"item": [
|
||||
{
|
||||
"name": "Step 1: Send Login OTP to Mobile",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"functionName\": \"sendOtp\",\n \"payload\": {\n \"identifier\": \"{{mobileNumber}}\",\n \"numberOfDigits\": 6,\n \"newUser\": false\n }\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/alt",
|
||||
"host": ["{{baseUrl}}"],
|
||||
"path": ["alt"]
|
||||
},
|
||||
"description": "Send OTP to mobile number for existing user login"
|
||||
},
|
||||
"response": [],
|
||||
"event": [
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"exec": [
|
||||
"var jsonData = pm.response.json();",
|
||||
"if (jsonData.data && jsonData.data.Data && jsonData.data.Data.ReferenceNumber) {",
|
||||
" pm.environment.set('referenceNumber', jsonData.data.Data.ReferenceNumber);",
|
||||
" console.log('Login OTP Reference: ' + jsonData.data.Data.ReferenceNumber);",
|
||||
"}"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Step 2: Verify OTP & Login",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"functionName\": \"VerifyOTP\",\n \"payload\": {\n \"referenceNumber\": \"{{referenceNumber}}\",\n \"otpCode\": \"123456\",\n \"newUser\": false,\n \"identifier\": \"{{mobileNumber}}\",\n \"deviceName\": \"iPhone 14 Pro\"\n }\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/alt",
|
||||
"host": ["{{baseUrl}}"],
|
||||
"path": ["alt"]
|
||||
},
|
||||
"description": "Verify OTP and complete login - returns JWT tokens"
|
||||
},
|
||||
"response": [],
|
||||
"event": [
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"exec": [
|
||||
"var jsonData = pm.response.json();",
|
||||
"if (jsonData.data && jsonData.data.AccessToken) {",
|
||||
" pm.environment.set('accessToken', jsonData.data.AccessToken);",
|
||||
" pm.environment.set('refreshToken', jsonData.data.RefreshToken);",
|
||||
" console.log('Login successful - Tokens saved');",
|
||||
"}"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Authenticated Mobile Operations",
|
||||
"item": [
|
||||
{
|
||||
"name": "Get User Details",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Authorization",
|
||||
"value": "Bearer {{accessToken}}"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"functionName\": \"getUserDetails\",\n \"payload\": {}\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/user",
|
||||
"host": ["{{baseUrl}}"],
|
||||
"path": ["user"]
|
||||
},
|
||||
"description": "Get authenticated user details"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Get User Sessions",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Authorization",
|
||||
"value": "Bearer {{accessToken}}"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"functionName\": \"getUserSessions\",\n \"payload\": {}\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/user",
|
||||
"host": ["{{baseUrl}}"],
|
||||
"path": ["user"]
|
||||
},
|
||||
"description": "Get all active sessions for the user"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Change Password",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Authorization",
|
||||
"value": "Bearer {{accessToken}}"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"functionName\": \"ChangeUserPassword\",\n \"payload\": {\n \"currentPassword\": \"SecurePass123!\",\n \"newPassword\": \"NewSecurePass456!\"\n }\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/user",
|
||||
"host": ["{{baseUrl}}"],
|
||||
"path": ["user"]
|
||||
},
|
||||
"description": "Change user password"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Logout",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Authorization",
|
||||
"value": "Bearer {{accessToken}}"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"functionName\": \"LogoutUser\",\n \"payload\": {}\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/user",
|
||||
"host": ["{{baseUrl}}"],
|
||||
"path": ["user"]
|
||||
},
|
||||
"description": "Logout user and invalidate current session"
|
||||
},
|
||||
"response": [],
|
||||
"event": [
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"exec": [
|
||||
"pm.environment.unset('accessToken');",
|
||||
"pm.environment.unset('refreshToken');",
|
||||
"console.log('Logged out - Tokens cleared');"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Two-Factor Authentication (Mobile)",
|
||||
"item": [
|
||||
{
|
||||
"name": "Initiate 2FA Setup",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Authorization",
|
||||
"value": "Bearer {{accessToken}}"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"functionName\": \"initiateTwoFASetup\",\n \"payload\": {}\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/user",
|
||||
"host": ["{{baseUrl}}"],
|
||||
"path": ["user"]
|
||||
},
|
||||
"description": "Get QR code and secret for Google Authenticator setup"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Complete 2FA Setup",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Authorization",
|
||||
"value": "Bearer {{accessToken}}"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"functionName\": \"completeTwoFASetup\",\n \"payload\": {\n \"verificationCode\": \"123456\"\n }\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/user",
|
||||
"host": ["{{baseUrl}}"],
|
||||
"path": ["user"]
|
||||
},
|
||||
"description": "Verify and complete 2FA setup"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Verify 2FA Code",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Authorization",
|
||||
"value": "Bearer {{accessToken}}"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"functionName\": \"verifyTwoFA\",\n \"payload\": {\n \"code\": \"123456\"\n }\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/user",
|
||||
"host": ["{{baseUrl}}"],
|
||||
"path": ["user"]
|
||||
},
|
||||
"description": "Verify 2FA code during login"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Get 2FA Status",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Authorization",
|
||||
"value": "Bearer {{accessToken}}"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"functionName\": \"getTwoFAStatus\",\n \"payload\": {}\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/user",
|
||||
"host": ["{{baseUrl}}"],
|
||||
"path": ["user"]
|
||||
},
|
||||
"description": "Check if 2FA is enabled for user"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Disable 2FA",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Authorization",
|
||||
"value": "Bearer {{accessToken}}"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"functionName\": \"disableTwoFA\",\n \"payload\": {\n \"password\": \"SecurePass123!\"\n }\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/user",
|
||||
"host": ["{{baseUrl}}"],
|
||||
"path": ["user"]
|
||||
},
|
||||
"description": "Disable 2FA for user account"
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"auth": {
|
||||
"type": "bearer",
|
||||
"bearer": [
|
||||
{
|
||||
"key": "token",
|
||||
"value": "{{accessToken}}",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user