No rows is not an error

This commit is contained in:
scs 2019-07-26 00:17:46 +00:00
parent 4ca36d90de
commit 7d96d46ac8
1 changed files with 3 additions and 4 deletions

View File

@ -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())
}