aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/main.go b/main.go
index 786263d..12d876c 100644
--- a/main.go
+++ b/main.go
@@ -36,9 +36,8 @@ func mainHandler(ds DataStore, w http.ResponseWriter, r *http.Request) {
user := r.FormValue("u")
auth := r.FormValue("a")
- password, ok := ds.GetPassword(user)
-
- if (md5hex(password+timestamp) != auth) || !ok {
+ password, err := ds.GetPassword(user)
+ if (md5hex(password+timestamp) != auth) || err != nil {
fmt.Fprintf(w, "BADAUTH\n")
return
}
@@ -123,7 +122,7 @@ func parseScrobbles(values url.Values, session *Session) []Scrobble {
}
func scrobbleHandler(ds DataStore, w http.ResponseWriter, r *http.Request) {
- if session, ok := ds.GetSession(r.FormValue("s")); ok {
+ if session, err := ds.GetSession(r.FormValue("s")); err != nil {
scrobbles := parseScrobbles(r.Form, session)
ds.PutScrobbles(scrobbles)
fmt.Fprintf(w, "OK\n")
@@ -133,8 +132,8 @@ func scrobbleHandler(ds DataStore, w http.ResponseWriter, r *http.Request) {
}
func nowPlayingHandler(ds DataStore, w http.ResponseWriter, r *http.Request) {
- if _, ok := ds.GetSession(r.FormValue("s")); ok {
- fmt.Fprintf(w, "OK\n")
+ if _, err := ds.GetSession(r.FormValue("s")); err != nil {
+ fmt.Fprintln(w, "OK")
} else {
fmt.Fprintf(w, "BADSESSION\n")
}