Skip to content

Commit

Permalink
Merge branch 'main' into cheap-DAM
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikskog authored May 8, 2024
2 parents 71dc6cf + 7fc12d9 commit 3fb0f99
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 8 additions & 2 deletions infra/auth0/appkom.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@ resource "auth0_client" "appkom_opptak" {
allowed_logout_urls = {
"dev" = ["http://localhost:3000"]
"stg" = []
"prd" = ["https://online-opptak.vercel.app"]
"prd" = [
"https://online-opptak.vercel.app",
"http://localhost:3000",
]
}[terraform.workspace]
allowed_origins = []
app_type = "spa"
callbacks = {
"dev" = ["http://localhost:3000/api/auth/callback/auth0"]
"stg" = []
"prd" = ["https://online-opptak.vercel.app/api/auth/callback/auth0"]
"prd" = [
"https://online-opptak.vercel.app/api/auth/callback/auth0",
"http://localhost:3000/api/auth/callback,
]
}[terraform.workspace]
grant_types = ["authorization_code", "refresh_token"]
name = "Online Komitéopptak${local.name_suffix[terraform.workspace]}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,21 @@ export class Auth0SynchronizationServiceImpl implements Auth0SynchronizationServ
}

private async synchronizeUserAuth0ToLocalDb(userAuth0: User) {
this.logger.log("info", "Synchronizing user with Auth0 id", { userId: userAuth0.auth0Id })
this.logger.info("Synchronizing user with Auth0 id %O", { userId: userAuth0.auth0Id })

const updatedUser: User = {
...userAuth0,
lastSyncedAt: new Date(),
}

const userDb = await this.userService.getById(userAuth0.id)
const userDb = await this.userService.getByAuth0Id(userAuth0.auth0Id)

if (userDb === null) {
this.logger.log("info", "User does not exist in local db, creating user for user ", userAuth0.name)
this.logger.info("User does not exist in local db, creating user for user %O", userAuth0.name)
return this.userService.create(updatedUser)
}

this.logger.log("info", "Updating user in local db for user ", userAuth0.name)
this.logger.info("Updating user in local db for user %O", userAuth0.name)
return this.userService.update(updatedUser)
}

Expand Down

0 comments on commit 3fb0f99

Please sign in to comment.