If i am going to delete employee if employee is logged in after deleting or disable his/her account how he will automatically logout from his account
How employee automatically logout after account deletion happen from admin side
If i am going to delete employee if employee is logged in after deleting or disable his/her account how he will automatically logout from his account
How employee automatically logout after account deletion happen from admin side
To actively logout the user, you'll need to send a push message which in turn basically triggers the submit of a hidden logout form. You can do this via a web socket. A kickoff example can be found in this answer: Notify only specific user(s) through WebSockets, when something is modified in the database.
To passively logout the user, you'll need to implement a servlet filter which checks on every single request if the currently logged-in user is still valid. Here's a kickoff example assuming that you're using homegrown user authentication (which is confirmed by the screenshot as visible in your deleted answer here):
@WebFilter("/whatever_url_pattern_covering_your_restricted_pages/*")
public class YourLoginFilter extends HttpFilter {
@Override
public void doFilter(HttpServletRequest request, HttpServletRequest response, FilterChain chain) throws IOException, ServletException {
HttpSession session = request.getSession(false);
YourUser user = (session == null) ? null : (YourUser) session.getAttribute("user");
if (user == null) {
// No logged-in user found, so redirect to login page.
response.sendRedirect(request.getContextPath() + "/login");
} else {
// Logged-in user found, so validate it.
if (yourUserService.isValid(user)) {
// User is still valid, so continue request.
chain.doFilter(request, response);
} else {
// User is not valid anymore (e.g. deleted by admin), so block request.
response.sendRedirect(request.getContextPath() + "/blocked");
}
}
}
}