aboutsummaryrefslogtreecommitdiffstats
path: root/modern.go
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2017-06-27 22:28:40 -0400
committerGuillaume Horel <guillaume.horel@gmail.com>2017-06-27 22:28:40 -0400
commit475f53900a73bdb7b55d95037f26d3229405566b (patch)
tree6602a9f5bdf510b657f70f246397b762941e5f06 /modern.go
parentc9c5a01c07c428800249f2880e8467c196f694cf (diff)
downloadlastfm-api-475f53900a73bdb7b55d95037f26d3229405566b.tar.gz
more progress
Diffstat (limited to 'modern.go')
-rw-r--r--modern.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/modern.go b/modern.go
index 83feb5d..47b3a1d 100644
--- a/modern.go
+++ b/modern.go
@@ -1,6 +1,7 @@
package main
import (
+ "database/sql"
"database/sql/driver"
"encoding/json"
"encoding/xml"
@@ -34,10 +35,10 @@ type Name struct {
}
type Token struct {
- XMLName xml.Name `xml:"token" json:"-"`
- Val string `xml:",innerxml" json:"token"`
- Created time.Time `xml:"-" json:"-"`
- UserId int `xml:"-" json:"-"`
+ XMLName xml.Name `xml:"token" json:"-"`
+ Val string `xml:",innerxml" json:"token"`
+ Created time.Time `xml:"-" json:"-"`
+ UserId sql.NullInt64 `xml:"-" json:"-"`
}
type LFMResponse struct {
@@ -120,8 +121,8 @@ func (store *SqlStore) AuthGetSession(r *http.Request) (ApiResponse, error) {
// FIXME: error 15
return nil, errors.New("This token has expired")
} else {
- if token.UserId != 0 {
- user := &User{Id: token.UserId}
+ if token.UserId.Valid {
+ user := &User{Id: int(token.UserId.Int64)}
if err := store.GetUser(user); err != nil {
return nil, err
} else {