添加jwt鉴权中间件

This commit is contained in:
2025-08-28 17:44:20 +08:00
parent 0a3be6cf9e
commit 327f02630a
4 changed files with 95 additions and 8 deletions

View File

@@ -2,9 +2,9 @@ package system
import (
"errors"
"gin-admin/internal/auth"
"gin-admin/internal/core/config"
"gin-admin/internal/repository"
"gin-admin/pkg/auth"
"gin-admin/pkg/encrypt"
"gorm.io/gorm"
@@ -31,7 +31,7 @@ func SysUserLogin(username, password string) (string, error) {
return "", errors.New("用户已被禁用")
}
jwtToken, err := auth.CreateAccessToken(user.ID, user.Username, 3600)
jwtToken, err := auth.CreateAccessToken(user.ID, user.Username, config.Config.SecretKey)
if err != nil {
return "", errors.New("系统内部错误")
}