chore: remove useless card style -- fix build error

This commit is contained in:
engigu
2026-03-12 10:53:57 +08:00
parent fe6af5dab4
commit d79a26c7f5
2 changed files with 10 additions and 2 deletions
+2 -2
View File
@@ -169,8 +169,8 @@ func (ac *AuthController) Logout(c *gin.Context) {
func (ac *AuthController) GetCurrentUser(c *gin.Context) {
userID := c.GetString("userID")
var user models.User
if err := database.DB.Where("id = ?", userID).First(&user).Error; err != nil {
user, err := ac.userService.GetUserByID(userID)
if err != nil {
utils.Unauthorized(c, "会话无效")
return
}
+8
View File
@@ -57,6 +57,14 @@ func (us *UserService) GetUserByUsername(username string) *models.User {
return &user
}
func (us *UserService) GetUserByID(id string) (*models.User, error) {
var user models.User
if err := database.DB.Where("id = ?", id).First(&user).Error; err != nil {
return nil, err
}
return &user, nil
}
func (us *UserService) ValidatePassword(user *models.User, password string) bool {
// 尝试 bcrypt 校验
err := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(password))