Commit fe9acdad authored by brent's avatar brent

modify web3auth

parent 22fce0a9
......@@ -10,7 +10,13 @@ debitTime = "0 46 15 * * ?"
;01 01 00 * * ?
; SessionProvider = "redis"
; SessionProviderConfig = "192.168.1.10:6379,1000"
web3ClientId = "BHciicCbodMasHsyVfcdPYCaCokJMK5wGs2H4IRCaseqNJlcb1Li4kExaf5gF5DoUx-m_77epCrRPq4XmQzzdRk"
web3ClientId = "BHFvULiKBqRN0Em-14M-bDO2eAvHL4F19hLxR4s7dkksiIx8cIk5VlZvJeJbf8WwT5bX3FMhil45HjVbmd1Wmk4"
; [test]
; web3ClientId = "BHFvULiKBqRN0Em-14M-bDO2eAvHL4F19hLxR4s7dkksiIx8cIk5VlZvJeJbf8WwT5bX3FMhil45HjVbmd1Wmk4"
;
; [prod]
; web3ClientId = "BIJGFN6ZVU5DNxMXT6Y0biT2Kzt09YJTbZK-5Pb2OLeGYOixHxKBFkmKIb42qrhnZzjBGMDN_PVPYJosqC02tuI"
include "mysql.conf"
include "kong.conf"
......
......@@ -92,7 +92,7 @@ func (server *AppController) ApiKeys() {
if info.Role == 1 || info.Role == 2 {
qs = mysql.GetMysqlInstace().Ormer.QueryTable("api_key")
}
keyQs := qs.Offset(offset).Limit(appRequest.Size)
keyQs := qs.OrderBy("-created_time").Offset(offset).Limit(appRequest.Size)
count, err := keyQs.Count()
logs.Debug("Count = ", count)
......
......@@ -110,6 +110,13 @@ func (server *UserController) Login() {
return
}
}
key := "token:user-" + strconv.Itoa(checkUser.Id)
session, err := redis.GetDataToString(key)
if session != "" {
server.Ctx.Output.Header("Authorization", session)
server.respond(http.StatusOK, "")
return
}
duration := claims.Exp - claims.Iat
tokenString, err := utils.GenerateToken(checkUser, checkUser.Id, int(duration))
if err != nil {
......@@ -124,7 +131,6 @@ func (server *UserController) Login() {
// odysseus.SyncCredit(strconv.Itoa(checkUser.Id), checkUserLevel.FreeQuota)
//}
key := "token:user-" + strconv.Itoa(checkUser.Id)
//u.SetSession(key, tokenString)
//lifetime, _ := beego.AppConfig.Int64("sessiongcmaxlifetime")
redis.SetKeyAndData(key, tokenString, time.Duration(duration)*time.Second)
......
......@@ -19,7 +19,9 @@ func GetOrmer() orm.Ormer {
func init() {
//return
logs.Debug("postgres lib init")
orm.Debug = true
//clientId, _ := beego.AppConfig.String("web3ClientId")
//logs.Debug("clientId", clientId)
//orm.Debug = true
if err := orm.RegisterDriver("postgres", orm.DRPostgres); err != nil {
logs.Error(err.Error())
}
......
......@@ -13,6 +13,8 @@ import (
)
func init() {
runmode, _ := beego.AppConfig.String("runmode")
if runmode != "prod" {
beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
AllowAllOrigins: true,
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
......@@ -20,6 +22,8 @@ func init() {
ExposeHeaders: []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type", "X-Xsrf-Token", "Authorization"},
AllowCredentials: true,
}))
}
beego.SetStaticPath("/uploads", "uploads")
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment