✨ add session
This commit is contained in:
@@ -36,11 +36,11 @@ func (ClientAPI) GenerateClientId(c *gin.Context) {
|
||||
global.LOG.Error(err)
|
||||
return
|
||||
}
|
||||
err = redis.Set(constant.UserLoginClientRedisKey+ip, uid, time.Hour*24*7).Err()
|
||||
err = redis.Set(constant.UserLoginClientRedisKey+ip, uid.String(), time.Hour*24*7).Err()
|
||||
if err != nil {
|
||||
global.LOG.Error(err)
|
||||
return
|
||||
}
|
||||
result.OkWithData(uid, c)
|
||||
result.OkWithData(uid.String(), c)
|
||||
return
|
||||
}
|
||||
|
@@ -48,7 +48,8 @@ func HandleLoginResponse(c *gin.Context, uid string) {
|
||||
global.LOG.Error(err)
|
||||
return
|
||||
}
|
||||
formattedScript := fmt.Sprintf(script, tokenData, global.CONFIG.System.Web)
|
||||
|
||||
formattedScript := fmt.Sprintf(script, tokenData, global.CONFIG.System.WebURL())
|
||||
c.Data(http.StatusOK, "text/html; charset=utf-8", []byte(formattedScript))
|
||||
return
|
||||
}
|
||||
|
@@ -344,6 +344,11 @@ func handelUserLogin(user model.ScaAuthUser, autoLogin bool, c *gin.Context) {
|
||||
result.FailWithMessage(ginI18n.MustGetMessage(c, "LoginFailed"), c)
|
||||
return
|
||||
}
|
||||
err = utils.SetSession(c, "user", data)
|
||||
if err != nil {
|
||||
result.FailWithMessage(ginI18n.MustGetMessage(c, "LoginFailed"), c)
|
||||
return
|
||||
}
|
||||
result.OkWithData(data, c)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user