Authentication
Auth
You will need an email and password to authenticate
POST /api/auth/login
curl -X POST \
'http://localhost:3000/api/auth/login' \
--header 'Accept: */*' \
--header 'Content-Type: application/json' \
--data-raw '{"email": "test@test.com", "password": "stringstring"}'
From this you should receive a response that looks like this:
{
"id": 1,
"email": "test@test.com",
"active": true,
"createdBy": "seed",
"updatedBy": "seed",
"createdAt": "2024-05-19 19:12:50.576",
"updatedAt": "2024-05-19 19:12:50.575",
"primaryAccount": {
"accountName": "Account 1",
"accountId": "2311",
"userBelongsToThisAccount": true,
"usersPrimaryAccount": true,
"internalUser": true
},
"accounts": [
{
"accountName": "Account 1",
"accountId": "2311",
"userBelongsToThisAccount": true,
"usersPrimaryAccount": true,
"internalUser": true
}
],
"flatRolesList": [
"superAdmin"
],
"flatPermissionsList": [
"readApplications",
"writeApplications",
"miscPermission",
"anotherPermission"
],
"permissionsFromRoles": [
"readApplications",
"writeApplications"
],
"token": "e9f753d94b5eba91aabaa2dc8206d7dc03d29056abcda037acb4f2f56c6bc3c5",
"expiresAt": "2024-05-20T03:15:07.647Z"
}
Bearer Token
Above you will notice there is a token property that gets returned with the login response. This token will need to be passed in with any api request that requires authentication via the Authorization header.
Example:
GET /api/auth/session
curl -X GET \
'http://localhost:3000/api/auth/session' \
--header 'Accept: */*' \
--header 'Authorization: Bearer e9f753d94b5eba91aabaa2dc8206d7dc03d29056abcda037acb4f2f56c6bc3c5'
Response:
{
"id": 1,
"email": "test@test.com",
"active": true,
"createdBy": "seed",
"updatedBy": "seed",
"createdAt": "2024-05-19 19:12:50.576",
"updatedAt": "2024-05-19 19:12:50.575",
"primaryAccount": {
"accountName": "Account 1",
"accountId": "2311",
"userBelongsToThisAccount": true,
"usersPrimaryAccount": true,
"internalUser": true
},
"accounts": [
{
"accountName": "Account 1",
"accountId": "2311",
"userBelongsToThisAccount": true,
"usersPrimaryAccount": true,
"internalUser": true
}
],
"flatRolesList": [
"superAdmin"
],
"flatPermissionsList": [
"readApplications",
"writeApplications",
"miscPermission",
"anotherPermission"
],
"permissionsFromRoles": [
"readApplications",
"writeApplications"
],
"token": "e9f753d94b5eba91aabaa2dc8206d7dc03d29056abcda037acb4f2f56c6bc3c5",
"expiresAt": "2024-05-20T03:15:07.647Z"
}