@andrey4emk/npm-app-back-b24 0.9.6 → 0.9.8
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/bitrix24/b24.js +7 -3
- package/package.json +1 -1
package/bitrix24/b24.js
CHANGED
|
@@ -17,13 +17,13 @@ let confAuthB24 = new Conf({
|
|
|
17
17
|
configName: "authB24",
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
// Получаем данные авторизации из конфига
|
|
21
|
-
const authConfig = confAuthB24.get()?.[appEnv];
|
|
22
|
-
|
|
23
20
|
export class B24Prepared {
|
|
24
21
|
constructor() {}
|
|
25
22
|
|
|
26
23
|
async makeAuthParams() {
|
|
24
|
+
// Получаем данные авторизации из конфига
|
|
25
|
+
const authConfig = confAuthB24.get()?.[appEnv];
|
|
26
|
+
|
|
27
27
|
// Проверяем данные из confAuthB24. Если чего то не хватает, то возвращаем null
|
|
28
28
|
if (!authConfig || !authConfig.domain || !authConfig.access_token || !authConfig.refresh_token) {
|
|
29
29
|
return { error: true, data: null, message: "В конфиге authB24 не хватает данных для авторизации." };
|
|
@@ -75,6 +75,10 @@ export class B24Prepared {
|
|
|
75
75
|
let newAuth = null;
|
|
76
76
|
try {
|
|
77
77
|
newAuth = await $b24.auth.getAuthData();
|
|
78
|
+
if (!newAuth) {
|
|
79
|
+
let refresh = await $b24.auth.refreshAuth();
|
|
80
|
+
newAuth = refresh;
|
|
81
|
+
}
|
|
78
82
|
} catch (error) {
|
|
79
83
|
return { error: true, message: `Ошибка при получении данных авторизации из $b24. ${error.message} ` };
|
|
80
84
|
}
|