mirror of
https://github.com/idanoo/autobrr
synced 2025-07-22 16:29:12 +00:00
fix(autobrrctl): change password for user (#11)
This commit is contained in:
parent
b8edeb5f31
commit
eb5b040eeb
3 changed files with 8 additions and 6 deletions
|
@ -18,8 +18,9 @@ import (
|
|||
|
||||
const usage = `usage: autobrrctl --config path <action>
|
||||
|
||||
create-user <username> Create user
|
||||
help Show this help message
|
||||
create-user <username> Create user
|
||||
change-password <username> Change password for user
|
||||
help Show this help message
|
||||
`
|
||||
|
||||
func init() {
|
||||
|
@ -127,7 +128,7 @@ func readPassword() ([]byte, error) {
|
|||
}
|
||||
fmt.Printf("\n")
|
||||
} else {
|
||||
fmt.Fprintf(os.Stderr, "warning: Reading password from stdin.\n")
|
||||
//fmt.Fprintf(os.Stderr, "warning: Reading password from stdin.\n")
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
if !scanner.Scan() {
|
||||
if err := scanner.Err(); err != nil {
|
||||
|
|
|
@ -12,7 +12,8 @@ CREATE TABLE users
|
|||
username TEXT NOT NULL,
|
||||
password TEXT NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE (username)
|
||||
);
|
||||
|
||||
CREATE TABLE indexer
|
||||
|
|
|
@ -17,7 +17,7 @@ func NewUserRepo(db *sql.DB) domain.UserRepo {
|
|||
}
|
||||
|
||||
func (r *UserRepo) FindByUsername(username string) (*domain.User, error) {
|
||||
query := `SELECT username, password FROM users WHERE username = ?`
|
||||
query := `SELECT id, username, password FROM users WHERE username = ?`
|
||||
|
||||
row := r.db.QueryRow(query, username)
|
||||
if err := row.Err(); err != nil {
|
||||
|
@ -26,7 +26,7 @@ func (r *UserRepo) FindByUsername(username string) (*domain.User, error) {
|
|||
|
||||
var user domain.User
|
||||
|
||||
if err := row.Scan(&user.Username, &user.Password); err != nil {
|
||||
if err := row.Scan(&user.ID, &user.Username, &user.Password); err != nil {
|
||||
log.Error().Err(err).Msg("could not scan user to struct")
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue