This commit is contained in:
Leo
2024-01-25 17:46:28 +08:00
69 changed files with 10901 additions and 3222 deletions

View File

@ -165,6 +165,7 @@ app.socket = (function (app) {
});
return socket;
})(app);
//sensor data
app.sensordata = (function (app) {
@ -183,30 +184,21 @@ app.auth = (function (app) {
}
function isLoggedIn(callback) {
if (getToken()) {
console.log("you shldnt appear at all");
return app.api.get("user/me", function (error, data) {
console.log(error, data);
if (!error) app.auth.user = data;
//for navbar to show username
if (!location.pathname === "/login")
{
$.scope.getUsername.update(data);
}
//for edit profile to show user details
//if not in edit profile page, it will not show
if (location.pathname === "/profile") {
$.scope.getUserDetails.update(data);
}
return callback(error, data);
});
} else {
callback(null, false);
callback(true);
}
}
function logOut(callback) {
//call logout route
console.log("Logging out");
$.ajax({
type: "DELETE",
url: "/api/v0/user/logout",