diff --git a/README.md b/README.md index 6e153ae..ec8de3d 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,9 @@ S3_BUCKET= S3_ENDPOINT= S3_REGION= S3_SECRET_KEY= +COGNITO_ACCESS_KEY= # optional +COGNITO_SECRET_KEY= # optional +COGNITO_REGION= # optional PORT= # optional ``` diff --git a/client/layouts/basicHeader/BasicHeader.module.css b/client/layouts/basicHeader/BasicHeader.module.css index 14ea8d9..9fe815e 100644 --- a/client/layouts/basicHeader/BasicHeader.module.css +++ b/client/layouts/basicHeader/BasicHeader.module.css @@ -59,6 +59,13 @@ background: #f0f0f0; } +.photo { + width: 18px; + height: 18px; + background-size: cover; + border-radius: 50%; +} + .menu { position: absolute; top: 100%; diff --git a/client/layouts/basicHeader/BasicHeader.tsx b/client/layouts/basicHeader/BasicHeader.tsx index 13c9196..f9e0fc9 100644 --- a/client/layouts/basicHeader/BasicHeader.tsx +++ b/client/layouts/basicHeader/BasicHeader.tsx @@ -54,8 +54,15 @@ export const BasicHeader = (props: { user: UserDto }) => {
setAnchorEl(e.currentTarget)}> - - {props.user.signInName} + {props.user.photoUrl ? ( +
+ ) : ( + + )} + {props.user.displayName}
setAnchorEl(null)}> setOpenProfile(true)}>Your profile @@ -67,7 +74,9 @@ export const BasicHeader = (props: { user: UserDto }) => { setOpenProfile(false)}> -
User name: {props.user.signInName}
+
Sign in name: {props.user.signInName}
+ +
Display name: {props.user.displayName}
Email: {props.user.email}
diff --git a/client/pages/_app.page.tsx b/client/pages/_app.page.tsx index fe60079..a082249 100644 --- a/client/pages/_app.page.tsx +++ b/client/pages/_app.page.tsx @@ -34,7 +34,7 @@ function MyApp({ Component, pageProps }: AppProps) { email: true, oauth: { domain: NEXT_PUBLIC_OAUTH_DOMAIN, - scopes: ['openid'], + scopes: ['openid', 'profile', 'aws.cognito.signin.user.admin'], redirectSignIn: [location.origin], redirectSignOut: [location.origin], responseType: 'code', diff --git a/client/pages/index.page.tsx b/client/pages/index.page.tsx index c3287be..344cd3a 100644 --- a/client/pages/index.page.tsx +++ b/client/pages/index.page.tsx @@ -7,7 +7,7 @@ const Home = () => { (
-
Hello {user.signInName}!
+
Hello {user.displayName}!
)} diff --git a/server/domain/user/repository/userQuery.ts b/server/domain/user/repository/userQuery.ts index 9e3c5f8..f5deda4 100644 --- a/server/domain/user/repository/userQuery.ts +++ b/server/domain/user/repository/userQuery.ts @@ -1,13 +1,12 @@ import type { Prisma, User } from '@prisma/client'; import { brandedId } from 'service/brandedId'; -import { z } from 'zod'; import type { UserEntity } from '../model/userType'; const toUserEntity = (prismaUser: User): UserEntity => ({ id: brandedId.user.entity.parse(prismaUser.id), email: prismaUser.email, signInName: prismaUser.signInName, - displayName: z.string().parse(prismaUser.displayName), + displayName: prismaUser.displayName, photoUrl: prismaUser.photoUrl ?? undefined, createdTime: prismaUser.createdAt.getTime(), }); diff --git a/server/prisma/schema.prisma b/server/prisma/schema.prisma index 2bc005d..87c28b2 100644 --- a/server/prisma/schema.prisma +++ b/server/prisma/schema.prisma @@ -11,7 +11,7 @@ model User { id String @id email String signInName String - displayName String? + displayName String photoUrl String? createdAt DateTime tasks Task[] diff --git a/server/prisma/seed.ts b/server/prisma/seed.ts index b4d88a2..304f87a 100644 --- a/server/prisma/seed.ts +++ b/server/prisma/seed.ts @@ -1,17 +1,8 @@ import type { Prisma } from '@prisma/client'; import { prismaClient, transaction } from 'service/prismaClient'; -const someFn = async (tx: Prisma.TransactionClient): Promise => { +const someFn = async (_tx: Prisma.TransactionClient): Promise => { // seeder script - const users = await tx.user.findMany({ where: { displayName: null } }); - - if (users.length > 0) { - await Promise.all( - users.map((user) => - tx.user.update({ where: { id: user.id }, data: { displayName: user.signInName } }), - ), - ); - } }; transaction('RepeatableRead', (tx) => Promise.all([someFn(tx)]))