From 64240d1cbca9415a29ad5616b461a955da801768 Mon Sep 17 00:00:00 2001 From: solufa Date: Tue, 17 Sep 2024 05:51:28 +0900 Subject: [PATCH] feat: add name attribute --- client/pages/console/index.page.tsx | 2 +- .../domain/user/service/createAttributes.ts | 24 ++++++++----------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/client/pages/console/index.page.tsx b/client/pages/console/index.page.tsx index 14877a1..6364b9e 100644 --- a/client/pages/console/index.page.tsx +++ b/client/pages/console/index.page.tsx @@ -35,7 +35,7 @@ const Main = (_: { user: UserEntity }) => { {users?.map((user) => ( - {user.Attributes?.find((attr) => attr.Name === 'sub')?.Value} + {user.Attributes?.find((attr) => attr.Name === 'name')?.Value} {user.Username} {user.Attributes?.find((attr) => attr.Name === 'email')?.Value} {user.UserStatus} diff --git a/server/domain/user/service/createAttributes.ts b/server/domain/user/service/createAttributes.ts index 073637d..3a58fa1 100644 --- a/server/domain/user/service/createAttributes.ts +++ b/server/domain/user/service/createAttributes.ts @@ -26,20 +26,16 @@ export const STANDARD_ATTRIBUTE_NAMES = [ ] as const; export const toAttributeTypes = (user: UserEntity): AttributeType[] => { - return user.kind === 'cognito' - ? [ - { Name: 'sub', Value: user.id }, - { Name: 'email', Value: user.email }, - { Name: 'email_verified', Value: isEmailVerified(user) ? 'true' : 'false' }, - { Name: 'updated_at', Value: Math.floor(user.updatedTime / 1000).toString() }, - ...user.attributes.map((attr) => ({ Name: attr.name, Value: attr.value })), - ] - : [ - { Name: 'sub', Value: user.id }, - { Name: 'email', Value: user.email }, - { Name: 'updated_at', Value: Math.floor(user.updatedTime / 1000).toString() }, - ...user.attributes.map((attr) => ({ Name: attr.name, Value: attr.value })), - ]; + return [ + { Name: 'sub', Value: user.id }, + { Name: 'name', Value: user.name }, + { Name: 'email', Value: user.email }, + { Name: 'updated_at', Value: Math.floor(user.updatedTime / 1000).toString() }, + ...user.attributes.map((attr) => ({ Name: attr.name, Value: attr.value })), + ...(user.kind === 'cognito' + ? [{ Name: 'email_verified', Value: isEmailVerified(user) ? 'true' : 'false' }] + : []), + ]; }; export const createAttributes = (