feat: add support for remember sign in (#2402)

This commit is contained in:
Athurg Gooth
2023-10-19 09:38:49 +08:00
committed by GitHub
parent 37601e5d03
commit 0bfcff676c
5 changed files with 17 additions and 4 deletions

View File

@ -1,4 +1,4 @@
import { Button, Divider, Input } from "@mui/joy";
import { Button, Checkbox, Divider, Input } from "@mui/joy";
import { useEffect, useState } from "react";
import { toast } from "react-hot-toast";
import { Link } from "react-router-dom";
@ -19,6 +19,7 @@ const SignIn = () => {
const mode = systemStatus.profile.mode;
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
const [remember, setRemember] = useState(true);
const disablePasswordLogin = systemStatus.disablePasswordLogin;
const [identityProviderList, setIdentityProviderList] = useState<IdentityProvider[]>([]);
@ -71,7 +72,7 @@ const SignIn = () => {
try {
actionBtnLoadingState.setLoading();
await api.signin(username, password);
await api.signin(username, password, remember);
const user = await userStore.doSignIn();
if (user) {
window.location.href = "/";
@ -138,6 +139,9 @@ const SignIn = () => {
/>
</div>
</div>
<div className="flex flex-row justify-start items-center w-full mt-6">
<Checkbox label={t("common.remember-me")} checked={remember} onChange={(e) => setRemember(e.target.checked)} />
</div>
<div className="flex flex-row justify-end items-center w-full mt-6">
<Button
className="w-full"