diff --git a/controllers/client/login.go b/controllers/client/login.go index 661ece4..38518cb 100644 --- a/controllers/client/login.go +++ b/controllers/client/login.go @@ -161,7 +161,6 @@ func (t *UserCtl) WxLogin() { } func (t *UserCtl) Login() { - activityId := t.MustGetInt("activity_id") wxcode := t.MustGet("code") user := new(models.User) @@ -177,23 +176,25 @@ func (t *UserCtl) Login() { area := &models.AreaStore{} admin := 0 - if username, ok := t.Get("username"); ok && username != "" { - username := t.MustGet("username") - password := t.MustGet("password") - exist, err := area.Login(activityId, username, password) - t.CheckErr(err) - t.Assert(exist, code.MSG_ERR_Authority, "不存在地区管理员") - if area.UserId != user.Id { - area.UserId = user.Id - _, err = models.Update(area.Id, area, "user_id") + if activityId, ok := t.GetInt("activity_id"); ok && activityId != 0 { + if username, ok := t.Get("username"); ok && username != "" { + username := t.MustGet("username") + password := t.MustGet("password") + exist, err := area.Login(activityId, username, password) t.CheckErr(err) - } - admin = 1 - } else { - exist, err := area.GetByUserId(activityId, user.Id) - t.CheckErr(err) - if exist { // 管理员 + t.Assert(exist, code.MSG_ERR_Authority, "不存在地区管理员") + if area.UserId != user.Id { + area.UserId = user.Id + _, err = models.Update(area.Id, area, "user_id") + t.CheckErr(err) + } admin = 1 + } else { + exist, err := area.GetByUserId(activityId, user.Id) + t.CheckErr(err) + if exist { // 管理员 + admin = 1 + } } }