mirror of
https://github.com/spacebarchat/server.git
synced 2026-05-28 11:54:35 +00:00
Merge remote-tracking branch 'upstream/dev/staging_2' into staging
This commit is contained in:
@@ -14,4 +14,6 @@ export class SecurityConfiguration {
|
||||
// CF-Connecting-IP for cloudflare
|
||||
forwadedFor: string | null = null;
|
||||
ipdataApiKey: string | null = "eca677b284b3bac29eb72f5e496aa9047f26543605efe99ff2ce35c9";
|
||||
mfaBackupCodeCount: number = 10;
|
||||
mfaBackupCodeBytes: number = 4;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import crypto from "crypto";
|
||||
import { Config } from ".";
|
||||
import { BackupCode } from "../entities/BackupCodes";
|
||||
|
||||
export function generateMfaBackupCodes(user_id: string) {
|
||||
let backup_codes: BackupCode[] = [];
|
||||
for (let i = 0; i < 10; i++) {
|
||||
for (let i = 0; i < Config.get().security.mfaBackupCodeCount; i++) {
|
||||
const code = BackupCode.create({
|
||||
user: { id: user_id },
|
||||
code: crypto.randomBytes(4).toString("hex"), // 8 characters
|
||||
code: crypto.randomBytes(Config.get().security.mfaBackupCodeBytes).toString("hex"), // 8 characters
|
||||
consumed: false,
|
||||
expired: false
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user