diff --git a/apps/server/src/app/__tests__/net-worth.integration.spec.ts b/apps/server/src/app/__tests__/net-worth.integration.spec.ts index 644ca0b9..5e5f7465 100644 --- a/apps/server/src/app/__tests__/net-worth.integration.spec.ts +++ b/apps/server/src/app/__tests__/net-worth.integration.spec.ts @@ -6,7 +6,6 @@ import { PgService } from '@maybe-finance/server/shared' import { AccountQueryService, UserService } from '@maybe-finance/server/features' import { resetUser } from './utils/user' jest.mock('plaid') -jest.mock('auth0') const prisma = new PrismaClient() diff --git a/apps/server/src/app/__tests__/utils/user.ts b/apps/server/src/app/__tests__/utils/user.ts index efff89fb..a8739e1c 100644 --- a/apps/server/src/app/__tests__/utils/user.ts +++ b/apps/server/src/app/__tests__/utils/user.ts @@ -3,12 +3,12 @@ import prisma from '../../lib/prisma' const EMAIL = 'test@example.com' -export async function resetUser(auth0Id = '__TEST_USER_ID__'): Promise { +export async function resetUser(authId = '__TEST_USER_ID__'): Promise { const [_, [user]] = await prisma.$transaction([ - prisma.$executeRaw`DELETE FROM "user" WHERE auth0_id=${auth0Id}`, + prisma.$executeRaw`DELETE FROM "user" WHERE auth_id=${authId}`, prisma.$queryRaw< [User] - >`INSERT INTO "user" (auth0_id, email) VALUES (${auth0Id}, ${EMAIL}) ON CONFLICT DO NOTHING RETURNING *`, + >`INSERT INTO "user" (auth_id, email) VALUES (${authId}, ${EMAIL}) ON CONFLICT DO NOTHING RETURNING *`, ]) return user diff --git a/apps/server/src/app/app.ts b/apps/server/src/app/app.ts index a2ae1001..c495a30d 100644 --- a/apps/server/src/app/app.ts +++ b/apps/server/src/app/app.ts @@ -82,6 +82,7 @@ app.get('/', (req, res) => { res.render('pages/index', { error: req.query.error }) }) +// TODO: Replace "admin" concept from Auth0 with next-auth // Only Auth0 users with a role of "admin" can view these pages (i.e. Maybe Employees) app.use(express.static(__dirname + '/assets')) diff --git a/apps/server/src/app/lib/endpoint.ts b/apps/server/src/app/lib/endpoint.ts index 535dd45f..7459930e 100644 --- a/apps/server/src/app/lib/endpoint.ts +++ b/apps/server/src/app/lib/endpoint.ts @@ -302,10 +302,15 @@ async function getCurrentUser(jwt: NonNullable) { return { ...user, - roles: jwt[SharedType.Auth0CustomNamespace.Roles] ?? [], - primaryIdentity: jwt[SharedType.Auth0CustomNamespace.PrimaryIdentity] ?? {}, - userMetadata: jwt[SharedType.Auth0CustomNamespace.UserMetadata] ?? {}, - appMetadata: jwt[SharedType.Auth0CustomNamespace.AppMetadata] ?? {}, + // TODO: Replace Auth0 concepts with next-auth + roles: [], + primaryIdentity: {}, + userMetadata: {}, + appMetadata: {}, + // roles: jwt[SharedType.Auth0CustomNamespace.Roles] ?? [], + // primaryIdentity: jwt[SharedType.Auth0CustomNamespace.PrimaryIdentity] ?? {}, + // userMetadata: jwt[SharedType.Auth0CustomNamespace.UserMetadata] ?? {}, + // appMetadata: jwt[SharedType.Auth0CustomNamespace.AppMetadata] ?? {}, } } diff --git a/apps/workers/src/app/__tests__/helpers/user.test-helper.ts b/apps/workers/src/app/__tests__/helpers/user.test-helper.ts index d581e3a6..0956a22b 100644 --- a/apps/workers/src/app/__tests__/helpers/user.test-helper.ts +++ b/apps/workers/src/app/__tests__/helpers/user.test-helper.ts @@ -1,12 +1,9 @@ import type { PrismaClient, User } from '@prisma/client' -export async function resetUser( - prisma: PrismaClient, - auth0Id = 'auth0|workers-integration-test-id' -): Promise { +export async function resetUser(prisma: PrismaClient, authId = 'TODO'): Promise { // eslint-disable-next-line const [_, __, ___, user] = await prisma.$transaction([ - prisma.$executeRaw`DELETE FROM "user" WHERE auth0_id=${auth0Id};`, + prisma.$executeRaw`DELETE FROM "user" WHERE auth_id=${authId};`, // Deleting a user does not cascade to securities, so delete all security records prisma.$executeRaw`DELETE from security;`, @@ -14,7 +11,7 @@ export async function resetUser( prisma.user.create({ data: { - auth0Id, + authId, email: 'test@example.com', finicityCustomerId: 'TEST', }, diff --git a/custom-express.d.ts b/custom-express.d.ts index e43bcf0f..58dd689a 100644 --- a/custom-express.d.ts +++ b/custom-express.d.ts @@ -13,19 +13,5 @@ declare global { json(data: any): Send superjson(data: any): Send } - - // express-jwt already adds a `user` prop to `req` object, we just need to define it - // This is the structure of the Auth0 user object - https://auth0.com/docs/users/user-profiles/user-profile-structure - // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/96d20a6a47593b83b0331a0a3f163a39aba523aa/types/express-jwt/index.d.ts#L69 - interface User - extends Partial<{ - iss: string - sub: string - aud: string[] - iat: number - exp: number - azp: string - scope: string - }> {} } }