homebridge-melcloud-control 4.0.0-beta.316 → 4.0.0-beta.317
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/melcloudhometoken.js +15 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.317",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
package/src/melcloudhometoken.js
CHANGED
|
@@ -176,6 +176,21 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
176
176
|
});
|
|
177
177
|
|
|
178
178
|
this.emit('warn', `No cookie returned from login. Response headers: ${response}`);
|
|
179
|
+
if (response.status === 302 && postResp.headers.location) {
|
|
180
|
+
// Login success — mamy redirect z "code="
|
|
181
|
+
const redirectUrl = response.headers.location;
|
|
182
|
+
console.log('Login success, redirect URL:', redirectUrl);
|
|
183
|
+
|
|
184
|
+
const match = redirectUrl.match(/[?&]code=([^&]+)/);
|
|
185
|
+
if (match) {
|
|
186
|
+
const code = match[1];
|
|
187
|
+
console.log('Authorization code:', code);
|
|
188
|
+
return code;
|
|
189
|
+
} else {
|
|
190
|
+
console.warn('Redirect URL found, but no "code=" param.');
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
179
194
|
|
|
180
195
|
if (response.status !== 200) {
|
|
181
196
|
if (this.logError) this.emit('error', `Login failed with status code: ${response.status}`);
|