mirror of
https://github.com/usememos/memos.git
synced 2024-12-18 16:41:44 +03:00
chore: migrate create user
This commit is contained in:
parent
c0b5070e46
commit
c0628ef95b
@ -1,9 +1,11 @@
|
||||
import { Button, Dropdown, Input, Menu, MenuButton } from "@mui/joy";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { toast } from "react-hot-toast";
|
||||
import { userServiceClient } from "@/grpcweb";
|
||||
import * as api from "@/helpers/api";
|
||||
import { useUserStore } from "@/store/module";
|
||||
import { UserNamePrefix } from "@/store/v1";
|
||||
import { User_Role } from "@/types/proto/api/v2/user_service";
|
||||
import { useTranslate } from "@/utils/i18n";
|
||||
import showChangeMemberPasswordDialog from "../ChangeMemberPasswordDialog";
|
||||
import { showCommonDialog } from "../Dialog/CommonDialog";
|
||||
@ -53,16 +55,16 @@ const MemberSection = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
const userCreate: UserCreate = {
|
||||
username: state.createUserUsername,
|
||||
password: state.createUserPassword,
|
||||
role: "USER",
|
||||
};
|
||||
|
||||
try {
|
||||
await api.createUser(userCreate);
|
||||
await userServiceClient.createUser({
|
||||
user: {
|
||||
name: `${UserNamePrefix}${state.createUserUsername}`,
|
||||
password: state.createUserPassword,
|
||||
role: User_Role.USER,
|
||||
},
|
||||
});
|
||||
} catch (error: any) {
|
||||
toast.error(error.response.data.message);
|
||||
toast.error(error.details);
|
||||
}
|
||||
await fetchUserList();
|
||||
setState({
|
||||
|
@ -44,10 +44,6 @@ export function signout() {
|
||||
return axios.post("/api/v1/auth/signout");
|
||||
}
|
||||
|
||||
export function createUser(userCreate: UserCreate) {
|
||||
return axios.post<User>("/api/v1/user", userCreate);
|
||||
}
|
||||
|
||||
export function getMyselfUser() {
|
||||
return axios.get<User>("/api/v1/user/me");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user