diff --git a/documentation/reference/adminapi.md b/documentation/reference/adminapi.md index 43b1a9d..dbf8bec 100644 --- a/documentation/reference/adminapi.md +++ b/documentation/reference/adminapi.md @@ -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: @@ -79,6 +79,9 @@ Response: "attributes": { "name": "Authy Person", "email": "Hello@authcompanion.com", + "metadata": { + "tenant": "tenantID" + }, "active": 1, "created": "2023-02-02T21:33:53.926Z", "updated": "2023-02-02T21:33:53.926Z" @@ -90,17 +93,20 @@ Response: "attributes": { "name": "Authy Person 2", "email": "Hello2@authcompanion.com", + "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" + } } ``` @@ -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 @@ -122,7 +130,10 @@ Bearer Token Required: `Authorization: Bearer {admin access token}` "name": "Authy Person", "email": "hello@authcompanion.com", "password": "supersecret", - "active": 1 + "metadata": { + "tenant": "tenantID" + }, + "active": 1, } } } @@ -138,6 +149,9 @@ Response: "attributes": { "name": "Authy Person", "email": "hello@authcompanion.com", + "metadata": { + "tenant": "tenantID" + }, "active": 1, "created": "2023-02-02T21:33:53.926Z", "updated": "2023-02-02T21:33:53.926Z" @@ -163,8 +177,11 @@ Bearer Token Required: `Authorization: Bearer {admin access token}` "attributes": { "name": "Authy Person", "email": "hello@authcompanion.com", - "password": "supersecret" - "active": 1 + "password": "supersecret", + "active": 1, + "metadata": { + "tenant": "tenantID", + }, } } } @@ -180,6 +197,9 @@ Response: "attributes": { "name": "Authy Person", "email": "hello@authcompanion.com", + "metadata": { + "tenant": "tenantID", + }, "active": 1, "created": "2023-02-02T21:33:53.926Z", "updated": "2023-02-02T21:33:53.926Z" diff --git a/services/admin/users/create.js b/services/admin/users/create.js index 53a2255..5e744de 100644 --- a/services/admin/users/create.js +++ b/services/admin/users/create.js @@ -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, diff --git a/services/admin/users/schema/createSchema.js b/services/admin/users/schema/createSchema.js index 48caba8..8cda943 100644 --- a/services/admin/users/schema/createSchema.js +++ b/services/admin/users/schema/createSchema.js @@ -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"], }, diff --git a/services/admin/users/schema/updateSchema.js b/services/admin/users/schema/updateSchema.js index 10bb2fc..b713b76 100644 --- a/services/admin/users/schema/updateSchema.js +++ b/services/admin/users/schema/updateSchema.js @@ -13,6 +13,7 @@ export const updateSchema = { email: { type: "string" }, password: { type: "string" }, metadata: { type: "object" }, + active: { type: "string" }, }, }, }, diff --git a/services/admin/users/update.js b/services/admin/users/update.js index 507ef46..1d2c0fb 100644 --- a/services/admin/users/update.js +++ b/services/admin/users/update.js @@ -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,