implement no auth
This commit is contained in:
parent
33d7f8645a
commit
6f868c9ec3
|
@ -26,7 +26,7 @@ console.log("Importing this project modules");
|
||||||
debug("Importing Monitor");
|
debug("Importing Monitor");
|
||||||
const Monitor = require("./model/monitor");
|
const Monitor = require("./model/monitor");
|
||||||
debug("Importing Settings");
|
debug("Importing Settings");
|
||||||
const { getSettings, setSettings } = require("./util-server");
|
const { getSettings, setSettings, setting } = require("./util-server");
|
||||||
debug("Importing Notification");
|
debug("Importing Notification");
|
||||||
const { Notification } = require("./notification");
|
const { Notification } = require("./notification");
|
||||||
debug("Importing Database");
|
debug("Importing Database");
|
||||||
|
@ -114,6 +114,11 @@ let indexHTML = fs.readFileSync("./dist/index.html").toString();
|
||||||
socket.emit("setup")
|
socket.emit("setup")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (await setting("disableAuth")) {
|
||||||
|
console.log("Disabled Auth: auto login to admin")
|
||||||
|
await afterLogin(socket, await R.findOne("user", " username = 'admin' "))
|
||||||
|
}
|
||||||
|
|
||||||
socket.on("disconnect", () => {
|
socket.on("disconnect", () => {
|
||||||
totalClient--;
|
totalClient--;
|
||||||
});
|
});
|
||||||
|
@ -600,6 +605,8 @@ async function afterLogin(socket, user) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sendNotificationList(socket)
|
sendNotificationList(socket)
|
||||||
|
|
||||||
|
socket.emit("autoLogin")
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getMonitorJSONList(userID) {
|
async function getMonitorJSONList(userID) {
|
||||||
|
|
|
@ -56,6 +56,11 @@ export default {
|
||||||
this.$router.push("/setup")
|
this.$router.push("/setup")
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on("autoLogin", (monitorID, data) => {
|
||||||
|
this.loggedIn = true;
|
||||||
|
this.storage().token = "autoLogin"
|
||||||
|
});
|
||||||
|
|
||||||
socket.on("monitorList", (data) => {
|
socket.on("monitorList", (data) => {
|
||||||
// Add Helper function
|
// Add Helper function
|
||||||
Object.entries(data).forEach(([monitorID, monitor]) => {
|
Object.entries(data).forEach(([monitorID, monitor]) => {
|
||||||
|
@ -156,8 +161,12 @@ export default {
|
||||||
this.clearData()
|
this.clearData()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.storage().token) {
|
let token = this.storage().token;
|
||||||
this.loginByToken(this.storage().token)
|
|
||||||
|
if (token) {
|
||||||
|
if (token !== "autoLogin") {
|
||||||
|
this.loginByToken(token)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.allowLoginDialog = true;
|
this.allowLoginDialog = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<template v-if="loaded">
|
||||||
|
<template v-if="! settings.disableAuth">
|
||||||
<h2>Change Password</h2>
|
<h2>Change Password</h2>
|
||||||
<form class="mb-3" @submit.prevent="savePassword">
|
<form class="mb-3" @submit.prevent="savePassword">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
|
@ -53,14 +55,16 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
</template>
|
||||||
|
|
||||||
<h2>Advanced</h2>
|
<h2>Advanced</h2>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<button v-if="settings.disableAuth" class="btn btn-outline-primary me-1" @click="enableAuth">Enable Auth</button>
|
<button v-if="settings.disableAuth" class="btn btn-outline-primary me-1" @click="enableAuth">Enable Auth</button>
|
||||||
<button v-if="! settings.disableAuth" class="btn btn-primary me-1" @click="confirmDisableAuth">Disable Auth</button>
|
<button v-if="! settings.disableAuth" class="btn btn-primary me-1" @click="confirmDisableAuth">Disable Auth</button>
|
||||||
<button class="btn btn-danger me-1" @click="$root.logout">Logout</button>
|
<button v-if="! settings.disableAuth" class="btn btn-danger me-1" @click="$root.logout">Logout</button>
|
||||||
</div>
|
</div>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
|
@ -128,7 +132,8 @@ export default {
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
|
|
||||||
}
|
},
|
||||||
|
loaded: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -166,6 +171,7 @@ export default {
|
||||||
loadSettings() {
|
loadSettings() {
|
||||||
this.$root.getSocket().emit("getSettings", (res) => {
|
this.$root.getSocket().emit("getSettings", (res) => {
|
||||||
this.settings = res.data;
|
this.settings = res.data;
|
||||||
|
this.loaded = true;
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -188,6 +194,7 @@ export default {
|
||||||
enableAuth() {
|
enableAuth() {
|
||||||
this.settings.disableAuth = false;
|
this.settings.disableAuth = false;
|
||||||
this.saveSettings();
|
this.saveSettings();
|
||||||
|
this.$root.storage().token = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue