feat: login with only name in widget
This commit is contained in:
+1
-1
@@ -20,7 +20,7 @@ const styles = {
|
||||
Object.assign(wrapper.style, styles);
|
||||
wrapper.src = `${new URL(_src).origin}/widget.html?host=${hostId}&themeColor=${encodeURIComponent(
|
||||
themeColor
|
||||
)}&from=${encodeURIComponent(location.host)}`;
|
||||
)}&from=${encodeURIComponent(location.hostname)}`;
|
||||
wrapper.width = closeWidth;
|
||||
wrapper.height = closeHeight;
|
||||
wrapper.frameborder = 0;
|
||||
|
||||
@@ -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} />}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user