1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-06-27 16:36:00 +00:00

Fix regression in integration page and simplify SQL query

This commit is contained in:
Frédéric Guillot 2023-07-10 20:59:49 -07:00
parent 309e6d1084
commit 7988241e11
4 changed files with 72 additions and 174 deletions

View file

@ -9,6 +9,7 @@ import (
"runtime"
"strings"
"miniflux.app/crypto"
"miniflux.app/logger"
"miniflux.app/model"
@ -57,7 +58,7 @@ func (s *Storage) CreateUser(userCreationRequest *model.UserCreationRequest) (*m
var hashedPassword string
if userCreationRequest.Password != "" {
var err error
hashedPassword, err = hashPassword(userCreationRequest.Password)
hashedPassword, err = crypto.HashPassword(userCreationRequest.Password)
if err != nil {
return nil, err
}
@ -157,7 +158,7 @@ func (s *Storage) CreateUser(userCreationRequest *model.UserCreationRequest) (*m
// UpdateUser updates a user.
func (s *Storage) UpdateUser(user *model.User) error {
if user.Password != "" {
hashedPassword, err := hashPassword(user.Password)
hashedPassword, err := crypto.HashPassword(user.Password)
if err != nil {
return err
}
@ -649,8 +650,3 @@ func (s *Storage) HasPassword(userID int64) (bool, error) {
}
return false, nil
}
func hashPassword(password string) (string, error) {
bytes, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
return string(bytes), err
}