update user only if it exists

This commit is contained in:
Joerg Lehmann 2022-10-02 16:07:31 +02:00
parent 972f38fe6a
commit d8eece9046
1 changed files with 8 additions and 0 deletions

View File

@ -362,6 +362,14 @@ func updateUser(username, password string) {
conn := globalPool.Get() conn := globalPool.Get()
defer conn.Close() defer conn.Close()
logit("updateUser: " + username) logit("updateUser: " + username)
// we exit if user does not exit
exists, _ := redis.Bool(conn.Do("EXISTS", userPrefix+username))
if !exists {
logit("updateUser: User does not exist: " + username)
return
}
pwd := []byte(password) pwd := []byte(password)
hashedPassword, err := bcrypt.GenerateFromPassword(pwd, bcrypt.DefaultCost) hashedPassword, err := bcrypt.GenerateFromPassword(pwd, bcrypt.DefaultCost)
if err != nil { if err != nil {