Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move user information to auth0 #1023

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
ff98545
Remove user table and move information to auth0
jotjern Sep 24, 2024
73510c0
Give more proper names to columns
jotjern Sep 24, 2024
78da186
Update user repository to reflect db changes
jotjern Sep 24, 2024
eabd683
Correct user id type
jotjern Sep 24, 2024
059bfca
Clean attendee repository for ow_user references
jotjern Sep 24, 2024
1a57d9f
Fix attendee service
jotjern Sep 24, 2024
816f673
Add user data to next auth
jotjern Sep 24, 2024
cdd94a3
Merge branch 'main' into feature/dot-817-store-user-data-in-auth0-ins…
jotjern Sep 24, 2024
d321b8c
Retain ow_user table with only one column
jotjern Sep 24, 2024
3d1a180
Ensure auth0 id always added to owUser
jotjern Sep 24, 2024
963395d
Remove unecessary change
jotjern Sep 24, 2024
c891564
Cleanup
jotjern Sep 24, 2024
7743bd6
Fix nullable types
jotjern Sep 24, 2024
d843e57
Fix auth types
jotjern Sep 24, 2024
7a14de3
Lint fix
jotjern Sep 24, 2024
83f61ad
Remove outdated user service tests
jotjern Sep 24, 2024
bf221ae
Fix data shape
jotjern Sep 25, 2024
2c28667
Fix user dashboard page
jotjern Sep 25, 2024
0151599
Merge branch 'main' into feature/dot-817-store-user-data-in-auth0-ins…
jotjern Sep 25, 2024
ccfefe6
Lint
jotjern Sep 25, 2024
5708d1b
Fixed errors and removed unintentional changes
jotjern Sep 25, 2024
76958fb
Fix type problems
jotjern Sep 25, 2024
e06e233
LINT
jotjern Sep 25, 2024
44dc29c
Revert disabled e2e test to original state
jotjern Sep 25, 2024
ce228c0
Cleaned up user mapping code
jotjern Sep 26, 2024
6954629
Revert changes from other branch
jotjern Sep 26, 2024
69f1bd7
Fix again
jotjern Sep 26, 2024
9223f2d
Fix profile settings page
jotjern Nov 20, 2024
7ea7ac2
Lots of cleanup
jotjern Nov 20, 2024
a566624
Unrenamed file
jotjern Nov 20, 2024
6b3133e
Fix renamed propery
jotjern Nov 20, 2024
24047a1
Fix dashboard property names
jotjern Nov 20, 2024
89aac6a
Merge with main
jotjern Nov 20, 2024
14d5561
Merge branch 'main' into feature/dot-817-store-user-data-in-auth0-ins…
jotjern Nov 20, 2024
c991374
Remove unnecessary changes
jotjern Nov 20, 2024
14ddacd
Retain user id in ow_user table
jotjern Nov 20, 2024
04eb5d6
Fix type
jotjern Nov 20, 2024
7b6743c
Fix type problems
jotjern Nov 20, 2024
5161419
LINT
jotjern Nov 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/dashboard/src/modules/user/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const useUsersQuery = () => {
}

