feat: login with only name in widget

This commit is contained in:
Tristan Yang
2023-03-15 10:31:44 +08:00
parent f038c683b0
commit 1dfb64bfb6
3 changed files with 10 additions and 12 deletions
+7 -9
View File
@@ -34,12 +34,13 @@ const Login = () => {
}
const data = new FormData(form);
const name = data.get("username") as string;
const email = data.get("email") as string;
console.log("name,email", name, email);
// const email = data.get("email") as string;
console.log("name,email", name);
const randomEmail = `${name}-${(Math.random() + 1).toString(36).substring(7)}@${from}`;
register({
name: `${name}-[${from}]`,
email,
password: email,
name,
email: randomEmail,
password: randomEmail,
});
// const content = new FormData(form).get("prompt") as string;
};
@@ -61,10 +62,7 @@ const Login = () => {
}
}
}, [error]);
if (!loginConfigSuccess) return null;
const {
github: enableGithubLogin,
google: enableGoogleLogin,
@@ -76,7 +74,7 @@ const Login = () => {
<div className="bg-white dark:bg-gray-700 border dark:border-gray-500 rounded-lg">
<form className="px-4 py-3 flex flex-col gap-2" onSubmit={handleSubmit}>
<Input required placeholder="Name" name='username' />
<Input required placeholder="Email" type="email" name='email' />
{/* <Input required placeholder="Email" type="email" name='email' /> */}
<StyledButton disabled={isLoading} type="submit" className={clsx("small", `bg-[${color}] text-[${fgColor}]`)}>Start Chat</StyledButton>
{hasSocialLogins && <Divider content='OR' />}
{googleLogin && <GoogleLoginButton clientId={clientId} />}
+2 -2
View File
@@ -4,7 +4,7 @@ import { useAppSelector } from '../app/store';
import { getContrastColor } from '../common/utils';
const color = decodeURIComponent(new URLSearchParams(location.search).get("themeColor") || "#1fe1f9");
const from = decodeURIComponent(new URLSearchParams(location.search).get("from") || "widget");
const from = decodeURIComponent(new URLSearchParams(location.search).get("from") || "widget.link");
const fgColor = getContrastColor(color);
// 判断是否是iframe上下文
const embed = window.location !== window.parent.location;
@@ -12,7 +12,7 @@ const WidgetContext = createContext({ color, fgColor, embed, from, loading: true
function WidgetProvider({ children }: { children: ReactNode }) {
const { isLoading: loadingServerData, isError } = useGetServerQuery();
const { isLoading: loadingServerData } = useGetServerQuery();
const { isLoading: loadingConfig, data: loginConfig } = useGetLoginConfigQuery();
const serverData = useAppSelector(store => store.server);