Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: add dedicated UpdateEmail API with bb.users.updateEmail permission (#18415)
Danny Xu03a04b3817e5
diff --git a/backend/api/v1/user_service.go b/backend/api/v1/user_service.goindex a9e3994074..1872dc2d4b 100644--- a/backend/api/v1/user_service.go+++ b/backend/api/v1/user_service.go@@ -382,17 +382,8 @@ func (s *UserService) UpdateUser(ctx context.Context, request *connect.Request[vfor _, path := range request.Msg.UpdateMask.Paths {switch path {case "email":- if err := validateEmailWithDomains(ctx, s.licenseService, s.store, request.Msg.User.Email, user.Type == storepb.PrincipalType_SERVICE_ACCOUNT, false); err != nil {- return nil, err- }- existedUser, err := s.store.GetUserByEmail(ctx, request.Msg.User.Email)- if err != nil {- return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to find user list, error: %v", err))- }- if existedUser != nil && existedUser.ID != user.ID {- return nil, connect.NewError(connect.CodeAlreadyExists, errors.Errorf("email %s is already existed", request.Msg.User.Email))- }- patch.Email = &request.Msg.User.Email+ // Email updates are not supported through UpdateUser. Use UpdateEmail API instead.+ return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("email updates are not supported through UpdateUser, use UpdateEmail API instead"))case "title":patch.Name = &request.Msg.User.Titlecase "password":@@ -662,6 +653,64 @@ func (s *UserService) UndeleteUser(ctx context.Context, request *connect.Requestreturn connect.NewResponse(convertToUser(ctx, user)), nil}+// UpdateEmail updates a user's email address.+func (s *UserService) UpdateEmail(ctx context.Context, request *connect.Request[v1pb.UpdateEmailRequest]) (*connect.Response[v1pb.User], error) {+ callerUser, ok := GetUserFromContext(ctx)+ if !ok {+ return nil, connect.NewError(connect.CodePermissionDenied, errors.Errorf("failed to get caller user"))+ }+ ok, err := s.iamManager.CheckPermission(ctx, iam.PermissionUsersUpdateEmail, callerUser)+ if err != nil {+ return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to check permission with error: %v", err.Error()))+ }+ if !ok {+ return nil, connect.NewError(connect.CodePermissionDenied, errors.Errorf("user does not have permission %q", iam.PermissionUsersUpdateEmail))+ }++ // Get user by email from the name field+ email, err := common.GetUserEmail(request.Msg.Name)+ if err != nil {+ return nil, connect.NewError(connect.CodeInvalidArgument, err)+ }+ user, err := s.store.GetUserByEmail(ctx, email)+ if err != nil {+ return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to get user, error: %v", err))+ }+ if user == nil {+ return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("user not found"))+ }+ if user.MemberDeleted {+ return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("user has been deleted"))+ }++ // Check if new email is the same as current email (no-op)+ if user.Email == request.Msg.Email {+ return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("new email is the same as current email"))+ }++ // Validate email format and domain restrictions+ if err := validateEmailWithDomains(ctx, s.licenseService, s.store, request.Msg.Email, user.Type == storepb.PrincipalType_SERVICE_ACCOUNT, false); err != nil {+ return nil, err+ }++ // Check if email already exists+ existedUser, err := s.store.GetUserByEmail(ctx, request.Msg.Email)+ if err != nil {+ return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to find user by email, error: %v", err))+ }+ if existedUser != nil && existedUser.ID != user.ID {+ return nil, connect.NewError(connect.CodeAlreadyExists, errors.Errorf("email %s already exists", request.Msg.Email))+ }++ // Update the email+ user, err = s.store.UpdateUser(ctx, user, &store.UpdateUserMessage{Email: &request.Msg.Email})+ if err != nil {+ return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to update user email, error: %v", err))+ }++ return connect.NewResponse(convertToUser(ctx, user)), nil+}+func convertToV1UserType(userType storepb.PrincipalType) v1pb.UserType {switch userType {case storepb.PrincipalType_END_USER:diff --git a/backend/component/iam/acl.yaml b/backend/component/iam/acl.yamlindex b592a3b4d1..311a2fe403 100644--- a/backend/component/iam/acl.yaml+++ b/backend/component/iam/acl.yaml@@ -112,6 +112,7 @@ roles:- bb.users.list- bb.users.undelete- bb.users.update+ - bb.users.updateEmail- bb.worksheets.get- bb.worksheets.manage- bb.workspaces.getIamPolicydiff --git a/backend/component/iam/permission.go b/backend/component/iam/permission.goindex 5dac5c65cb..775985a964 100644--- a/backend/component/iam/permission.go+++ b/backend/component/iam/permission.go@@ -113,6 +113,7 @@ const (PermissionUsersList Permission = "bb.users.list"PermissionUsersUndelete Permission = "bb.users.undelete"PermissionUsersUpdate Permission = "bb.users.update"+ PermissionUsersUpdateEmail Permission = "bb.users.updateEmail"PermissionWorksheetsGet Permission = "bb.worksheets.get"PermissionWorksheetsManage Permission = "bb.worksheets.manage"PermissionWorkspacesGetIamPolicy Permission = "bb.workspaces.getIamPolicy"@@ -230,6 +231,7 @@ var allPermissions = []Permission{PermissionUsersList,PermissionUsersUndelete,PermissionUsersUpdate,+ PermissionUsersUpdateEmail,PermissionWorksheetsGet,PermissionWorksheetsManage,PermissionWorkspacesGetIamPolicy,diff --git a/backend/component/iam/permission.yaml b/backend/component/iam/permission.yamlindex c7e8b6332d..b1a697a67c 100644--- a/backend/component/iam/permission.yaml+++ b/backend/component/iam/permission.yaml@@ -109,6 +109,7 @@ permissions:- bb.users.list- bb.users.undelete- bb.users.update+ - bb.users.updateEmail- bb.worksheets.get- bb.worksheets.manage- bb.workspaces.getIamPolicydiff --git a/backend/generated-go/v1/user_service.pb.go b/backend/generated-go/v1/user_service.pb.goindex 451ef01da5..83568c8937 100644--- a/backend/generated-go/v1/user_service.pb.go+++ b/backend/generated-go/v1/user_service.pb.go@@ -607,6 +607,61 @@ func (x *UndeleteUserRequest) GetName() string {return ""}+type UpdateEmailRequest struct {+ state protoimpl.MessageState `protogen:"open.v1"`+ // The name of the user whose email to update.+ // Format: users/{user email}+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`+ // The new email address.+ Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"`+ unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache+}++func (x *UpdateEmailRequest) Reset() {+ *x = UpdateEmailRequest{}+ mi := &file_v1_user_service_proto_msgTypes[9]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+}++func (x *UpdateEmailRequest) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*UpdateEmailRequest) ProtoMessage() {}++func (x *UpdateEmailRequest) ProtoReflect() protoreflect.Message {+ mi := &file_v1_user_service_proto_msgTypes[9]+ if x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use UpdateEmailRequest.ProtoReflect.Descriptor instead.+func (*UpdateEmailRequest) Descriptor() ([]byte, []int) {+ return file_v1_user_service_proto_rawDescGZIP(), []int{9}+}++func (x *UpdateEmailRequest) GetName() string {+ if x != nil {+ return x.Name+ }+ return ""+}++func (x *UpdateEmailRequest) GetEmail() string {+ if x != nil {+ return x.Email+ }+ return ""+}+type User struct {state protoimpl.MessageState `protogen:"open.v1"`// The name of the user.@@ -646,7 +701,7 @@ type User struct {func (x *User) Reset() {*x = User{}- mi := &file_v1_user_service_proto_msgTypes[9]+ mi := &file_v1_user_service_proto_msgTypes[10]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -658,7 +713,7 @@ func (x *User) String() string {func (*User) ProtoMessage() {}func (x *User) ProtoReflect() protoreflect.Message {- mi := &file_v1_user_service_proto_msgTypes[9]+ mi := &file_v1_user_service_proto_msgTypes[10]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -671,7 +726,7 @@ func (x *User) ProtoReflect() protoreflect.Message {// Deprecated: Use User.ProtoReflect.Descriptor instead.func (*User) Descriptor() ([]byte, []int) {- return file_v1_user_service_proto_rawDescGZIP(), []int{9}+ return file_v1_user_service_proto_rawDescGZIP(), []int{10}}func (x *User) GetName() string {@@ -786,7 +841,7 @@ type User_Profile struct {func (x *User_Profile) Reset() {*x = User_Profile{}- mi := &file_v1_user_service_proto_msgTypes[10]+ mi := &file_v1_user_service_proto_msgTypes[11]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -798,7 +853,7 @@ func (x *User_Profile) String() string {func (*User_Profile) ProtoMessage() {}func (x *User_Profile) ProtoReflect() protoreflect.Message {- mi := &file_v1_user_service_proto_msgTypes[10]+ mi := &file_v1_user_service_proto_msgTypes[11]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -811,7 +866,7 @@ func (x *User_Profile) ProtoReflect() protoreflect.Message {// Deprecated: Use User_Profile.ProtoReflect.Descriptor instead.func (*User_Profile) Descriptor() ([]byte, []int) {- return file_v1_user_service_proto_rawDescGZIP(), []int{9, 0}+ return file_v1_user_service_proto_rawDescGZIP(), []int{10, 0}}func (x *User_Profile) GetLastLoginTime() *timestamppb.Timestamp {@@ -873,7 +928,11 @@ const file_v1_user_service_proto_rawDesc = "" +"\x11bytebase.com/UserR\x04name\"D\n" +"\x13UndeleteUserRequest\x12-\n" +"\x04name\x18\x01 \x01(\tB\x19\xe0A\x02\xfaA\x13\n" +- "\x11bytebase.com/UserR\x04name\"\x9c\x06\n" ++ "\x11bytebase.com/UserR\x04name\"^\n" ++ "\x12UpdateEmailRequest\x12-\n" ++ "\x04name\x18\x01 \x01(\tB\x19\xe0A\x02\xfaA\x13\n" ++ "\x11bytebase.com/UserR\x04name\x12\x19\n" ++ "\x05email\x18\x02 \x01(\tB\x03\xe0A\x02R\x05email\"\x9c\x06\n" +"\x04User\x12\x17\n" +"\x04name\x18\x01 \x01(\tB\x03\xe0A\x03R\x04name\x12(\n" +"\x05state\x18\x02 \x01(\x0e2\x12.bytebase.v1.StateR\x05state\x12\x14\n" +@@ -902,7 +961,7 @@ const file_v1_user_service_proto_rawDesc = "" +"\x04USER\x10\x01\x12\x0e\n" +"\n" +"SYSTEM_BOT\x10\x02\x12\x13\n" +- "\x0fSERVICE_ACCOUNT\x10\x032\xb7\a\n" ++ "\x0fSERVICE_ACCOUNT\x10\x032\xd3\b\n" +"\vUserService\x12p\n" +"\aGetUser\x12\x1b.bytebase.v1.GetUserRequest\x1a\x11.bytebase.v1.User\"5\xdaA\x04name\x8a\xea0\fbb.users.get\x90\xea0\x01\x82\xd3\xe4\x93\x02\x14\x12\x12/v1/{name=users/*}\x12\x86\x01\n" +"\rBatchGetUsers\x12!.bytebase.v1.BatchGetUsersRequest\x1a\".bytebase.v1.BatchGetUsersResponse\".\x8a\xea0\fbb.users.get\x90\xea0\x01\x82\xd3\xe4\x93\x02\x14\x12\x12/v1/users:batchGet\x12Y\n" +@@ -914,7 +973,9 @@ const file_v1_user_service_proto_rawDesc = "" +"UpdateUser\x12\x1e.bytebase.v1.UpdateUserRequest\x1a\x11.bytebase.v1.User\"@\xdaA\x10user,update_mask\x90\xea0\x02\x98\xea0\x01\x82\xd3\xe4\x93\x02\x1f:\x04user2\x17/v1/{user.name=users/*}\x12o\n" +"\n" +"DeleteUser\x12\x1e.bytebase.v1.DeleteUserRequest\x1a\x16.google.protobuf.Empty\")\xdaA\x04name\x90\xea0\x02\x98\xea0\x01\x82\xd3\xe4\x93\x02\x14*\x12/v1/{name=users/*}\x12s\n" +- "\fUndeleteUser\x12 .bytebase.v1.UndeleteUserRequest\x1a\x11.bytebase.v1.User\".\x90\xea0\x02\x98\xea0\x01\x82\xd3\xe4\x93\x02 :\x01*\"\x1b/v1/{name=users/*}:undeleteB\xa6\x01\n" ++ "\fUndeleteUser\x12 .bytebase.v1.UndeleteUserRequest\x1a\x11.bytebase.v1.User\".\x90\xea0\x02\x98\xea0\x01\x82\xd3\xe4\x93\x02 :\x01*\"\x1b/v1/{name=users/*}:undelete\x12\x99\x01\n" ++ "\vUpdateEmail\x12\x1f.bytebase.v1.UpdateEmailRequest\x1a\x11.bytebase.v1.User\"V\xdaA\n" ++ "name,email\x8a\xea0\x14bb.users.updateEmail\x90\xea0\x01\x98\xea0\x01\x82\xd3\xe4\x93\x02#:\x01*\"\x1e/v1/{name=users/*}:updateEmailB\xa6\x01\n" +"\x0fcom.bytebase.v1B\x10UserServiceProtoP\x01Z4github.com/bytebase/bytebase/backend/generated-go/v1\xa2\x02\x03BXX\xaa\x02\vBytebase.V1\xca\x02\vBytebase\\V1\xe2\x02\x17Bytebase\\V1\\GPBMetadata\xea\x02\fBytebase::V1b\x06proto3"var (@@ -930,7 +991,7 @@ func file_v1_user_service_proto_rawDescGZIP() []byte {}var file_v1_user_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1)-var file_v1_user_service_proto_msgTypes = make([]protoimpl.MessageInfo, 11)+var file_v1_user_service_proto_msgTypes = make([]protoimpl.MessageInfo, 12)var file_v1_user_service_proto_goTypes = []any{(UserType)(0), // 0: bytebase.v1.UserType(*GetUserRequest)(nil), // 1: bytebase.v1.GetUserRequest@@ -942,43 +1003,46 @@ var file_v1_user_service_proto_goTypes = []any{(*UpdateUserRequest)(nil), // 7: bytebase.v1.UpdateUserRequest(*DeleteUserRequest)(nil), // 8: bytebase.v1.DeleteUserRequest(*UndeleteUserRequest)(nil), // 9: bytebase.v1.UndeleteUserRequest- (*User)(nil), // 10: bytebase.v1.User- (*User_Profile)(nil), // 11: bytebase.v1.User.Profile- (*fieldmaskpb.FieldMask)(nil), // 12: google.protobuf.FieldMask- (State)(0), // 13: bytebase.v1.State- (*timestamppb.Timestamp)(nil), // 14: google.protobuf.Timestamp- (*emptypb.Empty)(nil), // 15: google.protobuf.Empty+ (*UpdateEmailRequest)(nil), // 10: bytebase.v1.UpdateEmailRequest+ (*User)(nil), // 11: bytebase.v1.User+ (*User_Profile)(nil), // 12: bytebase.v1.User.Profile+ (*fieldmaskpb.FieldMask)(nil), // 13: google.protobuf.FieldMask+ (State)(0), // 14: bytebase.v1.State+ (*timestamppb.Timestamp)(nil), // 15: google.protobuf.Timestamp+ (*emptypb.Empty)(nil), // 16: google.protobuf.Empty}var file_v1_user_service_proto_depIdxs = []int32{- 10, // 0: bytebase.v1.BatchGetUsersResponse.users:type_name -> bytebase.v1.User- 10, // 1: bytebase.v1.ListUsersResponse.users:type_name -> bytebase.v1.User- 10, // 2: bytebase.v1.CreateUserRequest.user:type_name -> bytebase.v1.User- 10, // 3: bytebase.v1.UpdateUserRequest.user:type_name -> bytebase.v1.User- 12, // 4: bytebase.v1.UpdateUserRequest.update_mask:type_name -> google.protobuf.FieldMask- 13, // 5: bytebase.v1.User.state:type_name -> bytebase.v1.State+ 11, // 0: bytebase.v1.BatchGetUsersResponse.users:type_name -> bytebase.v1.User+ 11, // 1: bytebase.v1.ListUsersResponse.users:type_name -> bytebase.v1.User+ 11, // 2: bytebase.v1.CreateUserRequest.user:type_name -> bytebase.v1.User+ 11, // 3: bytebase.v1.UpdateUserRequest.user:type_name -> bytebase.v1.User+ 13, // 4: bytebase.v1.UpdateUserRequest.update_mask:type_name -> google.protobuf.FieldMask+ 14, // 5: bytebase.v1.User.state:type_name -> bytebase.v1.State0, // 6: bytebase.v1.User.user_type:type_name -> bytebase.v1.UserType- 14, // 7: bytebase.v1.User.temp_otp_secret_created_time:type_name -> google.protobuf.Timestamp- 11, // 8: bytebase.v1.User.profile:type_name -> bytebase.v1.User.Profile- 14, // 9: bytebase.v1.User.Profile.last_login_time:type_name -> google.protobuf.Timestamp- 14, // 10: bytebase.v1.User.Profile.last_change_password_time:type_name -> google.protobuf.Timestamp+ 15, // 7: bytebase.v1.User.temp_otp_secret_created_time:type_name -> google.protobuf.Timestamp+ 12, // 8: bytebase.v1.User.profile:type_name -> bytebase.v1.User.Profile+ 15, // 9: bytebase.v1.User.Profile.last_login_time:type_name -> google.protobuf.Timestamp+ 15, // 10: bytebase.v1.User.Profile.last_change_password_time:type_name -> google.protobuf.Timestamp1, // 11: bytebase.v1.UserService.GetUser:input_type -> bytebase.v1.GetUserRequest2, // 12: bytebase.v1.UserService.BatchGetUsers:input_type -> bytebase.v1.BatchGetUsersRequest- 15, // 13: bytebase.v1.UserService.GetCurrentUser:input_type -> google.protobuf.Empty+ 16, // 13: bytebase.v1.UserService.GetCurrentUser:input_type -> google.protobuf.Empty4, // 14: bytebase.v1.UserService.ListUsers:input_type -> bytebase.v1.ListUsersRequest6, // 15: bytebase.v1.UserService.CreateUser:input_type -> bytebase.v1.CreateUserRequest7, // 16: bytebase.v1.UserService.UpdateUser:input_type -> bytebase.v1.UpdateUserRequest8, // 17: bytebase.v1.UserService.DeleteUser:input_type -> bytebase.v1.DeleteUserRequest9, // 18: bytebase.v1.UserService.UndeleteUser:input_type -> bytebase.v1.UndeleteUserRequest- 10, // 19: bytebase.v1.UserService.GetUser:output_type -> bytebase.v1.User- 3, // 20: bytebase.v1.UserService.BatchGetUsers:output_type -> bytebase.v1.BatchGetUsersResponse- 10, // 21: bytebase.v1.UserService.GetCurrentUser:output_type -> bytebase.v1.User- 5, // 22: bytebase.v1.UserService.ListUsers:output_type -> bytebase.v1.ListUsersResponse- 10, // 23: bytebase.v1.UserService.CreateUser:output_type -> bytebase.v1.User- 10, // 24: bytebase.v1.UserService.UpdateUser:output_type -> bytebase.v1.User- 15, // 25: bytebase.v1.UserService.DeleteUser:output_type -> google.protobuf.Empty- 10, // 26: bytebase.v1.UserService.UndeleteUser:output_type -> bytebase.v1.User- 19, // [19:27] is the sub-list for method output_type- 11, // [11:19] is the sub-list for method input_type+ 10, // 19: bytebase.v1.UserService.UpdateEmail:input_type -> bytebase.v1.UpdateEmailRequest+ 11, // 20: bytebase.v1.UserService.GetUser:output_type -> bytebase.v1.User+ 3, // 21: bytebase.v1.UserService.BatchGetUsers:output_type -> bytebase.v1.BatchGetUsersResponse+ 11, // 22: bytebase.v1.UserService.GetCurrentUser:output_type -> bytebase.v1.User+ 5, // 23: bytebase.v1.UserService.ListUsers:output_type -> bytebase.v1.ListUsersResponse+ 11, // 24: bytebase.v1.UserService.CreateUser:output_type -> bytebase.v1.User+ 11, // 25: bytebase.v1.UserService.UpdateUser:output_type -> bytebase.v1.User+ 16, // 26: bytebase.v1.UserService.DeleteUser:output_type -> google.protobuf.Empty+ 11, // 27: bytebase.v1.UserService.UndeleteUser:output_type -> bytebase.v1.User+ 11, // 28: bytebase.v1.UserService.UpdateEmail:output_type -> bytebase.v1.User+ 20, // [20:29] is the sub-list for method output_type+ 11, // [11:20] is the sub-list for method input_type11, // [11:11] is the sub-list for extension type_name11, // [11:11] is the sub-list for extension extendee0, // [0:11] is the sub-list for field type_name@@ -998,7 +1062,7 @@ func file_v1_user_service_proto_init() {GoPackagePath: reflect.TypeOf(x{}).PkgPath(),RawDescriptor: unsafe.Slice(unsafe.StringData(file_v1_user_service_proto_rawDesc), len(file_v1_user_service_proto_rawDesc)),NumEnums: 1,- NumMessages: 11,+ NumMessages: 12,NumExtensions: 0,NumServices: 1,},diff --git a/backend/generated-go/v1/user_service.pb.gw.go b/backend/generated-go/v1/user_service.pb.gw.goindex 8ed17fda98..8fbc073433 100644--- a/backend/generated-go/v1/user_service.pb.gw.go+++ b/backend/generated-go/v1/user_service.pb.gw.go@@ -358,6 +358,51 @@ func local_request_UserService_UndeleteUser_0(ctx context.Context, marshaler runreturn msg, metadata, err}+func request_UserService_UpdateEmail_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var (+ protoReq UpdateEmailRequest+ metadata runtime.ServerMetadata+ err error+ )+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }+ if req.Body != nil {+ _, _ = io.Copy(io.Discard, req.Body)+ }+ val, ok := pathParams["name"]+ if !ok {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")+ }+ protoReq.Name, err = runtime.String(val)+ if err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)+ }+ msg, err := client.UpdateEmail(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))+ return msg, metadata, err+}++func local_request_UserService_UpdateEmail_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var (+ protoReq UpdateEmailRequest+ metadata runtime.ServerMetadata+ err error+ )+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }+ val, ok := pathParams["name"]+ if !ok {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")+ }+ protoReq.Name, err = runtime.String(val)+ if err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)+ }+ msg, err := server.UpdateEmail(ctx, &protoReq)+ return msg, metadata, err+}+// RegisterUserServiceHandlerServer registers the http handlers for service UserService to "mux".// UnaryRPC :call UserServiceServer directly.// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.@@ -524,6 +569,26 @@ func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux}forward_UserService_UndeleteUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)})+ mux.Handle(http.MethodPost, pattern_UserService_UpdateEmail_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ var stream runtime.ServerTransportStream+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.UserService/UpdateEmail", runtime.WithHTTPPathPattern("/v1/{name=users/*}:updateEmail"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := local_request_UserService_UpdateEmail_0(annotatedContext, inboundMarshaler, server, req, pathParams)+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }+ forward_UserService_UpdateEmail_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)+ })return nil}@@ -700,6 +765,23 @@ func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux}forward_UserService_UndeleteUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)})+ mux.Handle(http.MethodPost, pattern_UserService_UpdateEmail_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.UserService/UpdateEmail", runtime.WithHTTPPathPattern("/v1/{name=users/*}:updateEmail"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := request_UserService_UpdateEmail_0(annotatedContext, inboundMarshaler, client, req, pathParams)+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }+ forward_UserService_UpdateEmail_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)+ })return nil}@@ -712,6 +794,7 @@ var (pattern_UserService_UpdateUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "users", "user.name"}, ""))pattern_UserService_DeleteUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "users", "name"}, ""))pattern_UserService_UndeleteUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "users", "name"}, "undelete"))+ pattern_UserService_UpdateEmail_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "users", "name"}, "updateEmail")))var (@@ -723,4 +806,5 @@ var (forward_UserService_UpdateUser_0 = runtime.ForwardResponseMessageforward_UserService_DeleteUser_0 = runtime.ForwardResponseMessageforward_UserService_UndeleteUser_0 = runtime.ForwardResponseMessage+ forward_UserService_UpdateEmail_0 = runtime.ForwardResponseMessage)diff --git a/backend/generated-go/v1/user_service_equal.pb.go b/backend/generated-go/v1/user_service_equal.pb.goindex aaa2cbc3e2..28f510885f 100644--- a/backend/generated-go/v1/user_service_equal.pb.go+++ b/backend/generated-go/v1/user_service_equal.pb.go@@ -171,6 +171,22 @@ func (x *UndeleteUserRequest) Equal(y *UndeleteUserRequest) bool {return true}+func (x *UpdateEmailRequest) Equal(y *UpdateEmailRequest) bool {+ if x == y {+ return true+ }+ if x == nil || y == nil {+ return x == nil && y == nil+ }+ if x.Name != y.Name {+ return false+ }+ if x.Email != y.Email {+ return false+ }+ return true+}+func (x *User_Profile) Equal(y *User_Profile) bool {if x == y {return truediff --git a/backend/generated-go/v1/user_service_grpc.pb.go b/backend/generated-go/v1/user_service_grpc.pb.goindex 5765bc8002..2ae3dc82df 100644--- a/backend/generated-go/v1/user_service_grpc.pb.go+++ b/backend/generated-go/v1/user_service_grpc.pb.go@@ -28,6 +28,7 @@ const (UserService_UpdateUser_FullMethodName = "/bytebase.v1.UserService/UpdateUser"UserService_DeleteUser_FullMethodName = "/bytebase.v1.UserService/DeleteUser"UserService_UndeleteUser_FullMethodName = "/bytebase.v1.UserService/UndeleteUser"+ UserService_UpdateEmail_FullMethodName = "/bytebase.v1.UserService/UpdateEmail")// UserServiceClient is the client API for UserService service.@@ -55,6 +56,7 @@ type UserServiceClient interface {// Permissions required: bb.users.create (only when Disallow Signup is enabled)CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*User, error)// Updates a user. Users can update their own profile, or users with bb.users.update permission can update any user.+ // Note: Email updates are not supported through this API. Use UpdateEmail instead.// Permissions required: bb.users.update (or self)UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...grpc.CallOption) (*User, error)// Deletes a user. Requires bb.users.delete permission with additional validation: the last remaining workspace admin cannot be deleted.@@ -63,6 +65,9 @@ type UserServiceClient interface {// Restores a deleted user.// Permissions required: bb.users.undeleteUndeleteUser(ctx context.Context, in *UndeleteUserRequest, opts ...grpc.CallOption) (*User, error)+ // Updates a user's email address.+ // Permissions required: bb.users.updateEmail+ UpdateEmail(ctx context.Context, in *UpdateEmailRequest, opts ...grpc.CallOption) (*User, error)}type userServiceClient struct {@@ -153,6 +158,16 @@ func (c *userServiceClient) UndeleteUser(ctx context.Context, in *UndeleteUserRereturn out, nil}+func (c *userServiceClient) UpdateEmail(ctx context.Context, in *UpdateEmailRequest, opts ...grpc.CallOption) (*User, error) {+ cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)+ out := new(User)+ err := c.cc.Invoke(ctx, UserService_UpdateEmail_FullMethodName, in, out, cOpts...)+ if err != nil {+ return nil, err+ }+ return out, nil+}+// UserServiceServer is the server API for UserService service.// All implementations must embed UnimplementedUserServiceServer// for forward compatibility.@@ -178,6 +193,7 @@ type UserServiceServer interface {// Permissions required: bb.users.create (only when Disallow Signup is enabled)CreateUser(context.Context, *CreateUserRequest) (*User, error)// Updates a user. Users can update their own profile, or users with bb.users.update permission can update any user.+ // Note: Email updates are not supported through this API. Use UpdateEmail instead.// Permissions required: bb.users.update (or self)UpdateUser(context.Context, *UpdateUserRequest) (*User, error)// Deletes a user. Requires bb.users.delete permission with additional validation: the last remaining workspace admin cannot be deleted.@@ -186,6 +202,9 @@ type UserServiceServer interface {// Restores a deleted user.// Permissions required: bb.users.undeleteUndeleteUser(context.Context, *UndeleteUserRequest) (*User, error)+ // Updates a user's email address.+ // Permissions required: bb.users.updateEmail+ UpdateEmail(context.Context, *UpdateEmailRequest) (*User, error)mustEmbedUnimplementedUserServiceServer()}@@ -220,6 +239,9 @@ func (UnimplementedUserServiceServer) DeleteUser(context.Context, *DeleteUserReqfunc (UnimplementedUserServiceServer) UndeleteUser(context.Context, *UndeleteUserRequest) (*User, error) {return nil, status.Error(codes.Unimplemented, "method UndeleteUser not implemented")}+func (UnimplementedUserServiceServer) UpdateEmail(context.Context, *UpdateEmailRequest) (*User, error) {+ return nil, status.Error(codes.Unimplemented, "method UpdateEmail not implemented")+}func (UnimplementedUserServiceServer) mustEmbedUnimplementedUserServiceServer() {}func (UnimplementedUserServiceServer) testEmbeddedByValue() {}@@ -385,6 +407,24 @@ func _UserService_UndeleteUser_Handler(srv interface{}, ctx context.Context, decreturn interceptor(ctx, in, info, handler)}+func _UserService_UpdateEmail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {+ in := new(UpdateEmailRequest)+ if err := dec(in); err != nil {+ return nil, err+ }+ if interceptor == nil {+ return srv.(UserServiceServer).UpdateEmail(ctx, in)+ }+ info := &grpc.UnaryServerInfo{+ Server: srv,+ FullMethod: UserService_UpdateEmail_FullMethodName,+ }+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {+ return srv.(UserServiceServer).UpdateEmail(ctx, req.(*UpdateEmailRequest))+ }+ return interceptor(ctx, in, info, handler)+}+// UserService_ServiceDesc is the grpc.ServiceDesc for UserService service.// It's only intended for direct use with grpc.RegisterService,// and not to be introspected or modified (even as a copy)@@ -424,6 +464,10 @@ var UserService_ServiceDesc = grpc.ServiceDesc{MethodName: "UndeleteUser",Handler: _UserService_UndeleteUser_Handler,},+ {+ MethodName: "UpdateEmail",+ Handler: _UserService_UpdateEmail_Handler,+ },},Streams: []grpc.StreamDesc{},Metadata: "v1/user_service.proto",diff --git a/backend/generated-go/v1/v1connect/user_service.connect.go b/backend/generated-go/v1/v1connect/user_service.connect.goindex 29b8d66db1..85a258942b 100644--- a/backend/generated-go/v1/v1connect/user_service.connect.go+++ b/backend/generated-go/v1/v1connect/user_service.connect.go@@ -53,6 +53,8 @@ const (// UserServiceUndeleteUserProcedure is the fully-qualified name of the UserService's UndeleteUser// RPC.UserServiceUndeleteUserProcedure = "/bytebase.v1.UserService/UndeleteUser"+ // UserServiceUpdateEmailProcedure is the fully-qualified name of the UserService's UpdateEmail RPC.+ UserServiceUpdateEmailProcedure = "/bytebase.v1.UserService/UpdateEmail")// UserServiceClient is a client for the bytebase.v1.UserService service.@@ -76,6 +78,7 @@ type UserServiceClient interface {// Permissions required: bb.users.create (only when Disallow Signup is enabled)CreateUser(context.Context, *connect.Request[v1.CreateUserRequest]) (*connect.Response[v1.User], error)// Updates a user. Users can update their own profile, or users with bb.users.update permission can update any user.+ // Note: Email updates are not supported through this API. Use UpdateEmail instead.// Permissions required: bb.users.update (or self)UpdateUser(context.Context, *connect.Request[v1.UpdateUserRequest]) (*connect.Response[v1.User], error)// Deletes a user. Requires bb.users.delete permission with additional validation: the last remaining workspace admin cannot be deleted.@@ -84,6 +87,9 @@ type UserServiceClient interface {// Restores a deleted user.// Permissions required: bb.users.undeleteUndeleteUser(context.Context, *connect.Request[v1.UndeleteUserRequest]) (*connect.Response[v1.User], error)+ // Updates a user's email address.+ // Permissions required: bb.users.updateEmail+ UpdateEmail(context.Context, *connect.Request[v1.UpdateEmailRequest]) (*connect.Response[v1.User], error)}// NewUserServiceClient constructs a client for the bytebase.v1.UserService service. By default, it@@ -145,6 +151,12 @@ func NewUserServiceClient(httpClient connect.HTTPClient, baseURL string, opts ..connect.WithSchema(userServiceMethods.ByName("UndeleteUser")),connect.WithClientOptions(opts...),),+ updateEmail: connect.NewClient[v1.UpdateEmailRequest, v1.User](+ httpClient,+ baseURL+UserServiceUpdateEmailProcedure,+ connect.WithSchema(userServiceMethods.ByName("UpdateEmail")),+ connect.WithClientOptions(opts...),+ ),}}@@ -158,6 +170,7 @@ type userServiceClient struct {updateUser *connect.Client[v1.UpdateUserRequest, v1.User]deleteUser *connect.Client[v1.DeleteUserRequest, emptypb.Empty]undeleteUser *connect.Client[v1.UndeleteUserRequest, v1.User]+ updateEmail *connect.Client[v1.UpdateEmailRequest, v1.User]}// GetUser calls bytebase.v1.UserService.GetUser.@@ -200,6 +213,11 @@ func (c *userServiceClient) UndeleteUser(ctx context.Context, req *connect.Requereturn c.undeleteUser.CallUnary(ctx, req)}+// UpdateEmail calls bytebase.v1.UserService.UpdateEmail.+func (c *userServiceClient) UpdateEmail(ctx context.Context, req *connect.Request[v1.UpdateEmailRequest]) (*connect.Response[v1.User], error) {+ return c.updateEmail.CallUnary(ctx, req)+}+// UserServiceHandler is an implementation of the bytebase.v1.UserService service.type UserServiceHandler interface {// Get the user.@@ -221,6 +239,7 @@ type UserServiceHandler interface {// Permissions required: bb.users.create (only when Disallow Signup is enabled)CreateUser(context.Context, *connect.Request[v1.CreateUserRequest]) (*connect.Response[v1.User], error)// Updates a user. Users can update their own profile, or users with bb.users.update permission can update any user.+ // Note: Email updates are not supported through this API. Use UpdateEmail instead.// Permissions required: bb.users.update (or self)UpdateUser(context.Context, *connect.Request[v1.UpdateUserRequest]) (*connect.Response[v1.User], error)// Deletes a user. Requires bb.users.delete permission with additional validation: the last remaining workspace admin cannot be deleted.@@ -229,6 +248,9 @@ type UserServiceHandler interface {// Restores a deleted user.// Permissions required: bb.users.undeleteUndeleteUser(context.Context, *connect.Request[v1.UndeleteUserRequest]) (*connect.Response[v1.User], error)+ // Updates a user's email address.+ // Permissions required: bb.users.updateEmail+ UpdateEmail(context.Context, *connect.Request[v1.UpdateEmailRequest]) (*connect.Response[v1.User], error)}// NewUserServiceHandler builds an HTTP handler from the service implementation. It returns the path@@ -286,6 +308,12 @@ func NewUserServiceHandler(svc UserServiceHandler, opts ...connect.HandlerOptionconnect.WithSchema(userServiceMethods.ByName("UndeleteUser")),connect.WithHandlerOptions(opts...),)+ userServiceUpdateEmailHandler := connect.NewUnaryHandler(+ UserServiceUpdateEmailProcedure,+ svc.UpdateEmail,+ connect.WithSchema(userServiceMethods.ByName("UpdateEmail")),+ connect.WithHandlerOptions(opts...),+ )return "/bytebase.v1.UserService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {switch r.URL.Path {case UserServiceGetUserProcedure:@@ -304,6 +332,8 @@ func NewUserServiceHandler(svc UserServiceHandler, opts ...connect.HandlerOptionuserServiceDeleteUserHandler.ServeHTTP(w, r)case UserServiceUndeleteUserProcedure:userServiceUndeleteUserHandler.ServeHTTP(w, r)+ case UserServiceUpdateEmailProcedure:+ userServiceUpdateEmailHandler.ServeHTTP(w, r)default:http.NotFound(w, r)}@@ -344,3 +374,7 @@ func (UnimplementedUserServiceHandler) DeleteUser(context.Context, *connect.Requfunc (UnimplementedUserServiceHandler) UndeleteUser(context.Context, *connect.Request[v1.UndeleteUserRequest]) (*connect.Response[v1.User], error) {return nil, connect.NewError(connect.CodeUnimplemented, errors.New("bytebase.v1.UserService.UndeleteUser is not implemented"))}++func (UnimplementedUserServiceHandler) UpdateEmail(context.Context, *connect.Request[v1.UpdateEmailRequest]) (*connect.Response[v1.User], error) {+ return nil, connect.NewError(connect.CodeUnimplemented, errors.New("bytebase.v1.UserService.UpdateEmail is not implemented"))+}diff --git a/frontend/src/store/modules/user.ts b/frontend/src/store/modules/user.tsindex 2ad68b41db..04b3826c09 100644--- a/frontend/src/store/modules/user.ts+++ b/frontend/src/store/modules/user.ts@@ -143,6 +143,18 @@ export const useUserStore = defineStore("user", () => {return setUser(response);};+ const updateEmail = async (oldEmail: string, newEmail: string) => {+ const originData = await getOrFetchUserByIdentifier(oldEmail);+ if (!originData) {+ throw new Error(`user with email ${oldEmail} not found`);+ }+ const response = await userServiceClientConnect.updateEmail({+ name: `users/${oldEmail}`,+ email: newEmail,+ });+ return setUser(response);+ };+const archiveUser = async (user: User) => {const request = create(DeleteUserRequestSchema, {name: user.name,@@ -232,6 +244,7 @@ export const useUserStore = defineStore("user", () => {fetchUserList,createUser,updateUser,+ updateEmail,batchGetUsers,getOrFetchUserByIdentifier,getUserByIdentifier,diff --git a/frontend/src/types/iam/permission.ts b/frontend/src/types/iam/permission.tsindex 54de67589b..3946662042 100644--- a/frontend/src/types/iam/permission.ts+++ b/frontend/src/types/iam/permission.ts@@ -107,8 +107,11 @@ export type Permission =| "bb.taskRuns.list"| "bb.users.create"| "bb.users.delete"+ | "bb.users.get"+ | "bb.users.list"| "bb.users.undelete"| "bb.users.update"+ | "bb.users.updateEmail"| "bb.worksheets.get"| "bb.worksheets.manage"| "bb.workspaces.getIamPolicy"diff --git a/frontend/src/types/proto-es/v1/user_service_pb.d.ts b/frontend/src/types/proto-es/v1/user_service_pb.d.tsindex 76d56f7790..b99697039c 100644--- a/frontend/src/types/proto-es/v1/user_service_pb.d.ts+++ b/frontend/src/types/proto-es/v1/user_service_pb.d.ts@@ -276,6 +276,32 @@ export declare type UndeleteUserRequest = Message<"bytebase.v1.UndeleteUserReque*/export declare const UndeleteUserRequestSchema: GenMessage<UndeleteUserRequest>;+/**+ * @generated from message bytebase.v1.UpdateEmailRequest+ */+export declare type UpdateEmailRequest = Message<"bytebase.v1.UpdateEmailRequest"> & {+ /**+ * The name of the user whose email to update.+ * Format: users/{user email}+ *+ * @generated from field: string name = 1;+ */+ name: string;++ /**+ * The new email address.+ *+ * @generated from field: string email = 2;+ */+ email: string;+};++/**+ * Describes the message bytebase.v1.UpdateEmailRequest.+ * Use `create(UpdateEmailRequestSchema)` to create a new message.+ */+export declare const UpdateEmailRequestSchema: GenMessage<UpdateEmailRequest>;+/*** @generated from message bytebase.v1.User*/@@ -524,6 +550,7 @@ export declare const UserService: GenService<{},/*** Updates a user. Users can update their own profile, or users with bb.users.update permission can update any user.+ * Note: Email updates are not supported through this API. Use UpdateEmail instead.* Permissions required: bb.users.update (or self)** @generated from rpc bytebase.v1.UserService.UpdateUser@@ -555,5 +582,16 @@ export declare const UserService: GenService<{input: typeof UndeleteUserRequestSchema;output: typeof UserSchema;},+ /**+ * Updates a user's email address.+ * Permissions required: bb.users.updateEmail+ *+ * @generated from rpc bytebase.v1.UserService.UpdateEmail+ */+ updateEmail: {+ methodKind: "unary";+ input: typeof UpdateEmailRequestSchema;+ output: typeof UserSchema;+ },}>;diff --git a/frontend/src/types/proto-es/v1/user_service_pb.js b/frontend/src/types/proto-es/v1/user_service_pb.jsindex 93ff04bfae..7204ffa6e3 100644--- a/frontend/src/types/proto-es/v1/user_service_pb.js+++ b/frontend/src/types/proto-es/v1/user_service_pb.js@@ -16,7 +16,7 @@ import { file_v1_common } from "./common_pb";* Describes the file v1/user_service.proto.*/export const file_v1_user_service = /*@__PURE__*/- fileDesc("ChV2MS91c2VyX3NlcnZpY2UucHJvdG8SC2J5dGViYXNlLnYxIjkKDkdldFVzZXJSZXF1ZXN0EicKBG5hbWUYASABKAlCGeBBAvpBEwoRYnl0ZWJhc2UuY29tL1VzZXIiQAoUQmF0Y2hHZXRVc2Vyc1JlcXVlc3QSKAoFbmFtZXMYASADKAlCGeBBAvpBEwoRYnl0ZWJhc2UuY29tL1VzZXIiOQoVQmF0Y2hHZXRVc2Vyc1Jlc3BvbnNlEiAKBXVzZXJzGAEgAygLMhEuYnl0ZWJhc2UudjEuVXNlciJfChBMaXN0VXNlcnNSZXF1ZXN0EhEKCXBhZ2Vfc2l6ZRgBIAEoBRISCgpwYWdlX3Rva2VuGAIgASgJEhQKDHNob3dfZGVsZXRlZBgDIAEoCBIOCgZmaWx0ZXIYBCABKAkiTgoRTGlzdFVzZXJzUmVzcG9uc2USIAoFdXNlcnMYASADKAsyES5ieXRlYmFzZS52MS5Vc2VyEhcKD25leHRfcGFnZV90b2tlbhgCIAEoCSI5ChFD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h4uYnl0ZWJhc2UudjEuQ3JlYXRlVXNlclJlcXVlc3QaES5ieXRlYmFzZS52MS5Vc2VyIiraQQR1c2VygOowAZDqMAKY6jABgtPkkwIROgR1c2VyIgkvdjEvdXNlcnMSgQEKClVwZGF0ZVVzZXISHi5ieXRlYmFzZS52MS5VcGRhdGVVc2VyUmVxdWVzdBoRLmJ5dGViYXNlLnYxLlVzZXIiQNpBEHVzZXIsdXBkYXRlX21hc2uQ6jACmOowAYLT5JMCHzoEdXNlcjIXL3YxL3t1c2VyLm5hbWU9dXNlcnMvKn0SbwoKRGVsZXRlVXNlchIeLmJ5dGViYXNlLnYxLkRlbGV0ZVVzZXJSZXF1ZXN0GhYuZ29vZ2xlLnByb3RvYnVmLkVtcHR5IinaQQRuYW1lkOowApjqMAGC0+STAhQqEi92MS97bmFtZT11c2Vycy8qfRJzCgxVbmRlbGV0ZVVzZXISIC5ieXRlYmFzZS52MS5VbmRlbGV0ZVVzZXJSZXF1ZXN0GhEuYnl0ZWJhc2UudjEuVXNlciIukOowApjqMAGC0+STAiA6ASoiGy92MS97bmFtZT11c2Vycy8qfTp1bmRlbGV0ZUKmAQoPY29tLmJ5dGViYXNlLnYxQhBVc2VyU2VydmljZVByb3RvUAFaNGdpdGh1Yi5jb20vYnl0ZWJhc2UvYnl0ZWJhc2UvYmFja2VuZC9nZW5lcmF0ZWQtZ28vdjGiAgNCWFiqAgtCeXRlYmFzZS5WMcoCC0J5dGViYXNlXFYx4gIXQnl0ZWJhc2VcVjFcR1BCTWV0YWRhdGHqAgxCeXRlYmFzZTo6VjFiBnByb3RvMw", [file_buf_validate_validate, file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_empty, file_google_protobuf_field_mask, file_google_protobuf_timestamp, file_v1_annotation, file_v1_common]);+ fileDesc("ChV2MS91c2VyX3NlcnZpY2UucHJvdG8SC2J5dGViYXNlLnYxIjkKDkdldFVzZXJSZXF1ZXN0EicKBG5hbWUYASABKAlCG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ZXRlVXNlclJlcXVlc3QaES5ieXRlYmFzZS52MS5Vc2VyIi6Q6jACmOowAYLT5JMCIDoBKiIbL3YxL3tuYW1lPXVzZXJzLyp9OnVuZGVsZXRlEpkBCgtVcGRhdGVFbWFpbBIfLmJ5dGViYXNlLnYxLlVwZGF0ZUVtYWlsUmVxdWVzdBoRLmJ5dGViYXNlLnYxLlVzZXIiVtpBCm5hbWUsZW1haWyK6jAUYmIudXNlcnMudXBkYXRlRW1haWyQ6jABmOowAYLT5JMCIzoBKiIeL3YxL3tuYW1lPXVzZXJzLyp9OnVwZGF0ZUVtYWlsQqYBCg9jb20uYnl0ZWJhc2UudjFCEFVzZXJTZXJ2aWNlUHJvdG9QAVo0Z2l0aHViLmNvbS9ieXRlYmFzZS9ieXRlYmFzZS9iYWNrZW5kL2dlbmVyYXRlZC1nby92MaICA0JYWKoCC0J5dGViYXNlLlYxygILQnl0ZWJhc2VcVjHiAhdCeXRlYmFzZVxWMVxHUEJNZXRhZGF0YeoCDEJ5dGViYXNlOjpWMWIGcHJvdG8z", [file_buf_validate_validate, file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_empty, file_google_protobuf_field_mask, file_google_protobuf_timestamp, file_v1_annotation, file_v1_common]);/*** Describes the message bytebase.v1.GetUserRequest.@@ -81,19 +81,26 @@ export const DeleteUserRequestSchema = /*@__PURE__*/export const UndeleteUserRequestSchema = /*@__PURE__*/messageDesc(file_v1_user_service, 8);+/**+ * Describes the message bytebase.v1.UpdateEmailRequest.+ * Use `create(UpdateEmailRequestSchema)` to create a new message.+ */+export const UpdateEmailRequestSchema = /*@__PURE__*/+ messageDesc(file_v1_user_service, 9);+/*** Describes the message bytebase.v1.User.* Use `create(UserSchema)` to create a new message.*/export const UserSchema = /*@__PURE__*/- messageDesc(file_v1_user_service, 9);+ messageDesc(file_v1_user_service, 10);/*** Describes the message bytebase.v1.User.Profile.* Use `create(User_ProfileSchema)` to create a new message.*/export const User_ProfileSchema = /*@__PURE__*/- messageDesc(file_v1_user_service, 9, 0);+ messageDesc(file_v1_user_service, 10, 0);/*** Describes the enum bytebase.v1.UserType.diff --git a/frontend/src/views/ProfileDashboard.vue b/frontend/src/views/ProfileDashboard.vueindex 9996a88452..651a4e2f61 100644--- a/frontend/src/views/ProfileDashboard.vue+++ b/frontend/src/views/ProfileDashboard.vue@@ -361,9 +361,9 @@ const allowEdit = computed(() => {return isSelf.value || hasWorkspacePermissionV2("bb.policies.update");});-// Only admins can change email.+// Only users with bb.users.updateEmail permission can change email.const allowEditEmail = computed(() => {- return hasWorkspacePermissionV2("bb.policies.update");+ return hasWorkspacePermissionV2("bb.users.updateEmail");});const allowSaveEdit = computed(() => {@@ -399,30 +399,38 @@ const saveEdit = async () => {const userPatch = state.editingUser;if (!userPatch) return;+ const emailChanged = userPatch.email !== user.value.email;const updateMaskPaths: string[] = [];+if (userPatch.title !== user.value.title) {updateMaskPaths.push("title");}- if (userPatch.email !== user.value.email) {- updateMaskPaths.push("email");- }if (userPatch.phone !== user.value.phone) {updateMaskPaths.push("phone");}if (userPatch.password !== "") {updateMaskPaths.push("password");}+try {- await userStore.updateUser(- create(UpdateUserRequestSchema, {- user: userPatch,- updateMask: create(FieldMaskSchema, {- paths: updateMaskPaths,- }),- regenerateRecoveryCodes: false,- regenerateTempMfaSecret: false,- })- );+ // Update email using dedicated UpdateEmail API if changed+ if (emailChanged) {+ await userStore.updateEmail(user.value.email, userPatch.email);+ }++ // Update other fields using UpdateUser API if any changed+ if (updateMaskPaths.length > 0) {+ await userStore.updateUser(+ create(UpdateUserRequestSchema, {+ user: userPatch,+ updateMask: create(FieldMaskSchema, {+ paths: updateMaskPaths,+ }),+ regenerateRecoveryCodes: false,+ regenerateTempMfaSecret: false,+ })+ );+ }} catch (error) {pushNotification({module: "bytebase",@@ -436,7 +444,7 @@ const saveEdit = async () => {state.editing = false;// If we update email, we need to redirect to the new email.- if (updateMaskPaths.includes("email") && props.principalEmail) {+ if (emailChanged && props.principalEmail) {router.replace({name: WORKSPACE_ROUTE_USER_PROFILE,params: {diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yamlindex 72c26d6f61..5bfbf57635 100644--- a/proto/gen/grpc-doc/openapi.yaml+++ b/proto/gen/grpc-doc/openapi.yaml@@ -7203,6 +7203,7 @@ paths:- UserServicedescription: |-Updates a user. Users can update their own profile, or users with bb.users.update permission can update any user.+ Note: Email updates are not supported through this API. Use UpdateEmail instead.Permissions required: bb.users.update (or self)operationId: UserService_UpdateUserparameters:@@ -7295,6 +7296,40 @@ paths:application/json:schema:$ref: '#/components/schemas/Status'+ /v1/users/{user}:updateEmail:+ post:+ tags:+ - UserService+ description: |-+ Updates a user's email address.+ Permissions required: bb.users.updateEmail+ operationId: UserService_UpdateEmail+ parameters:+ - name: user+ in: path+ description: The user id.+ required: true+ schema:+ type: string+ requestBody:+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/UpdateEmailRequest'+ required: true+ responses:+ "200":+ description: OK+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/User'+ default:+ description: Default error response+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/Status'/v1/users:batchGet:get:tags:@@ -15250,6 +15285,20 @@ components:description: |-If set to true, and the database is not found, a new database will be created.In this situation, `update_mask` is ignored.+ UpdateEmailRequest:+ required:+ - name+ type: object+ properties:+ name:+ type: string+ description: |-+ The name of the user whose email to update.+ Format: users/{user email}+ email:+ type: string+ description: The new email address.UpdateInstanceRequest:required:- instancediff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex 8e09fd47e0..465f1e109f 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -120,6 +120,7 @@- [ListUsersRequest](#bytebase-v1-ListUsersRequest)- [ListUsersResponse](#bytebase-v1-ListUsersResponse)- [UndeleteUserRequest](#bytebase-v1-UndeleteUserRequest)+ - [UpdateEmailRequest](#bytebase-v1-UpdateEmailRequest)- [UpdateUserRequest](#bytebase-v1-UpdateUserRequest)- [User](#bytebase-v1-User)- [User.Profile](#bytebase-v1-User-Profile)@@ -2459,6 +2460,22 @@ For example: name == "ed" name.matches("ed") email == "ed@by+<a name="bytebase-v1-UpdateEmailRequest"></a>++### UpdateEmailRequest++++| Field | Type | Label | Description |+| ----- | ---- | ----- | ----------- |+| name | [string](#string) | | The name of the user whose email to update. Format: users/{user email} |+| email | [string](#string) | | The new email address. |++++++<a name="bytebase-v1-UpdateUserRequest"></a>### UpdateUserRequest@@ -2558,9 +2575,10 @@ UserService manages user accounts and authentication.| GetCurrentUser | [.google.protobuf.Empty](#google-protobuf-Empty) | [User](#bytebase-v1-User) | Get the current authenticated user. Permissions required: None || ListUsers | [ListUsersRequest](#bytebase-v1-ListUsersRequest) | [ListUsersResponse](#bytebase-v1-ListUsersResponse) | List all users. Any authenticated user can list users. Permissions required: bb.users.list || CreateUser | [CreateUserRequest](#bytebase-v1-CreateUserRequest) | [User](#bytebase-v1-User) | Creates a user. When Disallow Signup is enabled, requires bb.users.create permission; otherwise any user can sign up. Permissions required: bb.users.create (only when Disallow Signup is enabled) |-| UpdateUser | [UpdateUserRequest](#bytebase-v1-UpdateUserRequest) | [User](#bytebase-v1-User) | Updates a user. Users can update their own profile, or users with bb.users.update permission can update any user. Permissions required: bb.users.update (or self) |+| UpdateUser | [UpdateUserRequest](#bytebase-v1-UpdateUserRequest) | [User](#bytebase-v1-User) | Updates a user. Users can update their own profile, or users with bb.users.update permission can update any user. Note: Email updates are not supported through this API. Use UpdateEmail instead. Permissions required: bb.users.update (or self) || DeleteUser | [DeleteUserRequest](#bytebase-v1-DeleteUserRequest) | [.google.protobuf.Empty](#google-protobuf-Empty) | Deletes a user. Requires bb.users.delete permission with additional validation: the last remaining workspace admin cannot be deleted. Permissions required: bb.users.delete || UndeleteUser | [UndeleteUserRequest](#bytebase-v1-UndeleteUserRequest) | [User](#bytebase-v1-User) | Restores a deleted user. Permissions required: bb.users.undelete |+| UpdateEmail | [UpdateEmailRequest](#bytebase-v1-UpdateEmailRequest) | [User](#bytebase-v1-User) | Updates a user's email address. Permissions required: bb.users.updateEmail |diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.htmlindex 434dfe4df9..883469b06a 100644--- a/proto/gen/grpc-doc/v1/index.html+++ b/proto/gen/grpc-doc/v1/index.html@@ -630,6 +630,10 @@<a href="#bytebase.v1.UndeleteUserRequest"><span class="badge">M</span>UndeleteUserRequest</a></li>+ <li>+ <a href="#bytebase.v1.UpdateEmailRequest"><span class="badge">M</span>UpdateEmailRequest</a>+ </li>+<li><a href="#bytebase.v1.UpdateUserRequest"><span class="badge">M</span>UpdateUserRequest</a></li>@@ -7269,6 +7273,38 @@ Format: users/{user} </p></td>+ <h3 id="bytebase.v1.UpdateEmailRequest">UpdateEmailRequest</h3>+ <p></p>+++ <table class="field-table">+ <thead>+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>+ </thead>+ <tbody>++ <tr>+ <td>name</td>+ <td><a href="#string">string</a></td>+ <td></td>+ <td><p>The name of the user whose email to update.+Format: users/{user email} </p></td>+ </tr>++ <tr>+ <td>email</td>+ <td><a href="#string">string</a></td>+ <td></td>+ <td><p>The new email address. </p></td>+ </tr>++ </tbody>+ </table>+++++<h3 id="bytebase.v1.UpdateUserRequest">UpdateUserRequest</h3><p></p>@@ -7586,6 +7622,7 @@ Permissions required: bb.users.create (only when Disallow Signup is enabled)</p><td><a href="#bytebase.v1.UpdateUserRequest">UpdateUserRequest</a></td><td><a href="#bytebase.v1.User">User</a></td><td><p>Updates a user. Users can update their own profile, or users with bb.users.update permission can update any user.+Note: Email updates are not supported through this API. Use UpdateEmail instead.Permissions required: bb.users.update (or self)</p></td></tr>@@ -7605,6 +7642,14 @@ Permissions required: bb.users.delete</p></td>Permissions required: bb.users.undelete</p></td></tr>+ <tr>+ <td>UpdateEmail</td>+ <td><a href="#bytebase.v1.UpdateEmailRequest">UpdateEmailRequest</a></td>+ <td><a href="#bytebase.v1.User">User</a></td>+ <td><p>Updates a user's email address.+Permissions required: bb.users.updateEmail</p></td>+ </tr>+</tbody></table>@@ -7703,6 +7748,16 @@ Permissions required: bb.users.undelete</p></td></tr>+++ <tr>+ <td>UpdateEmail</td>+ <td>POST</td>+ <td>/v1/{name=users/*}:updateEmail</td>+ <td>*</td>+ </tr>++</tbody></table>diff --git a/proto/v1/v1/user_service.proto b/proto/v1/v1/user_service.protoindex 67608c627e..b59f0166b8 100644--- a/proto/v1/v1/user_service.proto+++ b/proto/v1/v1/user_service.proto@@ -68,6 +68,7 @@ service UserService {}// Updates a user. Users can update their own profile, or users with bb.users.update permission can update any user.+ // Note: Email updates are not supported through this API. Use UpdateEmail instead.// Permissions required: bb.users.update (or self)rpc UpdateUser(UpdateUserRequest) returns (User) {option (google.api.http) = {@@ -98,6 +99,19 @@ service UserService {option (bytebase.v1.auth_method) = CUSTOM;option (bytebase.v1.audit) = true;}++ // Updates a user's email address.+ // Permissions required: bb.users.updateEmail+ rpc UpdateEmail(UpdateEmailRequest) returns (User) {+ option (google.api.http) = {+ post: "/v1/{name=users/*}:updateEmail"+ body: "*"+ };+ option (google.api.method_signature) = "name,email";+ option (bytebase.v1.permission) = "bb.users.updateEmail";+ option (bytebase.v1.auth_method) = IAM;+ option (bytebase.v1.audit) = true;+ }}message GetUserRequest {@@ -223,6 +237,18 @@ message UndeleteUserRequest {];}+message UpdateEmailRequest {+ // The name of the user whose email to update.+ // Format: users/{user email}+ string name = 1 [+ (google.api.field_behavior) = REQUIRED,+ (google.api.resource_reference) = {type: "bytebase.com/User"}+ ];++ // The new email address.+ string email = 2 [(google.api.field_behavior) = REQUIRED];+}+message User {option (google.api.resource) = {type: "bytebase.com/User"