diff --git a/api/src/user/services/invitation.service.ts b/api/src/user/services/invitation.service.ts index f4da2282..69a1cc75 100644 --- a/api/src/user/services/invitation.service.ts +++ b/api/src/user/services/invitation.service.ts @@ -39,10 +39,10 @@ export class InvitationService extends BaseService< @Inject(InvitationRepository) readonly repository: InvitationRepository, @Inject(JwtService) private readonly jwtService: JwtService, - @Optional() private readonly mailerService: MailerService | undefined, private logger: LoggerService, protected readonly i18n: I18nService, public readonly languageService: LanguageService, + @Optional() private readonly mailerService?: MailerService, ) { super(repository); } diff --git a/api/src/user/services/passwordReset.service.ts b/api/src/user/services/passwordReset.service.ts index 704e1a9b..8c5d7991 100644 --- a/api/src/user/services/passwordReset.service.ts +++ b/api/src/user/services/passwordReset.service.ts @@ -32,11 +32,11 @@ import { UserService } from './user.service'; export class PasswordResetService { constructor( @Inject(JwtService) private readonly jwtService: JwtService, - @Optional() private readonly mailerService: MailerService | undefined, private logger: LoggerService, private readonly userService: UserService, public readonly i18n: I18nService, public readonly languageService: LanguageService, + @Optional() private readonly mailerService: MailerService, ) {} public readonly jwtSignOptions: JwtSignOptions = { @@ -105,7 +105,7 @@ export class PasswordResetService { // first step is to check if the token has been used const user = await this.userService.findOne({ email: payload.email }); - if (!user.resetToken || compareSync(user.resetToken, token)) { + if (!user?.resetToken || compareSync(user.resetToken, token)) { throw new UnauthorizedException('Invalid token'); } diff --git a/api/src/user/services/validate-account.service.ts b/api/src/user/services/validate-account.service.ts index c7a7d203..6872ed2e 100644 --- a/api/src/user/services/validate-account.service.ts +++ b/api/src/user/services/validate-account.service.ts @@ -36,10 +36,10 @@ export class ValidateAccountService { constructor( @Inject(JwtService) private readonly jwtService: JwtService, private readonly userService: UserService, - @Optional() private readonly mailerService: MailerService | undefined, private logger: LoggerService, private readonly i18n: I18nService, private readonly languageService: LanguageService, + @Optional() private readonly mailerService?: MailerService, ) {} /**