diff --git a/src/templates/proxyauth-login.ejs b/src/templates/proxyauth-login.ejs
index 44a46c6be..85beed29f 100644
--- a/src/templates/proxyauth-login.ejs
+++ b/src/templates/proxyauth-login.ejs
@@ -1,105 +1,245 @@
+
- <%= title %> Login
+
+ Login to <%= title %>
-
-
-
-
<%= title %> Login
+
-
+
+
+
+
+

+
+
Login to <%= title %>
+
+
+
+
+
+
+
-
-
+
+ fetch('/login', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ username: username, password: password })
+ }).then(function (response) {
+ if (response.status === 401 || response.status === 403) {
+ document.getElementById('message').innerText = 'Invalid username or password';
+ return;
+ }
+
+ var search = decodeURIComponent(window.location.search).slice(1).split('&').map(function (item) { return item.split('='); }).reduce(function (o, k) { o[k[0]] = k[1]; return o; }, {});
+ window.location.href = search.redirect || '/';
+ });
+
+ return false;
+ }
+
+