Skip to content

Commit

Permalink
feat: add name attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
solufa committed Sep 16, 2024
1 parent 2280a71 commit 64240d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion client/pages/console/index.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const Main = (_: { user: UserEntity }) => {
<tbody>
{users?.map((user) => (
<tr key={user.Username}>
<td>{user.Attributes?.find((attr) => attr.Name === 'sub')?.Value}</td>
<td>{user.Attributes?.find((attr) => attr.Name === 'name')?.Value}</td>
<td>{user.Username}</td>
<td>{user.Attributes?.find((attr) => attr.Name === 'email')?.Value}</td>
<td>{user.UserStatus}</td>
Expand Down
24 changes: 10 additions & 14 deletions server/domain/user/service/createAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down

0 comments on commit 64240d1

Please sign in to comment.