chore: first login modify password

This commit is contained in:
jialin
2024-06-29 20:29:11 +08:00
parent cf0113e8d8
commit d47e53114c
25 changed files with 337 additions and 113 deletions
+19 -4
View File
@@ -1,13 +1,28 @@
import { useState } from 'react';
import { userAtom } from '@/atoms/user';
import { history } from '@umijs/max';
import { useAtom } from 'jotai';
import { useEffect } from 'react';
import LoginForm from './components/login-form';
import PasswordForm from './components/password-form';
const Login = () => {
const [currentUser, setCurrentUser] = useState(null);
const [userInfo, setUserInfo] = useAtom(userAtom);
const gotoDefaultPage = (userInfo: any) => {
if (!userInfo || userInfo?.require_password_change) {
return;
}
const pathname = userInfo?.is_admin ? '/dashboard' : '/playground';
history.push(pathname, { replace: true });
};
useEffect(() => {
gotoDefaultPage(userInfo);
}, [userInfo]);
return (
<div>
<LoginForm setCurrentUser={setCurrentUser} />
{/* <PasswordForm /> */}
{userInfo?.require_password_change ? <PasswordForm /> : <LoginForm />}
</div>
);
};