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: '' latest_version: ''
}); });
export const initialPasswordAtom = atomWithStorage<string>( export const initialPasswordAtom = atom<string>('');
'initialPassword',
''
);
// Namespace the server creates for an Org's resources on each Kubernetes // Namespace the server creates for an Org's resources on each Kubernetes
// cluster. The format must match the backend's ``get_namespace_name`` // cluster. The format must match the backend's ``get_namespace_name``
+4 -10
View File
@@ -6,7 +6,7 @@ import {
} from '@ant-design/icons'; } from '@ant-design/icons';
import { Input as CInput, HighlightCode, IconFont } from '@gpustack/core-ui'; import { Input as CInput, HighlightCode, IconFont } from '@gpustack/core-ui';
import { useIntl } from '@umijs/max'; 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'; import { createStyles } from 'antd-style';
const useStyles = createStyles(({ token, css }) => { const useStyles = createStyles(({ token, css }) => {
@@ -122,18 +122,12 @@ const LocalUserForm: React.FC<LocalUserFormProps> = (props) => {
/> />
</Form.Item> </Form.Item>
<div <div
className="flex-center flex-between" className="flex-center"
style={{ 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 <Button
type="link" type="link"
size="small" size="small"
+1 -1
View File
@@ -243,7 +243,7 @@ const LoginForm = () => {
{renderWelCome()} {renderWelCome()}
<div className="spin"> <div className="spin">
<Spin <Spin
tip={intl.formatMessage({ id: 'common.login.auth' })} description={intl.formatMessage({ id: 'common.login.auth' })}
size="middle" size="middle"
> >
<div style={{ width: 300 }}></div> <div style={{ width: 300 }}></div>
+5 -42
View File
@@ -3,8 +3,6 @@ import { clearStorageUserSettings } from '@/atoms/utils';
import { import {
CRYPT_TEXT, CRYPT_TEXT,
REMEMBER_ME_KEY, REMEMBER_ME_KEY,
getRememberMe,
rememberMe,
removeRememberMe removeRememberMe
} from '@/utils/localstore/index'; } from '@/utils/localstore/index';
import { FormInstance } from 'antd'; import { FormInstance } from 'antd';
@@ -23,8 +21,7 @@ interface UseLocalAuthOptions {
export const useLocalAuth = ({ export const useLocalAuth = ({
fetchUserInfo, fetchUserInfo,
onSuccess, onSuccess,
onError, onError
form
}: UseLocalAuthOptions) => { }: UseLocalAuthOptions) => {
const [initialPassword, setInitialPassword] = useAtom(initialPasswordAtom); const [initialPassword, setInitialPassword] = useAtom(initialPasswordAtom);
const [submitLoading, setSubmitLoading] = useState<boolean>(false); const [submitLoading, setSubmitLoading] = useState<boolean>(false);
@@ -35,35 +32,9 @@ export const useLocalAuth = ({
return psw; return psw;
}; };
const decryptPassword = (password: string) => { useEffect(() => {
const bytes = CryptoJS.AES?.decrypt?.(password, CRYPT_TEXT); removeRememberMe(REMEMBER_ME_KEY);
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);
}
};
// click login button // click login button
const handleLogin = async (values: any) => { const handleLogin = async (values: any) => {
@@ -75,11 +46,7 @@ export const useLocalAuth = ({
}); });
const userInfo = await fetchUserInfo(); const userInfo = await fetchUserInfo();
if (values.autoLogin) { console.log('autoLogin', values.autoLogin);
await callRememberMe(values);
} else {
await removeRememberMe(REMEMBER_ME_KEY);
}
if (userInfo?.require_password_change) { if (userInfo?.require_password_change) {
setInitialPassword(encryptPassword(values.password)); setInitialPassword(encryptPassword(values.password));
@@ -93,10 +60,6 @@ export const useLocalAuth = ({
} }
}; };
useEffect(() => {
callGetRememberMe();
}, []);
return { return {
handleLogin, handleLogin,
submitLoading submitLoading
+1 -14
View File
@@ -7,18 +7,7 @@ const CRYPT_TEXT = 'seal';
const store = localStore.createInstance({ name: '_xWXJKJ_S1Sna_' }); const store = localStore.createInstance({ name: '_xWXJKJ_S1Sna_' });
const rememberMe = (key: string, data: any) => { // Kept to remove credentials saved by the old "remember me" feature.
if (store) {
store.setItem(key, data);
}
};
const getRememberMe = (key: string) => {
if (store) {
return store.getItem(key);
}
};
const removeRememberMe = (key: string) => { const removeRememberMe = (key: string) => {
if (store) { if (store) {
store.removeItem(key); store.removeItem(key);
@@ -49,10 +38,8 @@ export {
CRYPT_TEXT, CRYPT_TEXT,
IS_FIRST_LOGIN, IS_FIRST_LOGIN,
REMEMBER_ME_KEY, REMEMBER_ME_KEY,
getRememberMe,
readColumnSettings, readColumnSettings,
readState, readState,
rememberMe,
removeRememberMe, removeRememberMe,
writeColumnSettings, writeColumnSettings,
writeState writeState