Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Fixed auth & user entity

Blaumause32f2b0020a5
diff --git a/src/common/decorators/current-user-id.decorator.ts b/src/common/decorators/current-user-id.decorator.ts
index 3946aa91f..32bc5b29b 100644
--- a/src/common/decorators/current-user-id.decorator.ts
+++ b/src/common/decorators/current-user-id.decorator.ts
@@ -7,17 +7,19 @@ export const CurrentUserId = createParamDecorator(
async (data: unknown, context: ExecutionContext) => {
const request: Request = context.switchToHttp().getRequest()
let token = ''
- if(request.cookies['token']) {
+
+ if (request.cookies['token']) {
token = request.cookies['token']
} else {
const extract = ExtractJwt.fromAuthHeaderAsBearerToken()
token = extract(request)
}
+
try {
const decoded: any = verify(token, process.env.JWT_SECRET)
- return decoded.userId
+ return decoded.user_id
} catch {
return null
}
- },
+ }
)
\ No newline at end of file
diff --git a/src/user/entities/user.entity.ts b/src/user/entities/user.entity.ts
index f8d44659a..97ecee518 100644
--- a/src/user/entities/user.entity.ts
+++ b/src/user/entities/user.entity.ts
@@ -29,9 +29,15 @@ export class User {
@Column('varchar', { length: 200, default: '' })
password: string
- @Column({ default: true })
+ @Column({ default: false })
isActive: boolean
+ @Column('int', { default: 1 })
+ emailRequests: number
+
+ // @Column('datetime', { nullable: true, default: null })
+ // consent: Date
+
@OneToMany(() => ActionToken, actionToken => actionToken.user)
actionTokens: ActionToken[]
}
\ No newline at end of file