Haikunate users first bot

pull/245/head
Rick Carlino 2016-03-30 08:41:22 -05:00
parent 80ff92fe60
commit 33d6edfc47
3 changed files with 7 additions and 2 deletions

View File

@ -32,4 +32,8 @@ class User
uuid: SecureRandom.uuid,
token: SecureRandom.hex)
end
def device_id
self[:device_id] || device.id
end
end

View File

@ -9,10 +9,11 @@ module Devices
end
optional do
string :name, default: 'Not set.'
string :name, default: nil
end
def execute
inputs["name"] ||= Haikunator.haikunate(99)
dev = Device.find_or_initialize_by(uuid: uuid, token: token)
if update_attributes(dev, inputs.except(:user))
user.update_attributes(device: dev)

View File

@ -27,6 +27,6 @@ class SessionToken
iss: iss,
exp: exp,
mqtt: MQTT,
bot: user.device.uuid)
bot: user.device.uuid)
end
end