mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-16 18:24:36 +00:00
Add /system/logout request to remove current authenticated user and
invalidate his session.
This commit is contained in:
@@ -243,6 +243,24 @@ public class SystemControl {
|
||||
return result;
|
||||
}, new JsonTransformer());
|
||||
|
||||
// http://ip_address:port/system/logout CORS request
|
||||
options(SYSTEM_CONTEXT + "/logout", (request, response) -> {
|
||||
response.status(HttpStatus.SC_OK);
|
||||
response.header("Access-Control-Allow-Origin", request.headers("Origin"));
|
||||
response.header("Access-Control-Allow-Methods", "GET, POST, PUT");
|
||||
response.header("Access-Control-Allow-Headers", request.headers("Access-Control-Request-Headers"));
|
||||
response.header("Content-Type", "text/html; charset=utf-8");
|
||||
return "";
|
||||
});
|
||||
// http://ip_address:port/system/logout invalidates user session
|
||||
put(SYSTEM_CONTEXT + "/logout", (request, response) -> {
|
||||
log.debug("logout....");
|
||||
bridgeSettings.getBridgeSecurity().removeAuthenticatedUser(request);
|
||||
response.status(HttpStatus.SC_OK);
|
||||
response.type("application/json");
|
||||
return "";
|
||||
});
|
||||
|
||||
// http://ip_address:port/system/presslinkbutton CORS request
|
||||
options(SYSTEM_CONTEXT + "/presslinkbutton", (request, response) -> {
|
||||
response.status(HttpStatus.SC_OK);
|
||||
@@ -558,4 +576,5 @@ public class SystemControl {
|
||||
pingListener();
|
||||
return "{\"control\":\"stopping\"}";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4813,15 +4813,24 @@ app.factory('Auth', function($resource, $rootScope, $sessionStorage, $http, $bas
|
||||
bridgeService.displayWarn("Login Error: ", error);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
auth.logout = function() {
|
||||
delete $sessionStorage.user;
|
||||
delete $rootScope.user;
|
||||
delete bridgeService.state.loggedInUser;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
auth.logout = function() {
|
||||
delete $sessionStorage.user;
|
||||
delete $rootScope.user;
|
||||
delete bridgeService.state.loggedInUser;
|
||||
// Logout on server side to destroy current session (fire and forget it)
|
||||
$http.put(bridgeService.state.systemsbase + "/logout").then(
|
||||
function (response) {
|
||||
// nothing more to do
|
||||
},
|
||||
function (error) {
|
||||
bridgeService.displayWarn("Logout Error: ", error);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
auth.checkPermissionForView = function(view) {
|
||||
if (!view.requiresAuthentication) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user