Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Create a separate usernew model for creating user and use the xxx in the [email protected] as the default name

天舟077def4d7dd0
diff --git a/frontend/src/components/MemberInvite.vue b/frontend/src/components/MemberInvite.vue
index de0f63af53..e592eee1be 100644
--- a/frontend/src/components/MemberInvite.vue
+++ b/frontend/src/components/MemberInvite.vue
@@ -119,7 +119,7 @@
import { computed, reactive } from "vue";
import { useStore } from "vuex";
import RoleSelect from "../components/RoleSelect.vue";
-import { Principal, RoleMappingNew, RoleType } from "../types";
+import { Principal, PrincipalNew, RoleMappingNew, RoleType } from "../types";
import { isValidEmail } from "../utils";
type Invite = {
@@ -216,10 +216,12 @@ export default {
// Note "principal/createPrincipal" would return the existing principal.
// This could happen if another client has just created the principal
// with this email.
+ const newPrincipal: PrincipalNew = {
+ name: invite.email.split("@")[0],
+ email: invite.email,
+ };
store
- .dispatch("principal/createPrincipal", {
- email: invite.email,
- })
+ .dispatch("principal/createPrincipal", newPrincipal)
.then((principal: Principal) => {
const newRoleMapping: RoleMappingNew = {
principalId: principal.id,
diff --git a/frontend/src/miragejs/models/index.js b/frontend/src/miragejs/models/index.js
index 415997af05..1a42c6ad22 100644
--- a/frontend/src/miragejs/models/index.js
+++ b/frontend/src/miragejs/models/index.js
@@ -14,6 +14,8 @@ import { Model, hasMany, belongsTo } from "miragejs";
export default {
user: Model.extend({}),
+ userNew: Model,
+
workspace: Model.extend({
roleMapping: hasMany(),
activity: hasMany(),
diff --git a/frontend/src/store/modules/principal.ts b/frontend/src/store/modules/principal.ts
index 0071c0fb52..d7a5d4c050 100644
--- a/frontend/src/store/modules/principal.ts
+++ b/frontend/src/store/modules/principal.ts
@@ -86,9 +86,10 @@ const actions = {
(
await axios.post(`/api/user`, {
data: {
- type: "user",
+ type: "usernew",
attributes: {
status: "INVITED",
+ name: newPrincipal.name,
email: newPrincipal.email,
password: isDevOrDemo() ? "aaa" : randomString(),
},
diff --git a/frontend/src/types/bytebase.ts b/frontend/src/types/bytebase.ts
index cc63c84c2f..ef1f62ac3f 100644
--- a/frontend/src/types/bytebase.ts
+++ b/frontend/src/types/bytebase.ts
@@ -276,6 +276,7 @@ export type Principal = {
};
export type PrincipalNew = {
+ name: string;
email: string;
};
@@ -290,7 +291,13 @@ export type User = {
name: string;
email: string;
};
-export type NewUser = Omit<User, "id">;
+
+export type NewUser = {
+ status: PrincipalStatus;
+ name: string;
+ email: string;
+ password: string;
+};
// Bookmark
export type Bookmark = {