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!

@yevheniikulisidi remarks

Blue Mouseed9c0acb9517
diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts
index a3442c4f2..a750d4631 100644
--- a/src/auth/auth.service.ts
+++ b/src/auth/auth.service.ts
@@ -14,7 +14,7 @@ import {
import { ActionTokensService } from 'src/action-tokens/action-tokens.service'
import { LetterTemplate } from 'src/mailer/letter'
import { MailerService } from 'src/mailer/mailer.service'
-import { MAX_EMAIL_REQUESTS, User, TRIAL_DURATION } from 'src/user/entities/user.entity'
+import { MAX_EMAIL_REQUESTS, User } from 'src/user/entities/user.entity'
import { TelegrafContext } from 'src/user/user.controller'
import { UserService } from 'src/user/user.service'
import { ProjectService } from 'src/project/project.service'
@@ -103,8 +103,6 @@ export class AuthService {
const user = await this.userService.createUser({
email,
password: hashedPassword, // Using the password field is incorrect.
- // @ts-ignore
- trialEndDate: dayjs.utc().add(TRIAL_DURATION, 'day').format('YYYY-MM-DD HH:mm:ss'),
})
await this.sendVerificationEmail(user.id, user.email)
diff --git a/src/user/entities/user.entity.ts b/src/user/entities/user.entity.ts
index 0964c3414..81abebc9a 100644
--- a/src/user/entities/user.entity.ts
+++ b/src/user/entities/user.entity.ts
@@ -163,7 +163,7 @@ export class User {
isActive: boolean
@Column({ type: 'timestamp', nullable: true })
- trialEndDate: Date
+ trialEndDate: Date | null
@Column({
type: 'enum',
diff --git a/src/user/user.service.ts b/src/user/user.service.ts
index 1c20ee7a9..e4be6ebf5 100644
--- a/src/user/user.service.ts
+++ b/src/user/user.service.ts
@@ -1,12 +1,13 @@
import { Injectable, BadRequestException } from '@nestjs/common'
import { InjectRepository } from '@nestjs/typeorm'
import { Repository } from 'typeorm'
+import * as dayjs from 'dayjs'
import * as _isEmpty from 'lodash/isEmpty'
import * as _size from 'lodash/size'
import * as _omit from 'lodash/omit'
import { Pagination, PaginationOptionsInterface } from '../common/pagination'
-import { User, ACCOUNT_PLANS } from './entities/user.entity'
+import { User, ACCOUNT_PLANS, TRIAL_DURATION } from './entities/user.entity'
import { UserProfileDTO } from './dto/user.dto'
import { RefreshToken } from './entities/refresh-token.entity'
@@ -161,8 +162,11 @@ export class UserService {
return await this.usersRepository.findOne({ email })
}
- public async createUser(user: Pick<User, 'email' | 'password' | 'trialEndDate'>) {
- return await this.usersRepository.save(user)
+ public async createUser(user: Pick<User, 'email' | 'password'>) {
+ return await this.usersRepository.save({
+ ...user,
+ trialEndDate: dayjs.utc().add(TRIAL_DURATION, 'day').format('YYYY-MM-DD HH:mm:ss'),
+ })
}
public async findUserById(id: string) {