Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion backend/src/auth/two-factor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
UnauthorizedException,
} from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { generateSecret, verify, generateURI } from 'otplib';
import { Repository, IsNull } from 'typeorm';
import { TOTP, generateURI } from 'otplib';
// import { authenticator } from 'otplib';
Expand All @@ -13,6 +15,7 @@ import * as bcrypt from 'bcrypt';
import { Redis } from 'ioredis';
import { User } from '../users/entities/user.entity';
import { TwoFactorRecovery } from '../users/entities/two-factor-recovery.entity';
import { IsNull } from 'typeorm';

const authenticator = new TOTP();

Expand All @@ -33,7 +36,7 @@ export class TwoFactorService {
}

async initiateSetup(userId: number, email: string) {
const secret = authenticator.generateSecret();
const secret = generateSecret();
const appName = 'YieldLadder platform';
const otpauthUrl = generateURI({ secret, issuer: appName, label: email });
const qrCodeDataUrl = await qrcode.toDataURL(otpauthUrl);
Expand Down
3 changes: 3 additions & 0 deletions backend/src/shipments/shipments.analytics.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ function makeUser(overrides: Partial<User> = {}): User {
verificationTokenExpiry: null,
resetPasswordToken: null,
resetPasswordExpiry: null,
isTwoFactorEnabled: false,
twoFactorSecret: '',
recoveryCodes: [],
createdAt: new Date(),
updatedAt: new Date(),
isTwoFactorEnabled: false,
Expand Down
Loading