MCPcopy Create free account
hub / github.com/TalkingData/owl / changeUserPassword

Function changeUserPassword

api/users.go:243–266  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

241}
242
243func changeUserPassword(c *gin.Context) {
244 response := gin.H{"code": http.StatusOK}
245 defer c.JSON(http.StatusOK, response)
246 username, _ := c.GetPostForm("username")
247 password, _ := c.GetPostForm("password")
248 newPassword, _ := c.GetPostForm("new_password")
249 user := mydb.getUserProfile(username)
250 if user == nil {
251 response["code"] = http.StatusBadRequest
252 return
253 }
254 if user.Password != password {
255 response["code"] = http.StatusBadRequest
256 response["message"] = "password wrong"
257 return
258 }
259 user.Password = newPassword
260 if err := mydb.updateUserProfile(user); err != nil {
261 response["code"] = http.StatusInternalServerError
262 response["message"] = err.Error()
263 return
264 }
265 c.SetCookie("token", "", -1, "/", "", false, true)
266}
267
268func Login(c *gin.Context) {
269 response := gin.H{"code": http.StatusOK}

Callers

nothing calls this directly

Calls 2

getUserProfileMethod · 0.80
updateUserProfileMethod · 0.80

Tested by

no test coverage detected