iobroker.mywebui 1.37.59 → 1.37.60

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/io-package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "mywebui",
4
- "version": "1.37.59",
4
+ "version": "1.37.60",
5
5
  "titleLang": {
6
6
  "en": "mywebui",
7
7
  "de": "mywebui",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.mywebui",
3
- "version": "1.37.59",
3
+ "version": "1.37.60",
4
4
  "description": "ioBroker mywebui - Custom edited mywebui by gokturk413",
5
5
  "type": "module",
6
6
  "main": "dist/backend/main.js",
@@ -161,47 +161,46 @@ let ScreenViewer = class ScreenViewer extends BaseCustomWebComponentConstructorA
161
161
  }
162
162
  async loadScreenData(html, style, script, settings, properties) {
163
163
  // SERVER-SIDE SECURITY CHECK: backend reads screen file + groups from ioBroker DB
164
- try {
165
- const currentUser = await iobrokerHandler.getCurrentUser();
166
- const username = currentUser?.name || iobrokerHandler.userName;
167
- const accessResult = await new Promise((resolve) => {
168
- iobrokerHandler.connection.sendTo(
169
- 'mywebui.0', 'checkScreenAccess',
170
- { screenName: this.screenName, username },
171
- (result) => resolve(result || { allowed: false, reason: 'no response' })
164
+ if (this.screenName) {
165
+ try {
166
+ const username = iobrokerHandler.userName || (await iobrokerHandler.getCurrentUser())?.name;
167
+ const _check = iobrokerHandler.connection.sendTo(
168
+ iobrokerHandler.namespace,
169
+ 'checkScreenAccess',
170
+ { screenName: this.screenName, username }
172
171
  );
173
- // timeout: 5s if backend doesn't respond, fail-open
174
- setTimeout(() => resolve({ allowed: true, _timeout: true }), 5000);
175
- });
172
+ const _timeout = new Promise(r => setTimeout(() => r({ allowed: true, _timeout: true }), 5000));
173
+ const accessResult = await Promise.race([_check, _timeout]);
176
174
 
177
- if (!accessResult.allowed) {
178
- console.warn('⛔ [Screen Visibility] Server denied access to:', this.screenName);
179
- const action = accessResult.action || 'hide';
180
- if (action === 'redirect' && accessResult.redirectScreen) {
181
- this.screenName = accessResult.redirectScreen;
182
- this._loadScreen();
175
+ if (!accessResult.allowed) {
176
+ console.warn('⛔ [Screen Visibility] Server denied access to:', this.screenName);
177
+ const action = accessResult.action || 'hide';
178
+ if (action === 'redirect' && accessResult.redirectScreen) {
179
+ this.screenName = accessResult.redirectScreen;
180
+ this._loadScreen();
181
+ return;
182
+ }
183
+ this._rootShadow.innerHTML = `
184
+ <div style="display:flex;align-items:center;justify-content:center;height:100%;font-family:sans-serif;">
185
+ <div style="text-align:center;padding:40px;">
186
+ <div style="font-size:48px;margin-bottom:20px;">🔒</div>
187
+ <h2 style="margin:0 0 10px 0;color:#666;">Access Denied</h2>
188
+ <p style="color:#999;">You don't have permission to view this screen.</p>
189
+ </div>
190
+ </div>
191
+ `;
183
192
  return;
184
193
  }
185
- this._rootShadow.innerHTML = `
186
- <div style="display:flex;align-items:center;justify-content:center;height:100%;font-family:sans-serif;">
187
- <div style="text-align:center;padding:40px;">
188
- <div style="font-size:48px;margin-bottom:20px;">🔒</div>
189
- <h2 style="margin:0 0 10px 0;color:#666;">Access Denied</h2>
190
- <p style="color:#999;">You don't have permission to view this screen.</p>
191
- </div>
192
- </div>
193
- `;
194
- return;
195
- }
196
194
 
197
- if (accessResult._timeout) {
198
- console.warn('[Screen Visibility] Backend timeout — fail-open');
199
- } else {
200
- console.log('✅ [Screen Visibility] Server granted access to:', this.screenName);
195
+ if (accessResult._timeout) {
196
+ console.warn('[Screen Visibility] Backend timeout — fail-open');
197
+ } else {
198
+ console.log('✅ [Screen Visibility] Server granted access to:', this.screenName);
199
+ }
200
+ } catch (err) {
201
+ console.error('❌ [Screen Visibility] Server check failed:', err);
202
+ // fail-open
201
203
  }
202
- } catch (err) {
203
- console.error('❌ [Screen Visibility] Server check failed:', err);
204
- // fail-open: backend xətası olduqda screen-i göstər
205
204
  }
206
205
 
207
206
  if (properties) {