Re-add the ID field

This commit is contained in:
Kegan Dougal 2017-05-24 16:41:41 +01:00
parent 12b0398f2b
commit b29725ab13
2 changed files with 3 additions and 1 deletions

View file

@ -16,6 +16,7 @@ package authtypes
// Device represents a client's device (mobile, web, etc)
type Device struct {
ID string
UserID string
// The access_token granted to this device.
// This uniquely identifies the device from all other devices and clients.

View file

@ -88,6 +88,7 @@ func (s *devicesStatements) insertDevice(txn *sql.Tx, id, localpart, accessToken
createdTimeMS := time.Now().UnixNano() / 1000000
if _, err = s.insertDeviceStmt.Exec(id, localpart, accessToken, createdTimeMS); err == nil {
dev = &authtypes.Device{
ID: id,
UserID: makeUserID(localpart, s.serverName),
AccessToken: accessToken,
}
@ -103,7 +104,7 @@ func (s *devicesStatements) deleteDevice(txn *sql.Tx, id, localpart string) erro
func (s *devicesStatements) selectDeviceByToken(accessToken string) (*authtypes.Device, error) {
var dev authtypes.Device
var localpart string
err := s.selectDeviceByTokenStmt.QueryRow(accessToken).Scan(&localpart)
err := s.selectDeviceByTokenStmt.QueryRow(accessToken).Scan(&dev.ID, &localpart)
if err != nil {
dev.UserID = makeUserID(localpart, s.serverName)
dev.AccessToken = accessToken