|
@@ -2,6 +2,7 @@ package apps
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
"fmt"
|
|
"fmt"
|
|
|
|
|
+ "fohow.com/apps/models/token_model"
|
|
|
"regexp"
|
|
"regexp"
|
|
|
"strings"
|
|
"strings"
|
|
|
// "time"
|
|
// "time"
|
|
@@ -14,9 +15,6 @@ import (
|
|
|
// "fohow.com/apps/models/balance_model"
|
|
// "fohow.com/apps/models/balance_model"
|
|
|
"fohow.com/apps/models/channel_gzh_qrcode_model"
|
|
"fohow.com/apps/models/channel_gzh_qrcode_model"
|
|
|
"fohow.com/apps/models/user_model"
|
|
"fohow.com/apps/models/user_model"
|
|
|
- // "fohow.com/libs/tool"
|
|
|
|
|
- // "fohow.com/libs/wx_mp"
|
|
|
|
|
- "fohow.com/libs/tool"
|
|
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
const (
|
|
@@ -66,7 +64,7 @@ var (
|
|
|
// 登录相关
|
|
// 登录相关
|
|
|
HasLogin = []string{"hasLogin", "已登录"}
|
|
HasLogin = []string{"hasLogin", "已登录"}
|
|
|
HasLogout = []string{"hasLogout", "已登出"}
|
|
HasLogout = []string{"hasLogout", "已登出"}
|
|
|
- UserNeedLogin = []string{"userNeedLogin", "需要用户登录"}
|
|
|
|
|
|
|
+ UserNeedLogin = []string{"userNeedLogin", "授权无效,需要用户登录"}
|
|
|
UserAuthorizeFailed = []string{"userAuthorizeFailed", "用户授权失败"}
|
|
UserAuthorizeFailed = []string{"userAuthorizeFailed", "用户授权失败"}
|
|
|
UserNeedTel = []string{"userNeedTel", "需要用户绑定手机"}
|
|
UserNeedTel = []string{"userNeedTel", "需要用户绑定手机"}
|
|
|
UserTelNotMatch = []string{"userTelNotMatch", "手机号码不匹配,请使用当前登录用户的号码"}
|
|
UserTelNotMatch = []string{"userTelNotMatch", "手机号码不匹配,请使用当前登录用户的号码"}
|
|
@@ -425,11 +423,14 @@ func checkWxUserLogin(ctx *context.Context) {
|
|
|
ctx.Output.JSON(errCode, true, true)
|
|
ctx.Output.JSON(errCode, true, true)
|
|
|
}
|
|
}
|
|
|
inputToken = authorizationData[1]
|
|
inputToken = authorizationData[1]
|
|
|
- err, tel := tool.CheckToken(inputToken)
|
|
|
|
|
- user := user_model.GetByTel(tel, true)
|
|
|
|
|
- wxUser := user_model.GetWxUserByUserId(user.Id, true)
|
|
|
|
|
|
|
+ var wxUser *user_model.WxUser
|
|
|
|
|
+ var user *user_model.User
|
|
|
|
|
+ user_token, err := token_model.ValidateToken(inputToken)
|
|
|
|
|
+ if err == nil {
|
|
|
|
|
+ user = user_model.GetByTel(user_token.Tel, true)
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if err != nil || (user == nil) || (wxUser == nil) {
|
|
|
|
|
|
|
+ if err != nil || user == nil {
|
|
|
// 验证 Token 无效
|
|
// 验证 Token 无效
|
|
|
errCode := &ErrCode{
|
|
errCode := &ErrCode{
|
|
|
Code: UserNeedLogin[0],
|
|
Code: UserNeedLogin[0],
|
|
@@ -441,6 +442,8 @@ func checkWxUserLogin(ctx *context.Context) {
|
|
|
ctx.Output.JSON(errCode, true, true)
|
|
ctx.Output.JSON(errCode, true, true)
|
|
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ wxUser = user_model.GetWxUserByUserId(user.Id, true)
|
|
|
|
|
+
|
|
|
ctx.Output.Session(SessionUserKey, wxUser.UserId)
|
|
ctx.Output.Session(SessionUserKey, wxUser.UserId)
|
|
|
ctx.Output.Session(SessionWxUserKey, wxUser.Id)
|
|
ctx.Output.Session(SessionWxUserKey, wxUser.Id)
|
|
|
}
|
|
}
|