mirror of
https://github.com/beestat/app.git
synced 2025-07-09 03:04:07 -04:00
Updated authentication to be based on the ecobee account ID instead of thermostat serial number
This commit is contained in:
parent
4394f38bb6
commit
d531850863
@ -52,37 +52,11 @@ class ecobee extends external_api {
|
|||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the thermostat list from ecobee.
|
$existing_user = $this->database->read(
|
||||||
$response = $this->ecobee_api(
|
'user',
|
||||||
'GET',
|
|
||||||
'thermostat',
|
|
||||||
[
|
[
|
||||||
'body' => json_encode([
|
'ecobee_account_id' => $ecobee_token['ecobee_account_id'],
|
||||||
'selection' => [
|
'deleted' => false
|
||||||
'selectionType' => 'registered',
|
|
||||||
'selectionMatch' => '',
|
|
||||||
'includeRuntime' => true,
|
|
||||||
'includeNotificationSettings' => true
|
|
||||||
]
|
|
||||||
])
|
|
||||||
],
|
|
||||||
false,
|
|
||||||
$ecobee_token
|
|
||||||
);
|
|
||||||
|
|
||||||
$identifiers = [];
|
|
||||||
foreach($response['thermostatList'] as $thermostat) {
|
|
||||||
$runtime = $thermostat['runtime'];
|
|
||||||
$identifiers[] = $thermostat['identifier'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Look to see if any of the returned thermostats exist. This does not use
|
|
||||||
// CRUD because it needs to bypass the user_id restriction (also I don't
|
|
||||||
// think you're logged in yet)
|
|
||||||
$existing_ecobee_thermostats = $this->database->read(
|
|
||||||
'ecobee_thermostat',
|
|
||||||
[
|
|
||||||
'identifier' => $identifiers
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -90,13 +64,12 @@ class ecobee extends external_api {
|
|||||||
// exists and all of them have matching user_ids, log in as that user.
|
// exists and all of them have matching user_ids, log in as that user.
|
||||||
// Otherwise create a new user and save the tokens to it.
|
// Otherwise create a new user and save the tokens to it.
|
||||||
if(
|
if(
|
||||||
count($existing_ecobee_thermostats) > 0 &&
|
count($existing_user) > 0
|
||||||
count(array_unique(array_column($existing_ecobee_thermostats, 'user_id'))) === 1
|
|
||||||
) {
|
) {
|
||||||
$this->api(
|
$this->api(
|
||||||
'user',
|
'user',
|
||||||
'force_log_in',
|
'force_log_in',
|
||||||
['user_id' => $existing_ecobee_thermostats[0]['user_id']]
|
['user_id' => $existing_user[count($existing_user) - 1]['user_id']]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Look for existing tokens (in case access was revoked and then re-
|
// Look for existing tokens (in case access was revoked and then re-
|
||||||
|
@ -75,6 +75,7 @@ beestat.component.modal.newsletter.prototype.get_buttons_ = function() {
|
|||||||
.set_background_color('#fff')
|
.set_background_color('#fff')
|
||||||
.set_text_color(beestat.style.color.gray.base)
|
.set_text_color(beestat.style.color.gray.base)
|
||||||
.set_text_hover_color(beestat.style.color.red.base)
|
.set_text_hover_color(beestat.style.color.red.base)
|
||||||
|
.set_shadow(false)
|
||||||
.set_text('No Thanks')
|
.set_text('No Thanks')
|
||||||
.addEventListener('click', function() {
|
.addEventListener('click', function() {
|
||||||
self.dispose();
|
self.dispose();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user