snakeia-server 1.2.7 → 2.0.0

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/views/admin.html CHANGED
@@ -271,8 +271,18 @@
271
271
  body: JSON.stringify(data),
272
272
  redirect: "follow"
273
273
  }).then((response) => {
274
- if(response.ok && response.redirected) {
274
+ const responseOK = response.ok || response.status === 401;
275
+ const redirected = response.redirected;
276
+
277
+ if(responseOK && redirected) {
275
278
  location.href = response.url;
279
+ } else if(!responseOK) {
280
+ element.classList.remove("disabled");
281
+ element.disabled = false;
282
+
283
+ if(response.status === 403) {
284
+ location.href = "/admin";
285
+ }
276
286
  }
277
287
  }).catch(() => {
278
288
  element.classList.remove("disabled");
@@ -302,7 +312,7 @@
302
312
  if((confirmAction && confirm("<%= __("actionConfirmAdmin") %>")) || !confirmAction) {
303
313
  element.classList.add("disabled");
304
314
  element.disabled = true;
305
- requestAction(action, data);
315
+ requestAction(action, data, element);
306
316
  }
307
317
  });
308
318
  });
@@ -20,6 +20,7 @@
20
20
  <head>
21
21
  <meta charset="UTF-8"></meta>
22
22
  <meta name="viewport" content="width=device-width, initial-scale=1">
23
+ <meta name="csrf-token" content="<%= csrfToken %>">
23
24
  <link href="/css/bootstrap.min.css" rel="stylesheet">
24
25
  <link href="/css/flat-ui.min.css" rel="stylesheet">
25
26
  <link href="/css/main.css" rel="stylesheet">
@@ -35,10 +36,13 @@
35
36
  <body class="text-center remove-padding">
36
37
  <% } %>
37
38
  <div class="container">
38
- <% if(authent) { %>
39
+ <% if(!clientCompatible) { %>
40
+ <h3><%= __("clientNotCompatible", serverGameVersion) %></h3>
41
+ <% } else if(authent) { %>
39
42
  <h3><%= __("alreadyAuthentified") %></h3>
40
43
  <% } else if(!success) { %>
41
44
  <form action="" method="post">
45
+ <input type="hidden" name="_csrf" value="<%= csrfToken %>" />
42
46
  <fieldset class="form-group">
43
47
  <div class="form-group row">
44
48
  <label for="username" class="col-12 col-form-label"><%= __("username", __n("characters", max), min) %></label>