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

Method Index

controllers/SettingController.go:28–63  ·  view source on GitHub ↗

基本信息

()

Source from the content-addressed store, hash-verified

26
27// 基本信息
28func (this *SettingController) Index() {
29 if this.Ctx.Input.IsPost() {
30 email := strings.TrimSpace(this.GetString("email", ""))
31 phone := strings.TrimSpace(this.GetString("phone"))
32 wechatNO := strings.TrimSpace(this.GetString("wechat_no"))
33 description := strings.TrimSpace(this.GetString("description"))
34 nickname := strings.TrimSpace(this.GetString("nickname"))
35 if email == "" {
36 this.JsonResult(601, "邮箱不能为空")
37 }
38
39 if l := strings.Count(nickname, "") - 1; l < 2 || l > 20 {
40 this.JsonResult(6004, "用户昵称限制在2-20个字符")
41 }
42
43 existMember := models.NewMember().FindByNickname(nickname, "member_id")
44 if existMember.MemberId > 0 && this.Member.MemberId != existMember.MemberId {
45 this.JsonResult(6004, "用户昵称已存在,请换一个")
46 }
47
48 member := this.Member
49 member.Email = email
50 member.Phone = phone
51 member.WechatNO = wechatNO
52 member.Description = description
53 member.Nickname = nickname
54 if err := member.Update(); err != nil {
55 this.JsonResult(602, err.Error())
56 }
57 this.SetMember(*member)
58 this.JsonResult(0, "ok")
59 }
60 this.Data["SeoTitle"] = "基本信息 - " + this.Sitename
61 this.Data["SettingBasic"] = true
62 this.TplName = "setting/index.html"
63}
64
65// 修改密码
66func (this *SettingController) Password() {

Callers

nothing calls this directly

Calls 6

NewMemberFunction · 0.92
JsonResultMethod · 0.80
FindByNicknameMethod · 0.80
SetMemberMethod · 0.80
CountMethod · 0.45
UpdateMethod · 0.45

Tested by

no test coverage detected