chore: remove username field from user table

This commit is contained in:
Steven
2023-06-23 01:01:22 +08:00
parent 8dfae8a6aa
commit 2aae515544
11 changed files with 52 additions and 78 deletions

View File

@ -4,16 +4,16 @@ export function getSystemStatus() {
return axios.get<SystemStatus>("/api/v1/status");
}
export function signin(username: string, password: string) {
export function signin(email: string, password: string) {
return axios.post<User>("/api/v1/auth/signin", {
username,
email,
password,
});
}
export function signup(username: string, password: string) {
export function signup(email: string, password: string) {
return axios.post<User>("/api/v1/auth/signup", {
username,
email,
password,
});
}

View File

@ -9,7 +9,7 @@ import Icon from "../components/Icon";
const Auth: React.FC = () => {
const navigate = useNavigate();
const [username, setUsername] = useState("");
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const actionBtnLoadingState = useLoading(false);
@ -20,9 +20,9 @@ const Auth: React.FC = () => {
}
}, []);
const handleUsernameInputChanged = (e: React.ChangeEvent<HTMLInputElement>) => {
const handleEmailInputChanged = (e: React.ChangeEvent<HTMLInputElement>) => {
const text = e.target.value as string;
setUsername(text);
setEmail(text);
};
const handlePasswordInputChanged = (e: React.ChangeEvent<HTMLInputElement>) => {
@ -37,7 +37,7 @@ const Auth: React.FC = () => {
try {
actionBtnLoadingState.setLoading();
await api.signin(username, password);
await api.signin(email, password);
const user = await userService.doSignIn();
if (user) {
navigate("/", {
@ -60,7 +60,7 @@ const Auth: React.FC = () => {
try {
actionBtnLoadingState.setLoading();
await api.signup(username, password);
await api.signup(email, password);
const user = await userService.doSignIn();
if (user) {
navigate("/", {
@ -89,8 +89,8 @@ const Auth: React.FC = () => {
</div>
<div className={`flex flex-col justify-start items-start w-full ${actionBtnLoadingState.isLoading ? "opacity-80" : ""}`}>
<div className="w-full flex flex-col mb-2">
<span className="leading-8 mb-1 text-gray-600">Username</span>
<Input className="w-full py-3" type="username" value={username} onChange={handleUsernameInputChanged} />
<span className="leading-8 mb-1 text-gray-600">Email</span>
<Input className="w-full py-3" type="email" value={email} onChange={handleEmailInputChanged} />
</div>
<div className="w-full flex flex-col mb-2">
<span className="leading-8 text-gray-600">Password</span>

View File

@ -16,13 +16,11 @@ const UserDetail: React.FC = () => {
showChangePasswordDialog: false,
});
console.log("here");
useEffect(() => {
if (!userService.getState().user) {
navigate("/user/auth");
return;
}
console.log("here");
}, []);
const handleChangePasswordBtnClick = async () => {

View File

@ -9,9 +9,8 @@ interface User {
updatedTs: TimeStamp;
rowStatus: RowStatus;
username: string;
nickname: string;
email: string;
nickname: string;
role: Role;
}