Commit bc10a748 by xuzhenhao

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

1 parent df39c69c
...@@ -15,7 +15,7 @@ import ( ...@@ -15,7 +15,7 @@ import (
// "reflect" // "reflect"
// "strconv" // "strconv"
// "strings" // "strings"
// "time" "time"
) )
//登录接口 //登录接口
...@@ -47,12 +47,13 @@ func UserLoginApi(c *gin.Context) { ...@@ -47,12 +47,13 @@ func UserLoginApi(c *gin.Context) {
Value: result.(map[string]interface{})["token"].(string), Value: result.(map[string]interface{})["token"].(string),
Path: "/", Path: "/",
HttpOnly: true, HttpOnly: true,
Expires: time.Now().Add(2 * time.Hour),
} }
res := map[string]interface{}{ // res := map[string]interface{}{
"user_id": result.(map[string]interface{})["user_id"].(int), // "user_id": result.(map[string]interface{})["user_id"].(int),
} // }
http.SetCookie(c.Writer, cookie) http.SetCookie(c.Writer, cookie)
ReturnRespones(c, "0", res) ReturnRespones(c, "0", "authorize success")
return return
} }
......
...@@ -172,9 +172,9 @@ func CheckUserAccessToken(token string) (result string, err error) { ...@@ -172,9 +172,9 @@ func CheckUserAccessToken(token string) (result string, err error) {
} }
if len(r) == 0 { if len(r) == 0 {
err = errors.New("token已失效") 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) { ...@@ -199,7 +199,7 @@ func CheckThirdpartAccessToken(token string) (result string, err error) {
err = errors.New("token已失效") err = errors.New("token已失效")
return "false", nil return "false", nil
} }
return "true", nil return string(r[0]["user_id"]), nil
} }
func MD5(str string) string { 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!