mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-06-14 18:10:58 +02:00
updated logic
This commit is contained in:
parent
c2447dbb1c
commit
680ab9ea30
@ -26,8 +26,6 @@ const ForgotPasswordPage: React.FC = () => {
|
|||||||
return (
|
return (
|
||||||
<AuthFlowContainer>
|
<AuthFlowContainer>
|
||||||
<div className="flex flex-col w-full justify-center">
|
<div className="flex flex-col w-full justify-center">
|
||||||
<CardSection className="mt-4 w-full">
|
|
||||||
{" "}
|
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
<Title className="mb-2 mx-auto font-bold">Forgot Password</Title>
|
<Title className="mb-2 mx-auto font-bold">Forgot Password</Title>
|
||||||
</div>
|
</div>
|
||||||
@ -46,8 +44,7 @@ const ForgotPasswordPage: React.FC = () => {
|
|||||||
await forgotPassword(values.email);
|
await forgotPassword(values.email);
|
||||||
setPopup({
|
setPopup({
|
||||||
type: "success",
|
type: "success",
|
||||||
message:
|
message: "Password reset email sent. Please check your inbox.",
|
||||||
"Password reset email sent. Please check your inbox.",
|
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMessage =
|
const errorMessage =
|
||||||
@ -91,7 +88,6 @@ const ForgotPasswordPage: React.FC = () => {
|
|||||||
</Link>
|
</Link>
|
||||||
</Text>
|
</Text>
|
||||||
</div>
|
</div>
|
||||||
</CardSection>
|
|
||||||
</div>
|
</div>
|
||||||
</AuthFlowContainer>
|
</AuthFlowContainer>
|
||||||
);
|
);
|
||||||
|
@ -12,6 +12,7 @@ import { Spinner } from "@/components/Spinner";
|
|||||||
import { set } from "lodash";
|
import { set } from "lodash";
|
||||||
import { NEXT_PUBLIC_FORGOT_PASSWORD_ENABLED } from "@/lib/constants";
|
import { NEXT_PUBLIC_FORGOT_PASSWORD_ENABLED } from "@/lib/constants";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import { useUser } from "@/components/user/UserProvider";
|
||||||
|
|
||||||
export function EmailPasswordForm({
|
export function EmailPasswordForm({
|
||||||
isSignup = false,
|
isSignup = false,
|
||||||
@ -24,6 +25,7 @@ export function EmailPasswordForm({
|
|||||||
referralSource?: string;
|
referralSource?: string;
|
||||||
nextUrl?: string | null;
|
nextUrl?: string | null;
|
||||||
}) {
|
}) {
|
||||||
|
const { user } = useUser();
|
||||||
const { popup, setPopup } = usePopup();
|
const { popup, setPopup } = usePopup();
|
||||||
const [isWorking, setIsWorking] = useState(false);
|
const [isWorking, setIsWorking] = useState(false);
|
||||||
return (
|
return (
|
||||||
@ -116,24 +118,29 @@ export function EmailPasswordForm({
|
|||||||
name="password"
|
name="password"
|
||||||
label="Password"
|
label="Password"
|
||||||
type="password"
|
type="password"
|
||||||
|
includeForgotPassword={
|
||||||
|
NEXT_PUBLIC_FORGOT_PASSWORD_ENABLED && !isSignup
|
||||||
|
}
|
||||||
placeholder="**************"
|
placeholder="**************"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{NEXT_PUBLIC_FORGOT_PASSWORD_ENABLED && !isSignup && (
|
|
||||||
<Link
|
|
||||||
href="/auth/forgot-password"
|
|
||||||
className="text-sm text-link font-medium whitespace-nowrap"
|
|
||||||
>
|
|
||||||
Forgot Password?
|
|
||||||
</Link>
|
|
||||||
)}
|
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
className="mx-auto w-full"
|
className="mx-auto !py-4 w-full"
|
||||||
>
|
>
|
||||||
{isSignup ? "Sign Up" : "Log In"}
|
{isSignup ? "Sign Up" : "Log In"}
|
||||||
</Button>
|
</Button>
|
||||||
|
{user?.is_anonymous_user && (
|
||||||
|
<Link
|
||||||
|
href="/chat"
|
||||||
|
className="text-xs text-blue-500 cursor-pointer text-center w-full text-link font-medium mx-auto"
|
||||||
|
>
|
||||||
|
<span className="hover:border-b hover:border-dotted hover:border-blue-500">
|
||||||
|
or continue as guest
|
||||||
|
</span>
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
</Form>
|
</Form>
|
||||||
)}
|
)}
|
||||||
</Formik>
|
</Formik>
|
||||||
|
@ -77,7 +77,8 @@ const Page = async (props: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthFlowContainer>
|
<div className="flex flex-col ">
|
||||||
|
<AuthFlowContainer authState="login">
|
||||||
<div className="absolute top-10x w-full">
|
<div className="absolute top-10x w-full">
|
||||||
<HealthCheckBanner />
|
<HealthCheckBanner />
|
||||||
</div>
|
</div>
|
||||||
@ -128,14 +129,18 @@ const Page = async (props: {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{authTypeMetadata?.authType === "basic" && (
|
{authTypeMetadata?.authType === "basic" && (
|
||||||
<CardSection className="mt-4 w-96">
|
<>
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
<Title className="mb-2 mx-auto font-bold">
|
<Title className="mb-2 mx-auto text-xl text-strong font-bold">
|
||||||
<LoginText />
|
<LoginText />
|
||||||
</Title>
|
</Title>
|
||||||
</div>
|
</div>
|
||||||
<EmailPasswordForm nextUrl={nextUrl} />
|
<EmailPasswordForm nextUrl={nextUrl} />
|
||||||
<div className="flex flex-col gap-y-2 items-center">
|
<div className="flex flex-col gap-y-2 items-center"></div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</AuthFlowContainer>
|
||||||
<Text className="mt-4 ">
|
<Text className="mt-4 ">
|
||||||
Don't have an account?{" "}
|
Don't have an account?{" "}
|
||||||
<Link
|
<Link
|
||||||
@ -148,27 +153,6 @@ const Page = async (props: {
|
|||||||
</Link>
|
</Link>
|
||||||
</Text>
|
</Text>
|
||||||
</div>
|
</div>
|
||||||
</CardSection>
|
|
||||||
)}
|
|
||||||
{currentUser?.is_anonymous_user && (
|
|
||||||
<div className="mt-4 w-full justify-center">
|
|
||||||
<Text className="mt-4 mx-auto">
|
|
||||||
You are currently logged in as an anonymous user. You can access
|
|
||||||
the chat experience{" "}
|
|
||||||
<Link
|
|
||||||
href={`/auth/login${
|
|
||||||
searchParams?.next ? `?next=${searchParams.next}` : ""
|
|
||||||
}`}
|
|
||||||
className="text-link font-medium"
|
|
||||||
>
|
|
||||||
here
|
|
||||||
</Link>
|
|
||||||
.
|
|
||||||
</Text>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</AuthFlowContainer>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@ const ResetPasswordPage: React.FC = () => {
|
|||||||
return (
|
return (
|
||||||
<AuthFlowContainer>
|
<AuthFlowContainer>
|
||||||
<div className="flex flex-col w-full justify-center">
|
<div className="flex flex-col w-full justify-center">
|
||||||
<CardSection className="mt-4 w-full">
|
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
<Title className="mb-2 mx-auto font-bold">Reset Password</Title>
|
<Title className="mb-2 mx-auto font-bold">Reset Password</Title>
|
||||||
</div>
|
</div>
|
||||||
@ -58,8 +57,7 @@ const ResetPasswordPage: React.FC = () => {
|
|||||||
await resetPassword(token, values.password);
|
await resetPassword(token, values.password);
|
||||||
setPopup({
|
setPopup({
|
||||||
type: "success",
|
type: "success",
|
||||||
message:
|
message: "Password reset successfully. Redirecting to login...",
|
||||||
"Password reset successfully. Redirecting to login...",
|
|
||||||
});
|
});
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
redirect("/auth/login");
|
redirect("/auth/login");
|
||||||
@ -108,7 +106,6 @@ const ResetPasswordPage: React.FC = () => {
|
|||||||
</Link>
|
</Link>
|
||||||
</Text>
|
</Text>
|
||||||
</div>
|
</div>
|
||||||
</CardSection>
|
|
||||||
</div>
|
</div>
|
||||||
</AuthFlowContainer>
|
</AuthFlowContainer>
|
||||||
);
|
);
|
||||||
|
@ -61,7 +61,7 @@ const Page = async (props: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthFlowContainer>
|
<AuthFlowContainer authState="signup">
|
||||||
<HealthCheckBanner />
|
<HealthCheckBanner />
|
||||||
|
|
||||||
<>
|
<>
|
||||||
@ -94,21 +94,6 @@ const Page = async (props: {
|
|||||||
shouldVerify={authTypeMetadata?.requiresVerification}
|
shouldVerify={authTypeMetadata?.requiresVerification}
|
||||||
nextUrl={nextUrl}
|
nextUrl={nextUrl}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="flex">
|
|
||||||
<Text className="mt-4 mx-auto">
|
|
||||||
Already have an account?{" "}
|
|
||||||
<Link
|
|
||||||
href={{
|
|
||||||
pathname: "/auth/login",
|
|
||||||
query: { ...searchParams },
|
|
||||||
}}
|
|
||||||
className="text-link font-medium"
|
|
||||||
>
|
|
||||||
Log In
|
|
||||||
</Link>
|
|
||||||
</Text>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
</AuthFlowContainer>
|
</AuthFlowContainer>
|
||||||
|
@ -29,6 +29,7 @@ import { useRef, useState } from "react";
|
|||||||
import remarkGfm from "remark-gfm";
|
import remarkGfm from "remark-gfm";
|
||||||
import { EditIcon } from "@/components/icons/icons";
|
import { EditIcon } from "@/components/icons/icons";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
import Link from "next/link";
|
||||||
|
|
||||||
export function SectionHeader({
|
export function SectionHeader({
|
||||||
children,
|
children,
|
||||||
@ -143,6 +144,7 @@ export function TextFormField({
|
|||||||
small,
|
small,
|
||||||
removeLabel,
|
removeLabel,
|
||||||
min,
|
min,
|
||||||
|
includeForgotPassword,
|
||||||
onChange,
|
onChange,
|
||||||
width,
|
width,
|
||||||
vertical,
|
vertical,
|
||||||
@ -169,6 +171,7 @@ export function TextFormField({
|
|||||||
explanationLink?: string;
|
explanationLink?: string;
|
||||||
small?: boolean;
|
small?: boolean;
|
||||||
min?: number;
|
min?: number;
|
||||||
|
includeForgotPassword?: boolean;
|
||||||
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
||||||
width?: string;
|
width?: string;
|
||||||
vertical?: boolean;
|
vertical?: boolean;
|
||||||
@ -238,7 +241,7 @@ export function TextFormField({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{subtext && <SubLabel>{subtext}</SubLabel>}
|
{subtext && <SubLabel>{subtext}</SubLabel>}
|
||||||
<div className={`w-full flex ${includeRevert && "gap-x-2"}`}>
|
<div className={`w-full flex ${includeRevert && "gap-x-2"} relative`}>
|
||||||
<Field
|
<Field
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
min={min}
|
min={min}
|
||||||
@ -269,6 +272,14 @@ export function TextFormField({
|
|||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
autoComplete={autoCompleteDisabled ? "off" : undefined}
|
autoComplete={autoCompleteDisabled ? "off" : undefined}
|
||||||
/>
|
/>
|
||||||
|
{includeForgotPassword && (
|
||||||
|
<Link
|
||||||
|
href="/auth/forgot-password"
|
||||||
|
className="absolute right-3 top-1/2 mt-[3px] transform -translate-y-1/2 text-xs text-blue-500 cursor-pointer"
|
||||||
|
>
|
||||||
|
Forgot password?
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{explanationText && (
|
{explanationText && (
|
||||||
|
@ -1,16 +1,41 @@
|
|||||||
|
import Link from "next/link";
|
||||||
import { Logo } from "../logo/Logo";
|
import { Logo } from "../logo/Logo";
|
||||||
|
|
||||||
export default function AuthFlowContainer({
|
export default function AuthFlowContainer({
|
||||||
children,
|
children,
|
||||||
|
authState,
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
authState?: "signup" | "login";
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center justify-center min-h-screen bg-background">
|
<div className="p-4 flex flex-col items-center justify-center min-h-screen bg-background">
|
||||||
<div className="w-full max-w-md bg-black pt-8 pb-4 px-8 mx-4 gap-y-4 bg-white flex items-center flex-col rounded-xl shadow-lg border border-bacgkround-100">
|
<div className="w-full max-w-md bg-black pt-8 pb-6 px-8 mx-4 gap-y-4 bg-white flex items-center flex-col rounded-xl shadow-lg border border-bacgkround-100">
|
||||||
<Logo width={70} height={70} />
|
<Logo width={70} height={70} />
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
|
{authState === "login" && (
|
||||||
|
<div className="text-sm mt-4 text-center w-full text-neutral-900 font-medium mx-auto">
|
||||||
|
Don't have an account?{" "}
|
||||||
|
<Link
|
||||||
|
href="/auth/signup"
|
||||||
|
className=" underline transition-colors duration-200"
|
||||||
|
>
|
||||||
|
Create one
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{authState === "signup" && (
|
||||||
|
<div className="text-sm mt-4 text-center w-full text-neutral-900 font-medium mx-auto">
|
||||||
|
Already have an account?{" "}
|
||||||
|
<Link
|
||||||
|
href="/auth/login"
|
||||||
|
className=" underline transition-colors duration-200"
|
||||||
|
>
|
||||||
|
Log In
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user