1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-07-22 17:18:37 +00:00

Make sure people don't create duplicate Fever usernames

This commit is contained in:
Frédéric Guillot 2017-12-29 14:38:43 -08:00
parent 9eb91e6f0b
commit 038ea790f7
4 changed files with 27 additions and 5 deletions

View file

@ -11,11 +11,25 @@ import (
"github.com/miniflux/miniflux/model"
)
// HasDuplicateFeverUsername checks if another user have the same fever username.
func (s *Storage) HasDuplicateFeverUsername(userID int64, feverUsername string) bool {
query := `
SELECT
count(*) as c
FROM integrations
WHERE user_id != $1 AND fever_username=$2
`
var result int
s.db.QueryRow(query, userID, feverUsername).Scan(&result)
return result >= 1
}
// UserByFeverToken returns a user by using the Fever API token.
func (s *Storage) UserByFeverToken(token string) (*model.User, error) {
query := `
SELECT
users.id, users.is_admin, users.timezone
users.id, users.is_admin, users.timezone
FROM users
LEFT JOIN integrations ON integrations.user_id=users.id
WHERE integrations.fever_enabled='t' AND integrations.fever_token=$1