mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
feat: add ability to create an account via the webui (#223)
* feat: add ability to create an account via the webui without the need for autobrrctl * refactor redundant code block. * fix: early return and 0 value
This commit is contained in:
parent
982eddc269
commit
1a4f3cf55d
11 changed files with 337 additions and 109 deletions
|
@ -15,6 +15,29 @@ func NewUserRepo(db *DB) domain.UserRepo {
|
|||
return &UserRepo{db: db}
|
||||
}
|
||||
|
||||
func (r *UserRepo) GetUserCount(ctx context.Context) (int, error) {
|
||||
queryBuilder := r.db.squirrel.Select("count(*)").From("users")
|
||||
|
||||
query, args, err := queryBuilder.ToSql()
|
||||
if err != nil {
|
||||
log.Error().Stack().Err(err).Msg("user.store: error building query")
|
||||
return 0, err
|
||||
}
|
||||
|
||||
row := r.db.handler.QueryRowContext(ctx, query, args...)
|
||||
if err := row.Err(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result := 0
|
||||
if err := row.Scan(&result); err != nil {
|
||||
log.Error().Err(err).Msg("could not query number of users")
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r *UserRepo) FindByUsername(ctx context.Context, username string) (*domain.User, error) {
|
||||
|
||||
queryBuilder := r.db.squirrel.
|
||||
|
@ -66,6 +89,7 @@ func (r *UserRepo) Store(ctx context.Context, user domain.User) error {
|
|||
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *UserRepo) Update(ctx context.Context, user domain.User) error {
|
||||
|
||||
var err error
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue