mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-11-30 04:10:01 +01:00
Allow adding/changing user with password hash via v1/users API
This commit is contained in:
parent
9edab24d4c
commit
4dc3b38c95
4 changed files with 87 additions and 16 deletions
|
|
@ -868,10 +868,8 @@ func (a *Manager) AddUser(username, password string, role Role, hashed bool) err
|
|||
if !AllowedUsername(username) || !AllowedRole(role) {
|
||||
return ErrInvalidArgument
|
||||
}
|
||||
|
||||
var hash []byte
|
||||
var err error = nil
|
||||
|
||||
if hashed {
|
||||
hash = []byte(password)
|
||||
} else {
|
||||
|
|
@ -880,7 +878,6 @@ func (a *Manager) AddUser(username, password string, role Role, hashed bool) err
|
|||
return err
|
||||
}
|
||||
}
|
||||
|
||||
userID := util.RandomStringPrefix(userIDPrefix, userIDLength)
|
||||
syncTopic, now := util.RandomStringPrefix(syncTopicPrefix, syncTopicLength), time.Now().Unix()
|
||||
if _, err = a.db.Exec(insertUserQuery, userID, username, hash, role, syncTopic, now); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue