![](/img/trans.png)
[英]Form-based Authentication using HttpClient - j_security_check
[英]How to programatically authenticate user after changing password? Form-based authentication using j_security_check was used to login
更改密碼后如何以編程方式對用戶進行身份驗證? 使用j_security_check的基於表單的身份驗證進行登錄。 更改密碼后,用戶將被重定向到主頁(這是必需的),但是在提交屏幕或單擊鏈接/按鈕時,用戶將被重定向回到登錄頁面。 我認為這是因為用於在后台進行身份驗證的密碼仍然是舊密碼。
如果可以獲得HttpServletRequest
(這是JSF中的示例),則可以從那里調用login()
。
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest();
request.login(username, password);
獎勵信息:要注銷當前用戶,可以在HttpSession
上調用invalidate()
:
FacesContext context = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession)context.getExternalContext().getSession(true);
session.invalidate();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.