flamerest 1.0.98 → 1.0.100
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/REST.js +16 -0
- package/package.json +1 -1
package/REST.js
CHANGED
|
@@ -88,6 +88,12 @@ class FLAMEREST {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
// Уникальный user_hash
|
|
92
|
+
let user_hash = localStorage.getItem('user_hash');
|
|
93
|
+
if (user_hash) {
|
|
94
|
+
Object.assign(customHeaders, { udata: user_hash });
|
|
95
|
+
}
|
|
96
|
+
|
|
91
97
|
// Тело запроса
|
|
92
98
|
let requestBody = {
|
|
93
99
|
method: type,
|
|
@@ -164,6 +170,8 @@ class FLAMEREST {
|
|
|
164
170
|
}
|
|
165
171
|
}
|
|
166
172
|
|
|
173
|
+
|
|
174
|
+
|
|
167
175
|
// Заполняем тело ответа заголовками
|
|
168
176
|
ResolveBody.type = "json";
|
|
169
177
|
ResolveBody.data = {};
|
|
@@ -526,6 +534,14 @@ class FLAMEREST {
|
|
|
526
534
|
// после успешной авторизации устанавливаем токен
|
|
527
535
|
if (typeof resp.token === 'string') this.token = resp.token;
|
|
528
536
|
|
|
537
|
+
// Сохраняем хеш юзера автоматически
|
|
538
|
+
let user_hash = localStorage.getItem('user_hash');
|
|
539
|
+
|
|
540
|
+
// Не трогаем хранилище при каждом запросе, только если нужно переустановить хеш [авторизация на др. устройстве]
|
|
541
|
+
if (resp?.User?.user_hash && resp.User.user_hash !== user_hash) {
|
|
542
|
+
localStorage.setItem('user_hash', resp.User.user_hash);
|
|
543
|
+
}
|
|
544
|
+
|
|
529
545
|
return resp.data;
|
|
530
546
|
|
|
531
547
|
}
|