MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / UpdateCurrent

Function UpdateCurrent

server/handles/auth.go:103–124  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

101}
102
103func UpdateCurrent(c *gin.Context) {
104 var req model.User
105 if err := c.ShouldBind(&req); err != nil {
106 common.ErrorResp(c, err, 400)
107 return
108 }
109 user := c.Request.Context().Value(conf.UserKey).(*model.User)
110 if user.IsGuest() {
111 common.ErrorStrResp(c, model.GuestCannotUpdateProfile, 403)
112 return
113 }
114 user.Username = req.Username
115 if req.Password != "" {
116 user.SetPassword(req.Password)
117 }
118 user.SsoID = req.SsoID
119 if err := op.UpdateUser(user); err != nil {
120 common.ErrorResp(c, err, 500)
121 } else {
122 common.SuccessResp(c)
123 }
124}
125
126func Generate2FA(c *gin.Context) {
127 user := c.Request.Context().Value(conf.UserKey).(*model.User)

Callers

nothing calls this directly

Calls 6

ErrorRespFunction · 0.92
ErrorStrRespFunction · 0.92
UpdateUserFunction · 0.92
SuccessRespFunction · 0.92
IsGuestMethod · 0.80
SetPasswordMethod · 0.65

Tested by

no test coverage detected