No rows is not an error
This commit is contained in:
parent
4ca36d90de
commit
7d96d46ac8
7
main.go
7
main.go
|
@ -117,7 +117,6 @@ func Login(username, password string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ChangePassword(username, oldpass, newpass 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)
|
q:=fmt.Sprintf("select password from %s_auth where username ILIKE $1 AND status='active'",c.TablePrefix)
|
||||||
var crypt string
|
var crypt string
|
||||||
err:=c.db.Get(&crypt, q, username)
|
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)`,
|
user_id=(select userid from %s_auth where username ILIKE $1)`,
|
||||||
c.TablePrefix, c.TablePrefix)
|
c.TablePrefix, c.TablePrefix)
|
||||||
rows,err:=c.db.Queryx(q, username)
|
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())
|
log.Printf("scsusers.GetAllMeta: %s: %s\n", username, err.Error())
|
||||||
return meta
|
return meta
|
||||||
}
|
}
|
||||||
|
@ -224,13 +223,13 @@ func GetMeta(username string, metakey string) string {
|
||||||
q:=fmt.Sprintf(`select meta_value from %s_user_metadata where
|
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)
|
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)
|
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())
|
log.Printf("scsusers.GetMeta: %s - %s - %s\n", username, metakey, err.Error())
|
||||||
}
|
}
|
||||||
if v=="" {
|
if v=="" {
|
||||||
// get default user
|
// get default user
|
||||||
err:=c.db.Get(&v, q, "//default//", metakey)
|
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())
|
log.Printf("scsusers.GetMeta: %s - %s - %s\n", username, metakey, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue