Browse Source

fix:bug

token_replace
黄梓健 4 years ago
parent
commit
1892bc4676
  1. 41
      controllers/client/login.go
  2. 3
      main.go

41
controllers/client/login.go

@ -161,9 +161,8 @@ func (t *UserCtl) WxLogin() {
}
func (t *UserCtl) Login() {
//activityId := t.MustGetInt("activity_id")
activityId := t.MustGetInt("activity_id")
wxcode := t.MustGet("code")
admin := t.DefaultInt("admin", 0)
user := new(models.User)
token, err := wechat.GetToken(wxcode)
@ -177,24 +176,26 @@ func (t *UserCtl) Login() {
}
area := &models.AreaStore{}
//if admin == 1 {
// 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")
// t.CheckErr(err)
// }
//} else {
// exist, err := area.GetByUserId(activityId, user.Id)
// t.CheckErr(err)
// if exist { // 管理员
// admin = 1
// }
//}
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")
t.CheckErr(err)
}
admin = 1
} else {
exist, err := area.GetByUserId(activityId, user.Id)
t.CheckErr(err)
if exist { // 管理员
admin = 1
}
}
jwtToken, err := jwt.GenJwtToken(define.TYPE_H5USER, user.Id, 0, 0, 0, 0)
t.CheckErr(err)

3
main.go

@ -6,11 +6,12 @@ import (
"hudongzhuanjia/controllers/client"
"hudongzhuanjia/controllers/common"
"hudongzhuanjia/controllers/pc"
"hudongzhuanjia/utils/define"
//_ "net/http/pprof"
)
func main() {
//define.SetDebug(true)
define.SetDebug(true)
// pc
core.GetInstanceRouterManage().Registered(new(pc.WsCtl)) // 用户

Loading…
Cancel
Save