mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-21 02:01:35 +00:00
Fix saving deviceApiKey to the DB (to fix the RESIN_API_KEY env var) when updating from some older supervisors
Change-Type: patch Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
This commit is contained in:
parent
17017936ce
commit
968d3ce1e3
@ -223,6 +223,17 @@ bootstrapper.done = new Promise (resolve) ->
|
||||
# This will only be the case when the supervisor/OS has been updated.
|
||||
if userConfig.apiKey?
|
||||
exchangeKeyOrRetry()
|
||||
else
|
||||
Promise.join(
|
||||
knex('config').select('value').where(key: 'apiKey')
|
||||
knex('config').select('value').where(key: 'deviceApiKey')
|
||||
([ apiKey ], [ deviceApiKey ]) ->
|
||||
if !deviceApiKey?.value
|
||||
# apiKey in the DB is actually the deviceApiKey, but it was
|
||||
# exchanged in a supervisor version that didn't save it to the DB
|
||||
# (which mainly affects the RESIN_API_KEY env var)
|
||||
knex('config').insert({ key: 'deviceApiKey', value: apiKey.value })
|
||||
)
|
||||
return
|
||||
|
||||
bootstrapper.bootstrapped = false
|
||||
|
Loading…
x
Reference in New Issue
Block a user