From d8eece90463dc0396e2390227503aa909c4e80ad Mon Sep 17 00:00:00 2001 From: Joerg Lehmann Date: Sun, 2 Oct 2022 16:07:31 +0200 Subject: [PATCH] update user only if it exists --- persistence.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/persistence.go b/persistence.go index 9c9e4df..e8827f1 100644 --- a/persistence.go +++ b/persistence.go @@ -362,6 +362,14 @@ func updateUser(username, password string) { conn := globalPool.Get() defer conn.Close() 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) hashedPassword, err := bcrypt.GenerateFromPassword(pwd, bcrypt.DefaultCost) if err != nil {