MCPcopy Create free account
hub / github.com/OpenCSGs/csghub-server / Update

Method Update

user/handler/member.go:83–103  ·  view source on GitHub ↗

UpdateMember godoc @Security ApiKey @Summary update user membership @Tags Member @Accept json @Produce json @Param namespace path string true "org name" @Param username path string true "user name" @Param current_user query string false "the op user

(ctx *gin.Context)

Source from the content-addressed store, hash-verified

81// @Failure 500 {object} types.APIInternalServerError "Internal server error"
82// @Router /organization/{namespace}/members/{username} [put]
83func (h *MemberHandler) Update(ctx *gin.Context) {
84 type updateMemberRequest struct {
85 OldRole string `json:"old_role" binding:"required"`
86 NewRole string `json:"new_role" binding:"required"`
87 }
88 req := new(updateMemberRequest)
89 if err := ctx.ShouldBindJSON(req); err != nil {
90 httpbase.BadRequest(ctx, fmt.Errorf("failed to unmarshal request body,caused by:%w", err).Error())
91 return
92 }
93 currentUser := httpbase.GetCurrentUser(ctx)
94 org := ctx.Param("namespace")
95 userName := ctx.Param("username")
96 err := h.c.ChangeMemberRole(ctx, org, userName, currentUser, req.OldRole, req.NewRole)
97 if err != nil {
98 httpbase.ServerError(ctx, err)
99 return
100 }
101
102 httpbase.OK(ctx, nil)
103}
104
105// Create godoc
106// @Security ApiKey

Callers

nothing calls this directly

Calls 6

BadRequestFunction · 0.92
GetCurrentUserFunction · 0.92
ServerErrorFunction · 0.92
OKFunction · 0.92
ErrorMethod · 0.80
ChangeMemberRoleMethod · 0.80

Tested by

no test coverage detected