mirror of
https://github.com/miniflux/v2.git
synced 2025-07-02 16:38:37 +00:00
Rename helper packages
This commit is contained in:
parent
3c3f397bf5
commit
c39f2e1a8d
31 changed files with 97 additions and 97 deletions
|
@ -13,15 +13,15 @@ import (
|
|||
|
||||
"github.com/lib/pq/hstore"
|
||||
|
||||
"github.com/miniflux/miniflux/helper"
|
||||
"github.com/miniflux/miniflux/model"
|
||||
"github.com/miniflux/miniflux/timer"
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
// SetLastLogin updates the last login date of a user.
|
||||
func (s *Storage) SetLastLogin(userID int64) error {
|
||||
defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:SetLastLogin] userID=%d", userID))
|
||||
defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:SetLastLogin] userID=%d", userID))
|
||||
query := "UPDATE users SET last_login_at=now() WHERE id=$1"
|
||||
_, err := s.db.Exec(query, userID)
|
||||
if err != nil {
|
||||
|
@ -33,7 +33,7 @@ func (s *Storage) SetLastLogin(userID int64) error {
|
|||
|
||||
// UserExists checks if a user exists by using the given username.
|
||||
func (s *Storage) UserExists(username string) bool {
|
||||
defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:UserExists] username=%s", username))
|
||||
defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:UserExists] username=%s", username))
|
||||
|
||||
var result int
|
||||
s.db.QueryRow(`SELECT count(*) as c FROM users WHERE username=LOWER($1)`, username).Scan(&result)
|
||||
|
@ -42,7 +42,7 @@ func (s *Storage) UserExists(username string) bool {
|
|||
|
||||
// AnotherUserExists checks if another user exists with the given username.
|
||||
func (s *Storage) AnotherUserExists(userID int64, username string) bool {
|
||||
defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:AnotherUserExists] userID=%d, username=%s", userID, username))
|
||||
defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:AnotherUserExists] userID=%d, username=%s", userID, username))
|
||||
|
||||
var result int
|
||||
s.db.QueryRow(`SELECT count(*) as c FROM users WHERE id != $1 AND username=LOWER($2)`, userID, username).Scan(&result)
|
||||
|
@ -51,7 +51,7 @@ func (s *Storage) AnotherUserExists(userID int64, username string) bool {
|
|||
|
||||
// CreateUser creates a new user.
|
||||
func (s *Storage) CreateUser(user *model.User) (err error) {
|
||||
defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:CreateUser] username=%s", user.Username))
|
||||
defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:CreateUser] username=%s", user.Username))
|
||||
password := ""
|
||||
extra := hstore.Hstore{Map: make(map[string]sql.NullString)}
|
||||
|
||||
|
@ -114,7 +114,7 @@ func (s *Storage) RemoveExtraField(userID int64, field string) error {
|
|||
|
||||
// UpdateUser updates a user.
|
||||
func (s *Storage) UpdateUser(user *model.User) error {
|
||||
defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:UpdateUser] userID=%d", user.ID))
|
||||
defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:UpdateUser] userID=%d", user.ID))
|
||||
|
||||
if user.Password != "" {
|
||||
hashedPassword, err := hashPassword(user.Password)
|
||||
|
@ -177,7 +177,7 @@ func (s *Storage) UpdateUser(user *model.User) error {
|
|||
|
||||
// UserByID finds a user by the ID.
|
||||
func (s *Storage) UserByID(userID int64) (*model.User, error) {
|
||||
defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:UserByID] userID=%d", userID))
|
||||
defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:UserByID] userID=%d", userID))
|
||||
query := `SELECT
|
||||
id, username, is_admin, theme, language, timezone, entry_direction, last_login_at, extra
|
||||
FROM users
|
||||
|
@ -188,7 +188,7 @@ func (s *Storage) UserByID(userID int64) (*model.User, error) {
|
|||
|
||||
// UserByUsername finds a user by the username.
|
||||
func (s *Storage) UserByUsername(username string) (*model.User, error) {
|
||||
defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:UserByUsername] username=%s", username))
|
||||
defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:UserByUsername] username=%s", username))
|
||||
query := `SELECT
|
||||
id, username, is_admin, theme, language, timezone, entry_direction, last_login_at, extra
|
||||
FROM users
|
||||
|
@ -199,7 +199,7 @@ func (s *Storage) UserByUsername(username string) (*model.User, error) {
|
|||
|
||||
// UserByExtraField finds a user by an extra field value.
|
||||
func (s *Storage) UserByExtraField(field, value string) (*model.User, error) {
|
||||
defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:UserByExtraField] field=%s", field))
|
||||
defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:UserByExtraField] field=%s", field))
|
||||
query := `SELECT
|
||||
id, username, is_admin, theme, language, timezone, entry_direction, last_login_at, extra
|
||||
FROM users
|
||||
|
@ -241,7 +241,7 @@ func (s *Storage) fetchUser(query string, args ...interface{}) (*model.User, err
|
|||
|
||||
// RemoveUser deletes a user.
|
||||
func (s *Storage) RemoveUser(userID int64) error {
|
||||
defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:RemoveUser] userID=%d", userID))
|
||||
defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:RemoveUser] userID=%d", userID))
|
||||
|
||||
result, err := s.db.Exec("DELETE FROM users WHERE id = $1", userID)
|
||||
if err != nil {
|
||||
|
@ -262,7 +262,7 @@ func (s *Storage) RemoveUser(userID int64) error {
|
|||
|
||||
// Users returns all users.
|
||||
func (s *Storage) Users() (model.Users, error) {
|
||||
defer helper.ExecutionTime(time.Now(), "[Storage:Users]")
|
||||
defer timer.ExecutionTime(time.Now(), "[Storage:Users]")
|
||||
query := `
|
||||
SELECT
|
||||
id, username, is_admin, theme, language, timezone, entry_direction, last_login_at, extra
|
||||
|
@ -309,7 +309,7 @@ func (s *Storage) Users() (model.Users, error) {
|
|||
|
||||
// CheckPassword validate the hashed password.
|
||||
func (s *Storage) CheckPassword(username, password string) error {
|
||||
defer helper.ExecutionTime(time.Now(), "[Storage:CheckPassword]")
|
||||
defer timer.ExecutionTime(time.Now(), "[Storage:CheckPassword]")
|
||||
|
||||
var hash string
|
||||
username = strings.ToLower(username)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue