mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
changes
This commit is contained in:
@@ -20,7 +20,9 @@ const Auth = () => {
|
|||||||
const mode = systemStatus.profile.mode;
|
const mode = systemStatus.profile.mode;
|
||||||
const [username, setUsername] = useState(mode === "demo" ? "demohero" : "");
|
const [username, setUsername] = useState(mode === "demo" ? "demohero" : "");
|
||||||
const [password, setPassword] = useState(mode === "demo" ? "secret" : "");
|
const [password, setPassword] = useState(mode === "demo" ? "secret" : "");
|
||||||
const [identityProviderList, setIdentityProviderList] = useState<IdentityProvider[]>([]);
|
const [identityProviderList, setIdentityProviderList] = useState<
|
||||||
|
IdentityProvider[]
|
||||||
|
>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
userStore.doSignOut().catch();
|
userStore.doSignOut().catch();
|
||||||
@@ -33,12 +35,16 @@ const Auth = () => {
|
|||||||
fetchIdentityProviderList();
|
fetchIdentityProviderList();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleUsernameInputChanged = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleUsernameInputChanged = (
|
||||||
|
e: React.ChangeEvent<HTMLInputElement>
|
||||||
|
) => {
|
||||||
const text = e.target.value as string;
|
const text = e.target.value as string;
|
||||||
setUsername(text);
|
setUsername(text);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handlePasswordInputChanged = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handlePasswordInputChanged = (
|
||||||
|
e: React.ChangeEvent<HTMLInputElement>
|
||||||
|
) => {
|
||||||
const text = e.target.value as string;
|
const text = e.target.value as string;
|
||||||
setPassword(text);
|
setPassword(text);
|
||||||
};
|
};
|
||||||
@@ -63,11 +69,11 @@ const Auth = () => {
|
|||||||
if (user) {
|
if (user) {
|
||||||
window.location.href = "/";
|
window.location.href = "/";
|
||||||
} else {
|
} else {
|
||||||
toastHelper.error(t("message.login-failed"),5000);
|
toastHelper.error(t("message.login-failed"));
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
toastHelper.error(error.response.data.error,5000);
|
toastHelper.error(error.response.data.error);
|
||||||
}
|
}
|
||||||
actionBtnLoadingState.setFinish();
|
actionBtnLoadingState.setFinish();
|
||||||
};
|
};
|
||||||
@@ -99,7 +105,9 @@ const Auth = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSignInWithIdentityProvider = async (identityProvider: IdentityProvider) => {
|
const handleSignInWithIdentityProvider = async (
|
||||||
|
identityProvider: IdentityProvider
|
||||||
|
) => {
|
||||||
const stateQueryParameter = `auth.signin.${identityProvider.name}-${identityProvider.id}`;
|
const stateQueryParameter = `auth.signin.${identityProvider.name}-${identityProvider.id}`;
|
||||||
if (identityProvider.type === "OAUTH2") {
|
if (identityProvider.type === "OAUTH2") {
|
||||||
const redirectUri = absolutifyLink("/auth/callback");
|
const redirectUri = absolutifyLink("/auth/callback");
|
||||||
@@ -119,18 +127,38 @@ const Auth = () => {
|
|||||||
<div className="auth-form-wrapper">
|
<div className="auth-form-wrapper">
|
||||||
<div className="page-header-container">
|
<div className="page-header-container">
|
||||||
<div className="title-container">
|
<div className="title-container">
|
||||||
<img className="logo-img" src={systemStatus.customizedProfile.logoUrl} alt="" />
|
<img
|
||||||
|
className="logo-img"
|
||||||
|
src={systemStatus.customizedProfile.logoUrl}
|
||||||
|
alt=""
|
||||||
|
/>
|
||||||
<p className="logo-text">{systemStatus.customizedProfile.name}</p>
|
<p className="logo-text">{systemStatus.customizedProfile.name}</p>
|
||||||
</div>
|
</div>
|
||||||
<p className="slogan-text">{systemStatus.customizedProfile.description || t("slogan")}</p>
|
<p className="slogan-text">
|
||||||
|
{systemStatus.customizedProfile.description || t("slogan")}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className={`page-content-container ${actionBtnLoadingState.isLoading ? "requesting" : ""}`}>
|
<div
|
||||||
|
className={`page-content-container ${
|
||||||
|
actionBtnLoadingState.isLoading ? "requesting" : ""
|
||||||
|
}`}
|
||||||
|
>
|
||||||
<div className="form-item-container input-form-container">
|
<div className="form-item-container input-form-container">
|
||||||
<span className={`normal-text ${username ? "not-null" : ""}`}>{t("common.username")}</span>
|
<span className={`normal-text ${username ? "not-null" : ""}`}>
|
||||||
<input className="input-text" type="text" value={username} onChange={handleUsernameInputChanged} required />
|
{t("common.username")}
|
||||||
|
</span>
|
||||||
|
<input
|
||||||
|
className="input-text"
|
||||||
|
type="text"
|
||||||
|
value={username}
|
||||||
|
onChange={handleUsernameInputChanged}
|
||||||
|
required
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="form-item-container input-form-container">
|
<div className="form-item-container input-form-container">
|
||||||
<span className={`normal-text ${password ? "not-null" : ""}`}>{t("common.password")}</span>
|
<span className={`normal-text ${password ? "not-null" : ""}`}>
|
||||||
|
{t("common.password")}
|
||||||
|
</span>
|
||||||
<input
|
<input
|
||||||
className="input-text"
|
className="input-text"
|
||||||
type="password"
|
type="password"
|
||||||
@@ -144,22 +172,39 @@ const Auth = () => {
|
|||||||
<div className="action-btns-container">
|
<div className="action-btns-container">
|
||||||
{systemStatus?.host ? (
|
{systemStatus?.host ? (
|
||||||
<>
|
<>
|
||||||
{actionBtnLoadingState.isLoading && <Icon.Loader className="w-4 h-auto mr-2 animate-spin dark:text-gray-300" />}
|
{actionBtnLoadingState.isLoading && (
|
||||||
|
<Icon.Loader className="w-4 h-auto mr-2 animate-spin dark:text-gray-300" />
|
||||||
|
)}
|
||||||
{systemStatus?.allowSignUp && (
|
{systemStatus?.allowSignUp && (
|
||||||
<>
|
<>
|
||||||
<button className={`btn-text ${actionBtnLoadingState.isLoading ? "requesting" : ""}`} onClick={handleSignUpBtnsClick}>
|
<button
|
||||||
|
className={`btn-text ${
|
||||||
|
actionBtnLoadingState.isLoading ? "requesting" : ""
|
||||||
|
}`}
|
||||||
|
onClick={handleSignUpBtnsClick}
|
||||||
|
>
|
||||||
{t("common.sign-up")}
|
{t("common.sign-up")}
|
||||||
</button>
|
</button>
|
||||||
<span className="mr-2 font-mono text-gray-200">/</span>
|
<span className="mr-2 font-mono text-gray-200">/</span>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<button className={`btn-primary ${actionBtnLoadingState.isLoading ? "requesting" : ""}`} onClick={handleSignInBtnClick}>
|
<button
|
||||||
|
className={`btn-primary ${
|
||||||
|
actionBtnLoadingState.isLoading ? "requesting" : ""
|
||||||
|
}`}
|
||||||
|
onClick={handleSignInBtnClick}
|
||||||
|
>
|
||||||
{t("common.sign-in")}
|
{t("common.sign-in")}
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<button className={`btn-primary ${actionBtnLoadingState.isLoading ? "requesting" : ""}`} onClick={handleSignUpBtnsClick}>
|
<button
|
||||||
|
className={`btn-primary ${
|
||||||
|
actionBtnLoadingState.isLoading ? "requesting" : ""
|
||||||
|
}`}
|
||||||
|
onClick={handleSignUpBtnsClick}
|
||||||
|
>
|
||||||
{t("auth.signup-as-host")}
|
{t("auth.signup-as-host")}
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
@@ -176,7 +221,9 @@ const Auth = () => {
|
|||||||
color="neutral"
|
color="neutral"
|
||||||
className="w-full"
|
className="w-full"
|
||||||
size="md"
|
size="md"
|
||||||
onClick={() => handleSignInWithIdentityProvider(identityProvider)}
|
onClick={() =>
|
||||||
|
handleSignInWithIdentityProvider(identityProvider)
|
||||||
|
}
|
||||||
>
|
>
|
||||||
Sign in with {identityProvider.name}
|
Sign in with {identityProvider.name}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -184,11 +231,16 @@ const Auth = () => {
|
|||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{!systemStatus?.host && <p className="tip-text">{t("auth.host-tip")}</p>}
|
{!systemStatus?.host && (
|
||||||
|
<p className="tip-text">{t("auth.host-tip")}</p>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-row items-center justify-center w-full gap-2">
|
<div className="flex flex-row items-center justify-center w-full gap-2">
|
||||||
<LocaleSelect value={locale} onChange={handleLocaleSelectChange} />
|
<LocaleSelect value={locale} onChange={handleLocaleSelectChange} />
|
||||||
<AppearanceSelect value={appearance} onChange={handleAppearanceSelectChange} />
|
<AppearanceSelect
|
||||||
|
value={appearance}
|
||||||
|
onChange={handleAppearanceSelectChange}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user