Skip to content

Commit

Permalink
change auth role
Browse files Browse the repository at this point in the history
  • Loading branch information
TA2k committed Jun 2, 2024
1 parent 7ea9d4b commit b9ae95e
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,15 @@ class Ford extends utils.Adapter {
const auth = await this.getStateAsync('auth');
if (this.config.clientId && this.config.secret) {
if (auth && auth.val) {
this.session = JSON.parse(auth.val);
await this.refreshTokenApi();
try {
// @ts-ignore
this.session = JSON.parse(auth.val);
await this.refreshTokenApi();
} catch (error) {
this.log.error('Failed to parse auth');
// @ts-ignore
this.log.error(error);
}
} else {
this.log.info('Found clientID start API Login');
if (!this.config.codeUrl) {
Expand Down Expand Up @@ -155,7 +162,7 @@ class Ford extends utils.Adapter {
common: {
name: 'auth',
type: 'string',
role: 'state',
role: 'json',
read: true,
write: true,
},
Expand Down Expand Up @@ -938,9 +945,9 @@ class Ford extends utils.Adapter {
try {
this.setState('info.connection', false, true);
clearTimeout(this.refreshTimeout);
clearTimeout(this.reLoginTimeout);
clearTimeout(this.refreshTokenTimeout);
clearInterval(this.updateInterval);
this.reLoginTimeout && clearTimeout(this.reLoginTimeout);
this.refreshTokenTimeout && clearTimeout(this.refreshTokenTimeout);
this.updateInterval && clearInterval(this.updateInterval);
clearInterval(this.refreshTokenInterval);
callback();
} catch (e) {
Expand Down

0 comments on commit b9ae95e

Please sign in to comment.