Am I correct in thinking you want a login page that calls a login controller? Redirect to success page when credentials are correct, redirect back to the login page when credentials are not correct?
On 29 April 2014 09:23, Brendan Le Ny <[email protected]> wrote: > Le 28/04/2014 20:47, rejimk a écrit : > >> In the example you have provided, what page will be shown for successful >> login? >> Also, if you are returning INPUTm it'll go back to login page, right? >> > > My answer was partial. Actually LoginAction as this annotation: > > @Results({ > @Result(name="success", type="redirectAction", params = { > "actionName", "index", "namespace", "/" }) > }) > > (I use struts2-convention-plugin) > > And my execute() method is: > > @Override > public String execute() { > > if (email != null) { > > if (log.isDebugEnabled()) { > log.debug("try login user " + email); > } > > try { > > service.authenticateUser(email, password); > > } catch (DisabledExtranetUserException e) { > > addActionError("Account disabled"); > > return ERROR; > > } catch (InvalidLoginException e) { > > addFieldError("email", "Invalid credentials"); > addFieldError("password", ""); > > return ERROR; > > } > > return SUCCESS; > > } else { > > return INPUT; > > } > > } > > But I use ShiroFilter so in most of the cases in my app user will be > redirected to the url he originally asked (he was redirected to > authc.loginUrl by shiro filter for not being authentified). > > When user submit the login form (to "login.action" which is also > authc.loginUrl) Shiro will look in request for authentication parameter and > intercept the request to redirect it if user asked for another URL (so > execute() is not called). If not, the user pass in execute, SUCCESS is > returned in the guy is redirected to index.action (according to the > annotation). > > It's confusing but it works fine for me. > > -- > Brendan Le Ny, Code Lutin > [email protected] > (+33) 02 40 50 29 28 >
