Skip to content

Commit

Permalink
fix: issue with logging user being set to different value than underl…
Browse files Browse the repository at this point in the history
…ying user.id bigint::text (#2042)

Motivation:
* #2040
  • Loading branch information
gobengo committed Oct 18, 2022
1 parent 6103e99 commit 9659ab0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/api/src/auth.js
Expand Up @@ -34,7 +34,7 @@ export function withMagicToken (handler) {
// @ts-ignore
request.auth = { user: magicUser, userTags }
// If env.log is not set, then the middlewares may be being run in the wrong order
env.log.setUser({ id: parseInt(magicUser._id) })
env.log.setUser({ id: magicUser._id })
return handler(request, env, ctx)
}

Expand Down Expand Up @@ -66,7 +66,7 @@ export function withApiOrMagicToken (handler) {
userTags
}
// If env.log is not set, then the middlewares may be being run in the wrong order
env.log.setUser({ id: parseInt(magicUser._id) })
env.log.setUser({ id: magicUser._id })
return handler(request, env, ctx)
}

Expand Down
8 changes: 4 additions & 4 deletions packages/api/src/utils/logs.js
Expand Up @@ -62,7 +62,7 @@ export class Logging {
}
this.metadata = {
user: {
id: 0
id: '0'
},
request: {
url: request.url,
Expand All @@ -87,11 +87,11 @@ export class Logging {
/**
* Set user
*
* @param {Object} user
* @param {number} [user.id]
* @param {object} user
* @param {string} user.id
*/
setUser (user) {
this.metadata.user.id = user.id || 0
this.metadata.user.id = user.id
this.sendToSentry && this.opts.sentry.setUser({
id: `${user.id}`
})
Expand Down

0 comments on commit 9659ab0

Please sign in to comment.