Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/feature-flags/add-new-features-to-feature-flags #165

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
1 change: 1 addition & 0 deletions backend/enmedd/server/feature_flags/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class FeatureFlags(BaseModel):
whitelabelling: bool = True
share_chat: bool = False
explore_assistants: bool = False
two_factor_auth: bool = True

def check_validity(self) -> None:
return
1 change: 1 addition & 0 deletions web/src/app/admin/settings/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface FeatureFlags {
whitelabelling: boolean;
share_chat: boolean;
explore_assistants: boolean;
two_factor_auth: boolean;
}

export interface CombinedSettings {
Expand Down
24 changes: 15 additions & 9 deletions web/src/app/auth/login/LoginForms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { basicLogin, basicSignup } from "@/lib/user";
import { Form, Formik } from "formik";
import { useRouter } from "next/navigation";
import * as Yup from "yup";
import { useState } from "react";
import { useContext, useState } from "react";
import { Spinner } from "@/components/Spinner";
import { Button } from "@/components/ui/button";
import { useToast } from "@/hooks/use-toast";
Expand All @@ -16,11 +16,13 @@ import GmailIcon from "../../../../public/Gmail.png";
import MicrosoftIcon from "../../../../public/microsoft.svg";
import Image from "next/image";
import Link from "next/link";
import { SettingsContext } from "@/components/settings/SettingsProvider";

export function LogInForms({}: {}) {
const router = useRouter();
const { toast } = useToast();
const [isLoading, setIsLoading] = useState(false);
const settings = useContext(SettingsContext);

return (
<>
Expand All @@ -39,14 +41,18 @@ export function LogInForms({}: {}) {

const loginResponse = await basicLogin(values.email, values.password);
if (loginResponse.ok) {
router.push(`/auth/2factorverification/?email=${values.email}`);
await fetch("/api/users/generate-otp", {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
credentials: "include",
});
if (settings?.featureFlags.two_factor_auth == true) {
router.push(`/auth/2factorverification/?email=${values.email}`);
await fetch("/api/users/generate-otp", {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
credentials: "include",
});
} else {
router.push("/");
}
} else {
setIsLoading(false);
const errorDetail = (await loginResponse.json()).detail;
Expand Down
Loading