Skip to content

Commit

Permalink
fix: 修复 Auth 问题
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Dec 22, 2023
1 parent 8bfef80 commit e453636
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/http/controllers/setting_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (r *SettingController) List(ctx http.Context) http.Response {
}

var user models.User
err = facades.Auth().User(ctx, &user)
err = facades.Auth(ctx).User(&user)
if err != nil {
facades.Log().Request(ctx.Request()).Tags("面板", "面板设置").With(map[string]any{
"error": err.Error(),
Expand Down Expand Up @@ -126,7 +126,7 @@ func (r *SettingController) Update(ctx http.Context) http.Response {
}

var user models.User
err = facades.Auth().User(ctx, &user)
err = facades.Auth(ctx).User(&user)
if err != nil {
return ErrorSystem(ctx)
}
Expand Down
4 changes: 2 additions & 2 deletions app/http/controllers/user_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (r *UserController) Login(ctx http.Context) http.Response {
}
}

token, loginErr := facades.Auth().LoginUsingID(ctx, user.ID)
token, loginErr := facades.Auth(ctx).LoginUsingID(user.ID)
if loginErr != nil {
facades.Log().Request(ctx.Request()).Tags("面板", "用户").With(map[string]any{
"error": err.Error(),
Expand All @@ -84,7 +84,7 @@ func (r *UserController) Login(ctx http.Context) http.Response {
// @Router /panel/user/info [get]
func (r *UserController) Info(ctx http.Context) http.Response {
var user models.User
err := facades.Auth().User(ctx, &user)
err := facades.Auth(ctx).User(&user)
if err != nil {
facades.Log().Request(ctx.Request()).Tags("面板", "用户").With(map[string]any{
"error": err.Error(),
Expand Down
4 changes: 2 additions & 2 deletions app/http/middleware/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ func Jwt() http.Middleware {
}

// JWT 鉴权
if _, err := facades.Auth().Parse(ctx, token); err != nil {
if _, err := facades.Auth(ctx).Parse(token); err != nil {
if errors.Is(err, auth.ErrorTokenExpired) {
token, err = facades.Auth().Refresh(ctx)
token, err = facades.Auth(ctx).Refresh()
if err != nil {
// 到达刷新时间上限
ctx.Request().AbortWithStatusJson(http.StatusOK, http.Json{
Expand Down

0 comments on commit e453636

Please sign in to comment.