🎨 update / add nsq
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
"github.com/mssola/useragent"
|
||||
"gorm.io/gorm"
|
||||
"net/http"
|
||||
"schisandra-cloud-album/api/user_api/dto"
|
||||
"schisandra-cloud-album/common/constant"
|
||||
"schisandra-cloud-album/common/redis"
|
||||
"schisandra-cloud-album/common/result"
|
||||
@@ -95,13 +94,13 @@ func HandelUserLogin(userId string, c *gin.Context) (bool, result.Response) {
|
||||
case expiresAt = <-expiresAtChan:
|
||||
}
|
||||
|
||||
data := dto.ResponseData{
|
||||
data := ResponseData{
|
||||
AccessToken: accessToken,
|
||||
RefreshToken: refreshToken,
|
||||
ExpiresAt: expiresAt,
|
||||
UID: &userId,
|
||||
}
|
||||
wrong := utils.SetSession(c, "user", data)
|
||||
wrong := utils.SetSession(c, constant.SessionKey, data)
|
||||
if wrong != nil {
|
||||
return false, result.Response{}
|
||||
}
|
||||
|
19
api/oauth_api/request_param.go
Normal file
19
api/oauth_api/request_param.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package oauth_api
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
// ResponseData 返回数据
|
||||
type ResponseData struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
ExpiresAt int64 `json:"expires_at"`
|
||||
UID *string `json:"uid"`
|
||||
}
|
||||
|
||||
func (res ResponseData) MarshalBinary() ([]byte, error) {
|
||||
return json.Marshal(res)
|
||||
}
|
||||
|
||||
func (res ResponseData) UnmarshalBinary(data []byte) error {
|
||||
return json.Unmarshal(data, &res)
|
||||
}
|
@@ -14,7 +14,6 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/yitter/idgenerator-go/idgen"
|
||||
"gorm.io/gorm"
|
||||
"schisandra-cloud-album/api/user_api/dto"
|
||||
"schisandra-cloud-album/api/websocket_api"
|
||||
"schisandra-cloud-album/common/constant"
|
||||
"schisandra-cloud-album/common/enum"
|
||||
@@ -291,7 +290,7 @@ func handelUserLogin(userId string, clientId string, c *gin.Context) bool {
|
||||
return
|
||||
}
|
||||
refreshToken, expiresAt := utils.GenerateRefreshToken(utils.RefreshJWTPayload{UserID: &userId}, time.Hour*24*7)
|
||||
data := dto.ResponseData{
|
||||
data := ResponseData{
|
||||
AccessToken: accessToken,
|
||||
RefreshToken: refreshToken,
|
||||
ExpiresAt: expiresAt,
|
||||
@@ -313,8 +312,8 @@ func handelUserLogin(userId string, clientId string, c *gin.Context) bool {
|
||||
resultChan <- false
|
||||
return
|
||||
}
|
||||
gob.Register(dto.ResponseData{})
|
||||
wrong := utils.SetSession(c, "user", data)
|
||||
gob.Register(ResponseData{})
|
||||
wrong := utils.SetSession(c, constant.SessionKey, data)
|
||||
if wrong != nil {
|
||||
resultChan <- false
|
||||
return
|
||||
|
Reference in New Issue
Block a user