Skip to content

Commit

Permalink
fix: add metadata user field to admin api response
Browse files Browse the repository at this point in the history
  • Loading branch information
authcompanion committed Oct 12, 2023
1 parent e1dca1f commit 7f85566
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 12 deletions.
42 changes: 31 additions & 11 deletions documentation/reference/adminapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ Bearer Token Required: `Authorization: Bearer {admin access token}`

Query Parameters:

* page[size] (optional): The number of users to include per page.
* page[number] (optional): The page number of users to retrieve.
* search[email] (optional): Filter users by email address using the LIKE operator.
- page[size] (optional): The number of users to include per page.
- page[number] (optional): The page number of users to retrieve.
- search[email] (optional): Filter users by email address using the LIKE operator.

Response:

Expand All @@ -79,6 +79,9 @@ Response:
"attributes": {
"name": "Authy Person",
"email": "[email protected]",
"metadata": {
"tenant": "tenantID"
},
"active": 1,
"created": "2023-02-02T21:33:53.926Z",
"updated": "2023-02-02T21:33:53.926Z"
Expand All @@ -90,17 +93,20 @@ Response:
"attributes": {
"name": "Authy Person 2",
"email": "[email protected]",
"metadata": {
"tenant": "tenantID"
},
"active": 1,
"created": "2023-02-02T21:34:37.712Z",
"updated": "2023-02-02T21:34:37.712Z"
}
}
],
"links": {
"next": "/v1/admin/users?page[number]=2&page[size]=2",
"first": "/v1/admin/users?page[number]=1&page[size]=2",
"last": "/v1/admin/users?page[number]=3&page[size]=2"
}
"links": {
"next": "/v1/admin/users?page[number]=2&page[size]=2",
"first": "/v1/admin/users?page[number]=1&page[size]=2",
"last": "/v1/admin/users?page[number]=3&page[size]=2"
}
}
```

Expand All @@ -112,6 +118,8 @@ Description: Creates a new user in the Authcompanion database.

Bearer Token Required: `Authorization: Bearer {admin access token}`

Pass an arbitrary object to data.attributes.metdata which will be made availale as a claim on the user's JWT issued after login.

**POST** Request Body:

```json
Expand All @@ -122,7 +130,10 @@ Bearer Token Required: `Authorization: Bearer {admin access token}`
"name": "Authy Person",
"email": "[email protected]",
"password": "supersecret",
"active": 1
"metadata": {
"tenant": "tenantID"
},
"active": 1,
}
}
}
Expand All @@ -138,6 +149,9 @@ Response:
"attributes": {
"name": "Authy Person",
"email": "[email protected]",
"metadata": {
"tenant": "tenantID"
},
"active": 1,
"created": "2023-02-02T21:33:53.926Z",
"updated": "2023-02-02T21:33:53.926Z"
Expand All @@ -163,8 +177,11 @@ Bearer Token Required: `Authorization: Bearer {admin access token}`
"attributes": {
"name": "Authy Person",
"email": "[email protected]",
"password": "supersecret"
"active": 1
"password": "supersecret",
"active": 1,
"metadata": {
"tenant": "tenantID",
},
}
}
}
Expand All @@ -180,6 +197,9 @@ Response:
"attributes": {
"name": "Authy Person",
"email": "[email protected]",
"metadata": {
"tenant": "tenantID",
},
"active": 1,
"created": "2023-02-02T21:33:53.926Z",
"updated": "2023-02-02T21:33:53.926Z"
Expand Down
1 change: 1 addition & 0 deletions services/admin/users/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const createUserHandler = async function (request, reply) {
const userAttributes = {
name: user.name,
email: user.email,
metadata: JSON.parse(user.metadata),
active: user.active,
created: user.created_at,
updated: user.updated_at,
Expand Down
2 changes: 1 addition & 1 deletion services/admin/users/schema/createSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export const createSchema = {
name: { type: "string" },
email: { type: "string" },
password: { type: "string" },
active: { type: "string" },
metadata: { type: "object" },
active: { type: "string" },
},
required: ["name", "email", "password", "active"],
},
Expand Down
1 change: 1 addition & 0 deletions services/admin/users/schema/updateSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const updateSchema = {
email: { type: "string" },
password: { type: "string" },
metadata: { type: "object" },
active: { type: "string" },
},
},
},
Expand Down
1 change: 1 addition & 0 deletions services/admin/users/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export const updateUserHandler = async function (request, reply) {
const userAttributes = {
name: updatedUser.name,
email: updatedUser.email,
metadata: JSON.parse(user.metadata),
active: updatedUser.active,
created: updatedUser.created_at,
updated: updatedUser.updated_at,
Expand Down

0 comments on commit 7f85566

Please sign in to comment.