chore: remove remember me

This commit is contained in:
jialin
2026-06-12 16:02:22 +08:00
committed by jialin
parent 01f66085ab
commit 04e1e1e566
5 changed files with 12 additions and 71 deletions
+1 -4
View File
@@ -32,10 +32,7 @@ export const UpdateCheckAtom = atom<{
latest_version: ''
});
export const initialPasswordAtom = atomWithStorage<string>(
'initialPassword',
''
);
export const initialPasswordAtom = atom<string>('');
// Namespace the server creates for an Org's resources on each Kubernetes
// cluster. The format must match the backend's ``get_namespace_name``
+4 -10
View File
@@ -6,7 +6,7 @@ import {
} from '@ant-design/icons';
import { Input as CInput, HighlightCode, IconFont } from '@gpustack/core-ui';
import { useIntl } from '@umijs/max';
import { Button, Checkbox, Divider, Form, FormInstance } from 'antd';
import { Button, Divider, Form, FormInstance } from 'antd';
import { createStyles } from 'antd-style';
const useStyles = createStyles(({ token, css }) => {
@@ -122,18 +122,12 @@ const LocalUserForm: React.FC<LocalUserFormProps> = (props) => {
/>
</Form.Item>
<div
className="flex-center flex-between"
className="flex-center"
style={{
marginBottom: 24
justifyContent: 'flex-end',
marginBottom: 20
}}
>
<Form.Item noStyle name="autoLogin" valuePropName="checked">
<Checkbox style={{ marginLeft: 5 }}>
<span style={{ color: 'var(--ant-color-text-secondary)' }}>
{intl.formatMessage({ id: 'common.login.rember' })}
</span>
</Checkbox>
</Form.Item>
<Button
type="link"
size="small"
+1 -1
View File
@@ -243,7 +243,7 @@ const LoginForm = () => {
{renderWelCome()}
<div className="spin">
<Spin
tip={intl.formatMessage({ id: 'common.login.auth' })}
description={intl.formatMessage({ id: 'common.login.auth' })}
size="middle"
>
<div style={{ width: 300 }}></div>
+5 -42
View File
@@ -3,8 +3,6 @@ import { clearStorageUserSettings } from '@/atoms/utils';
import {
CRYPT_TEXT,
REMEMBER_ME_KEY,
getRememberMe,
rememberMe,
removeRememberMe
} from '@/utils/localstore/index';
import { FormInstance } from 'antd';
@@ -23,8 +21,7 @@ interface UseLocalAuthOptions {
export const useLocalAuth = ({
fetchUserInfo,
onSuccess,
onError,
form
onError
}: UseLocalAuthOptions) => {
const [initialPassword, setInitialPassword] = useAtom(initialPasswordAtom);
const [submitLoading, setSubmitLoading] = useState<boolean>(false);
@@ -35,35 +32,9 @@ export const useLocalAuth = ({
return psw;
};
const decryptPassword = (password: string) => {
const bytes = CryptoJS.AES?.decrypt?.(password, CRYPT_TEXT);
const res = bytes.toString(CryptoJS.enc.Utf8);
return res;
};
const callGetRememberMe = async () => {
const rememberMe = await getRememberMe(REMEMBER_ME_KEY);
if (rememberMe?.f) {
const username = decryptPassword(rememberMe?.um);
const password = decryptPassword(rememberMe?.pw);
form.setFieldsValue({ username, password, autoLogin: true });
}
};
// remember me
const callRememberMe = async (values: any) => {
const { autoLogin } = values;
if (autoLogin) {
await rememberMe(REMEMBER_ME_KEY, {
um: encryptPassword(values.username),
pw: encryptPassword(values.password),
f: true
});
} else {
await removeRememberMe(REMEMBER_ME_KEY);
}
};
useEffect(() => {
removeRememberMe(REMEMBER_ME_KEY);
}, []);
// click login button
const handleLogin = async (values: any) => {
@@ -75,11 +46,7 @@ export const useLocalAuth = ({
});
const userInfo = await fetchUserInfo();
if (values.autoLogin) {
await callRememberMe(values);
} else {
await removeRememberMe(REMEMBER_ME_KEY);
}
console.log('autoLogin', values.autoLogin);
if (userInfo?.require_password_change) {
setInitialPassword(encryptPassword(values.password));
@@ -93,10 +60,6 @@ export const useLocalAuth = ({
}
};
useEffect(() => {
callGetRememberMe();
}, []);
return {
handleLogin,
submitLoading
+1 -14
View File
@@ -7,18 +7,7 @@ const CRYPT_TEXT = 'seal';
const store = localStore.createInstance({ name: '_xWXJKJ_S1Sna_' });
const rememberMe = (key: string, data: any) => {
if (store) {
store.setItem(key, data);
}
};
const getRememberMe = (key: string) => {
if (store) {
return store.getItem(key);
}
};
// Kept to remove credentials saved by the old "remember me" feature.
const removeRememberMe = (key: string) => {
if (store) {
store.removeItem(key);
@@ -49,10 +38,8 @@ export {
CRYPT_TEXT,
IS_FIRST_LOGIN,
REMEMBER_ME_KEY,
getRememberMe,
readColumnSettings,
readState,
rememberMe,
removeRememberMe,
writeColumnSettings,
writeState