Refactor: Implement DashboardLayout, fix mobile nav, and resolve scroll issues

This commit is contained in:
ren
2026-01-29 14:41:46 +01:00
parent 0a04e0817d
commit 811c78ffa5
171 changed files with 1678 additions and 23983 deletions

39
lib/otp.ts Normal file
View File

@@ -0,0 +1,39 @@
import fs from 'fs';
import path from 'path';
const OTP_FILE = path.join(process.cwd(), 'auth-otp.json');
interface OTPData {
code: string;
expiresAt: number;
}
export function generateOTP(): string {
return Math.floor(100000 + Math.random() * 900000).toString();
}
export function saveOTP(code: string) {
const data: OTPData = {
code,
expiresAt: Date.now() + 5 * 60 * 1000 // 5 minutes
};
try {
fs.writeFileSync(OTP_FILE, JSON.stringify(data));
} catch (err) {
console.error("Error saving OTP:", err);
}
}
export function verifyOTP(code: string): boolean {
if (!fs.existsSync(OTP_FILE)) return false;
try {
const data: OTPData = JSON.parse(fs.readFileSync(OTP_FILE, 'utf8'));
if (Date.now() > data.expiresAt) return false;
// Simple check
return String(data.code).trim() === String(code).trim();
} catch (e) {
console.error("Error verifying OTP:", e);
return false;
}
}