structure: 确定基本结构(保持基本形式, 采用组合)
This commit is contained in:
@@ -9,10 +9,10 @@ import (
|
||||
"gorm.io/gorm"
|
||||
"net/http"
|
||||
"time"
|
||||
"uauth/internal/store/cache"
|
||||
"uauth/internal/store/db"
|
||||
"uauth/internal/tool"
|
||||
"uauth/model"
|
||||
"uauth/pkg/cache"
|
||||
"uauth/pkg/store"
|
||||
"uauth/tool"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -43,7 +43,8 @@ func LoginPage(c *nf.Ctx) error {
|
||||
return resp.Resp400(c, req)
|
||||
}
|
||||
|
||||
if err = db.Default.Session().Model(&model.Client{}).
|
||||
if err = store.Default.Session(tool.TimeoutCtx(c.Context(), 3)).
|
||||
Model(&model.Client{}).
|
||||
Where("client_id = ?", req.ClientId).
|
||||
Take(client).
|
||||
Error; err != nil {
|
||||
@@ -96,7 +97,8 @@ func LoginAction(c *nf.Ctx) error {
|
||||
return c.Status(http.StatusBadRequest).SendString("Bad Request: username, password is required")
|
||||
}
|
||||
|
||||
if err = db.Default.Session().Model(&model.User{}).
|
||||
if err = store.Default.Session(tool.TimeoutCtx(c.Context(), 3)).
|
||||
Model(&model.User{}).
|
||||
Where("username = ?", req.Username).
|
||||
Take(op).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
|
||||
Reference in New Issue
Block a user