def diag_login(req): if "password" in req.POST: if hashlib.sha512(req.POST["password"].encode("utf-8")).hexdigest( ).upper() == DIAG_AUTH_PASSWORD and TOTP.Get( DIAG_AUTH_TOTP_SECRET) == int(req.POST["totp"]): DiagnosticsUser.Authorize(req) return redirect("diagnostics_dashboard") return render(req, "diag/login.html")
def authWrapper(req, *args, **kwargs): if not DiagnosticsUser.IsAuthenticated(req): return redirect("diagnostics_login") return view(req, *args, **kwargs)