Commit a67e7ef5 by xuzhenhao

增加了token的授权

1 parent d69c7f30
...@@ -48,8 +48,11 @@ func UserLoginApi(c *gin.Context) { ...@@ -48,8 +48,11 @@ func UserLoginApi(c *gin.Context) {
Path: "/", Path: "/",
HttpOnly: true, HttpOnly: true,
} }
res := map[string]string{
"user_id": result.(map[string]interface{})["user_id"].(string),
}
http.SetCookie(c.Writer, cookie) http.SetCookie(c.Writer, cookie)
ReturnRespones(c, "0", result) ReturnRespones(c, "0", res)
return return
} }
......
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"github.com/satori/go.uuid" "github.com/satori/go.uuid"
"log" "log"
db "loginserver/database" db "loginserver/database"
"strings"
) )
type UserLoginInfo struct { type UserLoginInfo struct {
...@@ -153,6 +154,7 @@ func GetUserAccessToken(userName string) (result string, err error) { ...@@ -153,6 +154,7 @@ func GetUserAccessToken(userName string) (result string, err error) {
} }
userId := userInfo.(UserInfo).Id userId := userInfo.(UserInfo).Id
uuid := uuid.NewV4().String() uuid := uuid.NewV4().String()
uuid = strings.Replace(uuid, '-', "", -1)
sql := ` replace into icesimba_user_token(user_id,user_token) values(?,?)` sql := ` replace into icesimba_user_token(user_id,user_token) values(?,?)`
_, err = db.Engine.Exec(sql, userId, uuid) _, err = db.Engine.Exec(sql, userId, uuid)
if err != nil { if err != nil {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!