Commit bc10a748 by xuzhenhao

增加了检查用户登录信息的接口

1 parent df39c69c
......@@ -15,7 +15,7 @@ import (
// "reflect"
// "strconv"
// "strings"
// "time"
"time"
)
//登录接口
......@@ -47,12 +47,13 @@ func UserLoginApi(c *gin.Context) {
Value: result.(map[string]interface{})["token"].(string),
Path: "/",
HttpOnly: true,
Expires: time.Now().Add(2 * time.Hour),
}
res := map[string]interface{}{
"user_id": result.(map[string]interface{})["user_id"].(int),
}
// res := map[string]interface{}{
// "user_id": result.(map[string]interface{})["user_id"].(int),
// }
http.SetCookie(c.Writer, cookie)
ReturnRespones(c, "0", res)
ReturnRespones(c, "0", "authorize success")
return
}
......
......@@ -172,9 +172,9 @@ func CheckUserAccessToken(token string) (result string, err error) {
}
if len(r) == 0 {
err = errors.New("token已失效")
return "false", nil
return "", nil
}
return "true", nil
return string(r[0]["user_id"]), nil
}
//生成外部应用授权
......@@ -199,7 +199,7 @@ func CheckThirdpartAccessToken(token string) (result string, err error) {
err = errors.New("token已失效")
return "false", nil
}
return "true", nil
return string(r[0]["user_id"]), nil
}
func MD5(str string) string {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!