diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2017-06-27 22:28:40 -0400 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2017-06-27 22:28:40 -0400 |
| commit | 475f53900a73bdb7b55d95037f26d3229405566b (patch) | |
| tree | 6602a9f5bdf510b657f70f246397b762941e5f06 /modern.go | |
| parent | c9c5a01c07c428800249f2880e8467c196f694cf (diff) | |
| download | lastfm-api-475f53900a73bdb7b55d95037f26d3229405566b.tar.gz | |
more progress
Diffstat (limited to 'modern.go')
| -rw-r--r-- | modern.go | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -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 { |
