|
@@ -6,8 +6,6 @@ import (
|
|
|
"net/http"
|
|
|
"net/url"
|
|
|
"strconv"
|
|
|
- "strings"
|
|
|
-
|
|
|
"github.com/astaxie/beego"
|
|
|
|
|
|
"hongze/hongze_api/models"
|
|
@@ -41,31 +39,31 @@ func (this *BaseAuthController) Prepare() {
|
|
|
this.StopRun()
|
|
|
return
|
|
|
}
|
|
|
- authorizationArr := strings.Split(authorization, ",")
|
|
|
- tokenStr := authorizationArr[0]
|
|
|
- tokenArr := strings.Split(tokenStr, "=")
|
|
|
- token := tokenArr[1]
|
|
|
-
|
|
|
- accountStr := authorizationArr[1]
|
|
|
- accountArr := strings.Split(accountStr, "=")
|
|
|
- account := accountArr[1]
|
|
|
-
|
|
|
- fmt.Println("token:", token)
|
|
|
- fmt.Println("account:", account)
|
|
|
- //校验token是否合法
|
|
|
- // JWT校验Token和Account
|
|
|
- if !utils.CheckToken(account, token) {
|
|
|
- fmt.Println("CheckToken Err")
|
|
|
- this.JSON(models.BaseResponse{Ret: 408, Msg: "鉴权失败,请重新登录!", ErrMsg: "登录失效,请重新登陆!,CheckToken Fail"}, false, false)
|
|
|
- this.StopRun()
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- fmt.Println("GetUserByToken")
|
|
|
- session, err := models.GetSessionByToken(token)
|
|
|
+ //authorizationArr := strings.Split(authorization, ",")
|
|
|
+ //tokenStr := authorizationArr[0]
|
|
|
+ //tokenArr := strings.Split(tokenStr, "=")
|
|
|
+ //token := tokenArr[1]
|
|
|
+ //
|
|
|
+ //accountStr := authorizationArr[1]
|
|
|
+ //accountArr := strings.Split(accountStr, "=")
|
|
|
+ //account := accountArr[1]
|
|
|
+ //
|
|
|
+ //fmt.Println("token:", token)
|
|
|
+ //fmt.Println("account:", account)
|
|
|
+ ////校验token是否合法
|
|
|
+ //// JWT校验Token和Account
|
|
|
+ //if !utils.CheckToken(account, token) {
|
|
|
+ // fmt.Println("CheckToken Err")
|
|
|
+ // this.JSON(models.BaseResponse{Ret: 408, Msg: "鉴权失败,请重新登录!", ErrMsg: "登录失效,请重新登陆!,CheckToken Fail"}, false, false)
|
|
|
+ // this.StopRun()
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ //
|
|
|
+ //fmt.Println("GetUserByToken")
|
|
|
+ session, err := models.GetSessionByToken(authorization)
|
|
|
if err != nil {
|
|
|
if err.Error() == utils.ErrNoRow() {
|
|
|
- this.JSON(models.BaseResponse{Ret: 408, Msg: "信息已变更,请重新登陆!", ErrMsg: "Token 信息已变更:Token: " + token}, false, false)
|
|
|
+ this.JSON(models.BaseResponse{Ret: 408, Msg: "信息已变更,请重新登陆!", ErrMsg: "Token 信息已变更:Token: " + authorization}, false, false)
|
|
|
this.StopRun()
|
|
|
return
|
|
|
}
|