Merge branch 'main' of https://github.com/Newtbot/MP
This commit is contained in:
@ -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",
|
||||
|
Reference in New Issue
Block a user