From 7d96d46ac89245070d8a4b0554fa01aa6438319f Mon Sep 17 00:00:00 2001 From: scs Date: Fri, 26 Jul 2019 00:17:46 +0000 Subject: [PATCH] No rows is not an error --- main.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 10e2f29..ca23b37 100644 --- a/main.go +++ b/main.go @@ -117,7 +117,6 @@ func Login(username, password string) bool { } func ChangePassword(username, oldpass, newpass string) bool { - log.Println("scsusers.ChangePassword: Attempting password change for "+ username) q:=fmt.Sprintf("select password from %s_auth where username ILIKE $1 AND status='active'",c.TablePrefix) var crypt string err:=c.db.Get(&crypt, q, username) @@ -203,7 +202,7 @@ func GetAllMeta(username string) (map[string]string) { user_id=(select userid from %s_auth where username ILIKE $1)`, c.TablePrefix, c.TablePrefix) rows,err:=c.db.Queryx(q, username) - if err != nil { + if err != nil && err!=sql.ErrNoRows { log.Printf("scsusers.GetAllMeta: %s: %s\n", username, err.Error()) return meta } @@ -224,13 +223,13 @@ func GetMeta(username string, metakey string) string { q:=fmt.Sprintf(`select meta_value from %s_user_metadata where user_id=(select userid from %s_auth where username ILIKE $1) AND meta_key=$2`, c.TablePrefix, c.TablePrefix) err:=c.db.Get(&v, q, username, metakey) - if err != nil { + if err != nil && err!=sql.ErrNoRows { log.Printf("scsusers.GetMeta: %s - %s - %s\n", username, metakey, err.Error()) } if v=="" { // get default user err:=c.db.Get(&v, q, "//default//", metakey) - if err != nil { + if err != nil && err!=sql.ErrNoRows { log.Printf("scsusers.GetMeta: %s - %s - %s\n", username, metakey, err.Error()) }