ifixkart-admin/Backend/app/utils/Mfa_util.py
Adithiyan bbd3a3e959 feat: initial commit — full platform snapshot
- Backend: FastAPI app with all models, services, schemas, routes
- Admin Panel: Next.js dashboard with all modules
  (CRM, POS, repairs, warranties, billing, notifications, etc.)
- Ecommerce: storefront (submodule) + product catalog
- AI Agents: .agents/ skill library for Antigravity IDE
- Docs: architecture, billing, notification gateway markdown
- Submodules: Backend/OpenWA, Ecommerce/File 2/storefront
2026-10-13 12:59:47 +05:30

22 lines
703 B
Python

import pyotp
import qrcode
from io import BytesIO
import base64
def generate_mfa_secret() -> str:
return pyotp.random_base32()
def get_mfa_uri(email: str, secret: str, issuer: str = "iFixKart") -> str:
return pyotp.totp.TOTP(secret).provisioning_uri(name=email, issuer_name=issuer)
def verify_mfa_token(secret: str, token: str) -> bool:
if not secret or not token:
return False
totp = pyotp.TOTP(secret)
return totp.verify(token, valid_window=1)
def qr_code_png_base64(otpauth_uri: str) -> str:
img = qrcode.make(otpauth_uri)
buffer = BytesIO()
img.save(buffer, format="PNG")
return "data:image/png;base64," + base64.b64encode(buffer.getvalue()).decode()