MCPcopy Index your code
hub / github.com/TruthHun/BookStack / EditMember

Method EditMember

controllers/ManagerController.go:285–339  ·  view source on GitHub ↗

编辑用户信息.

()

Source from the content-addressed store, hash-verified

283
284// 编辑用户信息.
285func (this *ManagerController) EditMember() {
286
287 memberId, _ := this.GetInt(":id", 0)
288 if memberId <= 0 {
289 this.Abort("404")
290 }
291
292 member, err := models.NewMember().Find(memberId)
293 if err != nil {
294 beego.Error(err)
295 this.Abort("404")
296 }
297
298 if this.Ctx.Input.IsPost() {
299 password1 := this.GetString("password1")
300 password2 := this.GetString("password2")
301 email := this.GetString("email")
302 phone := this.GetString("phone")
303 description := this.GetString("description")
304 member.Email = email
305 member.Phone = phone
306 member.Description = description
307 if password1 != "" && password2 != password1 {
308 this.JsonResult(6001, "确认密码不正确")
309 }
310 if password1 != "" && member.AuthMethod != conf.AuthMethodLDAP {
311 member.Password = password1
312 }
313 if err := member.Valid(password1 == ""); err != nil {
314 this.JsonResult(6002, err.Error())
315 }
316 if password1 != "" {
317 password, err := utils.PasswordHash(password1)
318 if err != nil {
319 beego.Error(err)
320 this.JsonResult(6003, "对用户密码加密时出错")
321 }
322 member.Password = password
323 }
324 if err := member.Update(); err != nil {
325 beego.Error(err)
326 this.JsonResult(6004, "保存失败")
327 }
328 this.JsonResult(0, "ok")
329 }
330
331 this.GetSeoByPage("manage_users_edit", map[string]string{
332 "title": "用户编辑 - " + this.Sitename,
333 "keywords": "用户标记",
334 "description": this.Sitename + "专注于文档在线写作、协作、分享、阅读与托管,让每个人更方便地发布、分享和获得知识。",
335 })
336 this.Data["IsUsers"] = true
337 this.Data["Model"] = member
338 this.TplName = "manager/edit_users.html"
339}
340
341// 删除一个用户,并将该用户的所有信息转移到超级管理员上.
342func (this *ManagerController) DeleteMember() {

Callers

nothing calls this directly

Calls 7

NewMemberFunction · 0.92
PasswordHashFunction · 0.92
JsonResultMethod · 0.80
ValidMethod · 0.80
GetSeoByPageMethod · 0.80
FindMethod · 0.45
UpdateMethod · 0.45

Tested by

no test coverage detected