Ensure we have the deviceId by GETting it from the Resin API

This commit is contained in:
Pablo Carranza Vélez 2015-09-11 16:05:08 +00:00
parent 198975fcb1
commit 8eb1c3ea7b

View File

@ -34,10 +34,18 @@ bootstrap = ->
return userConfig
deviceRegister.register(resinApi, userConfig)
.catch DuplicateUuidError, ->
return {}
resinApi.get
resource: 'device'
options:
filter:
uuid: userConfig.uuid
customOptions:
apikey: userConfig.apiKey
.then ([ device ]) ->
return device
.then (device) ->
userConfig.registered_at = Date.now()
userConfig.deviceId = device.id if device.id?
userConfig.deviceId = device.id
fs.writeFileAsync(configPath, JSON.stringify(userConfig))
.return(userConfig)
.then (userConfig) ->