Spring 注销前安全提醒用户
Spring security alert user before logout
我这里有一个更改密码页面。一旦成功更改密码,我将注销用户,但我必须在注销 him/her 之前通知用户密码已成功更改。我应该怎么做呢?下面是我的代码:
@RequestMapping(value = "/changepassword", method = RequestMethod.POST)
public String change(Model model, String oldPassword, String newPassword, Principal principal) throws NoSuchAlgorithmException {
//Some method
return "redirect:/somename/j_spring_security_logout";
}
}
我想这是一个简单的技巧,但我就是想不出来..
我看到 2 个选项:
1.Just 拨打 ajax 电话更改密码。然后在客户端而不是服务器端重定向。例如(javascript 中的助记符代码)
ajaxCall.success = {
showMessage("Your session will be terminated. Please login again.")
//wait for 3 seconds and then redirect
setTimeout(function(){ window.location = "/somename/j_spring_security_logout" }, 3000);
}
2.Keep 代码原样,只需在重定向上添加一个请求参数:
return "redirect:/somename/j_spring_security_logout?notify_about_password=true";
在您的注销页面上添加一些额外的逻辑来处理这个请求参数。
我这里有一个更改密码页面。一旦成功更改密码,我将注销用户,但我必须在注销 him/her 之前通知用户密码已成功更改。我应该怎么做呢?下面是我的代码:
@RequestMapping(value = "/changepassword", method = RequestMethod.POST)
public String change(Model model, String oldPassword, String newPassword, Principal principal) throws NoSuchAlgorithmException {
//Some method
return "redirect:/somename/j_spring_security_logout";
}
}
我想这是一个简单的技巧,但我就是想不出来..
我看到 2 个选项:
1.Just 拨打 ajax 电话更改密码。然后在客户端而不是服务器端重定向。例如(javascript 中的助记符代码)
ajaxCall.success = {
showMessage("Your session will be terminated. Please login again.")
//wait for 3 seconds and then redirect
setTimeout(function(){ window.location = "/somename/j_spring_security_logout" }, 3000);
}
2.Keep 代码原样,只需在重定向上添加一个请求参数:
return "redirect:/somename/j_spring_security_logout?notify_about_password=true";
在您的注销页面上添加一些额外的逻辑来处理这个请求参数。