diff --git a/src/config.js b/src/config.js
index 3fd4893a..423bc7f1 100644
--- a/src/config.js
+++ b/src/config.js
@@ -4,7 +4,6 @@ const { release } = require('./package.json');
module.exports.RELEASE = release;
module.exports.PORT = process.env.PORT || 51821;
-module.exports.PASSWORD = process.env.PASSWORD;
module.exports.WG_PATH = process.env.WG_PATH || '/etc/wireguard/';
module.exports.WG_DEVICE = process.env.WG_DEVICE || 'eth0';
module.exports.WG_HOST = process.env.WG_HOST;
diff --git a/src/lib/Server.js b/src/lib/Server.js
index 806769bc..009ab4a3 100644
--- a/src/lib/Server.js
+++ b/src/lib/Server.js
@@ -39,15 +39,11 @@ module.exports = class Server {
return RELEASE;
})))
- // Authentication
+ // Get session data
.get('/api/session', Util.promisify(async req => {
- const requiresPassword = !!process.env.PASSWORD;
- const authenticated = requiresPassword
- ? !!(req.session && req.session.authenticated)
- : true;
+ const authenticated = !!(req.session && req.session.authenticated);
return {
- requiresPassword,
authenticated,
};
}))
@@ -79,10 +75,7 @@ module.exports = class Server {
// WireGuard
.use((req, res, next) => {
- if (!PASSWORD) {
- return next();
- }
-
+
if (req.session && req.session.authenticated) {
return next();
}
diff --git a/src/www/index.html b/src/www/index.html
index 7d5da28d..5425a0de 100644
--- a/src/www/index.html
+++ b/src/www/index.html
@@ -24,7 +24,7 @@
diff --git a/src/www/js/api.js b/src/www/js/api.js
index 84885f17..a957f455 100644
--- a/src/www/js/api.js
+++ b/src/www/js/api.js
@@ -43,11 +43,11 @@ class API {
});
}
- async createSession({ password }) {
+ async createSession({ username, password }) {
return this.call({
method: 'post',
path: '/session',
- body: { password },
+ body: { username, password },
});
}
diff --git a/src/www/js/app.js b/src/www/js/app.js
index e22cbfe0..c95e8ebe 100644
--- a/src/www/js/app.js
+++ b/src/www/js/app.js
@@ -28,8 +28,8 @@ new Vue({
data: {
authenticated: null,
authenticating: false,
+ username: null,
password: null,
- requiresPassword: null,
clients: null,
clientsPersist: {},
@@ -173,17 +173,18 @@ new Vue({
login(e) {
e.preventDefault();
+ if (!this.username) return;
if (!this.password) return;
if (this.authenticating) return;
this.authenticating = true;
this.api.createSession({
+ username: this.username,
password: this.password,
})
.then(async () => {
const session = await this.api.getSession();
this.authenticated = session.authenticated;
- this.requiresPassword = session.requiresPassword;
return this.refresh();
})
.catch(err => {
@@ -191,6 +192,7 @@ new Vue({
})
.finally(() => {
this.authenticating = false;
+ this.username = null;
this.password = null;
});
},
@@ -251,7 +253,6 @@ new Vue({
this.api.getSession()
.then(session => {
this.authenticated = session.authenticated;
- this.requiresPassword = session.requiresPassword;
this.refresh({
updateCharts: true,
}).catch(err => {