export const useSearchUsersQuery = (fullName: string) => {
const { data = [], isLoading } = trpc.user.searchByFullName.useQuery({
const { data = [], isLoading } = trpc.user.searchByName.useQuery({
searchQuery: fullName,
})
return { data, isLoading }
Expand Down
8 changes: 2 additions & 6 deletions packages/core/src/modules/attendance/attendee-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,9 @@ export class AttendeeRepositoryImpl implements AttendeeRepository {
const res = await this.db
.selectFrom("attendee")
.selectAll("attendee")
.leftJoin("owUser", "owUser.id", "attendee.userId")
.leftJoin("attendancePool", "attendee.attendancePoolId", "attendancePool.id")
.leftJoin("attendance", "attendance.id", "attendancePool.attendanceId")
.select(sql<User[]>`COALESCE(json_agg(ow_user), '[]')`.as("user"))
.select(sql<User[]>`COALESCE(json_agg(attendee.userId), '[]')`.as("userIds"))
.where("attendance.id", "=", attendanceId)
.groupBy("attendee.id")
.execute()
Expand All @@ -82,7 +81,6 @@ export class AttendeeRepositoryImpl implements AttendeeRepository {
...value,
user: {
...value.user[0],
lastSyncedAt: new Date(value.user[0].lastSyncedAt),
},
}))
.map(mapToAttendeeWithUser)
Expand All @@ -92,9 +90,8 @@ export class AttendeeRepositoryImpl implements AttendeeRepository {
const res = await this.db
.selectFrom("attendee")
.selectAll("attendee")
.leftJoin("owUser", "owUser.id", "attendee.userId")
.leftJoin("attendancePool", "attendee.attendancePoolId", "attendancePool.id")
.select(sql<User[]>`COALESCE(json_agg(ow_user) FILTER (WHERE ow_user.id IS NOT NULL), '[]')`.as("user"))
.select(sql<User[]>`COALESCE(json_agg(attendee.userId), '[]')`.as("userIds"))
.where("attendancePool.id", "=", id)
.groupBy("attendee.id")
.execute()
Expand All @@ -104,7 +101,6 @@ export class AttendeeRepositoryImpl implements AttendeeRepository {
...value,
user: {
...value.user[0],
lastSyncedAt: value.user[0].lastSyncedAt ? new Date(value.user[0].lastSyncedAt) : null,
},
}))
.map(mapToAttendeeWithUser)
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/modules/attendance/attendee-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class AttendeeServiceImpl implements AttendeeService {
) {}

async getByAuth0UserId(auth0UserId: string, attendanceId: AttendanceId) {
const user = await this.userService.getByAuth0Id(auth0UserId)
const user = await this.userService.getById(auth0UserId)
if (user === null) {
return null
}
Expand Down
11 changes: 1 addition & 10 deletions packages/core/src/modules/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { type EventCompanyRepository, EventCompanyRepositoryImpl } from "./event
import { type EventCompanyService, EventCompanyServiceImpl } from "./event/event-company-service"
import { type EventRepository, EventRepositoryImpl } from "./event/event-repository"
import { type EventService, EventServiceImpl } from "./event/event-service"
import { type Auth0Repository, Auth0RepositoryImpl } from "./external/auth0-repository"
import { type S3Repository, S3RepositoryImpl } from "./external/s3-repository"
import { type InterestGroupRepository, InterestGroupRepositoryImpl } from "./interest-group/interest-group-repository"
import { type InterestGroupService, InterestGroupServiceImpl } from "./interest-group/interest-group-service"
Expand Down Expand Up @@ -65,7 +64,6 @@ import { type ProductRepository, ProductRepositoryImpl } from "./payment/product
import { type ProductService, ProductServiceImpl } from "./payment/product-service"
import { type RefundRequestRepository, RefundRequestRepositoryImpl } from "./payment/refund-request-repository"
import { type RefundRequestService, RefundRequestServiceImpl } from "./payment/refund-request-service"
import { type Auth0SynchronizationService, Auth0SynchronizationServiceImpl } from "./user/auth0-synchronization-service"
import {
type NotificationPermissionsRepository,
NotificationPermissionsRepositoryImpl,
Expand Down Expand Up @@ -108,7 +106,6 @@ export const createServiceLayer = async ({ db }: ServerLayerOptions) => {
}

const s3Repository: S3Repository = new S3RepositoryImpl(s3Client)
const auth0Repository: Auth0Repository = new Auth0RepositoryImpl(auth0ManagementClient)
const eventRepository: EventRepository = new EventRepositoryImpl(db)
const committeeRepository: CommitteeRepository = new CommitteeRepositoryImpl(db)
const jobListingRepository: JobListingRepository = new JobListingRepositoryImpl(db)
Expand All @@ -121,7 +118,7 @@ export const createServiceLayer = async ({ db }: ServerLayerOptions) => {
const eventCompanyRepository: EventCompanyRepository = new EventCompanyRepositoryImpl(db)
const committeeOrganizerRepository: EventCommitteeRepository = new EventCommitteeRepositoryImpl(db)

const userRepository: UserRepository = new UserRepositoryImpl(db)
const userRepository: UserRepository = new UserRepositoryImpl(auth0ManagementClient)

const attendanceRepository: AttendanceRepository = new AttendanceRepositoryImpl(db)
const attendancePoolRepository: AttendancePoolRepository = new AttendancePoolRepositoryImpl(db)
Expand Down Expand Up @@ -150,11 +147,6 @@ export const createServiceLayer = async ({ db }: ServerLayerOptions) => {
notificationPermissionsRepository
)

const auth0SynchronizationService: Auth0SynchronizationService = new Auth0SynchronizationServiceImpl(
userService,
auth0Repository
)

const eventCommitteeService: EventCommitteeService = new EventCommitteeServiceImpl(committeeOrganizerRepository)
const committeeService: CommitteeService = new CommitteeServiceImpl(committeeRepository)
const jobListingService: JobListingService = new JobListingServiceImpl(
Expand Down Expand Up @@ -249,6 +241,5 @@ export const createServiceLayer = async ({ db }: ServerLayerOptions) => {
attendeeService,
interestGroupRepository,
interestGroupService,
auth0SynchronizationService,
}
}
83 changes: 0 additions & 83 deletions packages/core/src/modules/external/auth0-repository.ts

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe("users", () => {
givenName: updatedGivenName,
}

const updated = await core.userService.update(updatedUserWrite)
const updated = await core.userService.updateMetadata(updatedUserWrite)

expect(updated.givenName).toEqual(updatedGivenName)
})
Expand Down
Loading
Loading