Permalink
Browse files

WICKET-4115 let subclasses decide what to do when sign-in was remembered

  • Loading branch information...
1 parent 266ca76 commit cd632a5bfc2e5e842b791b49bb44d268c60fbc1e svenmeier committed Feb 21, 2013
View
35 ...uth-roles/src/main/java/org/apache/wicket/authroles/authentication/panel/SignInPanel.java
@@ -108,10 +108,12 @@ protected SignInForm getForm()
}
/**
- * @see org.apache.wicket.Component#onBeforeRender()
+ * Try to sign-in with remembered credentials.
+ *
+ * @see #setRememberMe(boolean)
*/
@Override
- protected void onBeforeRender()
+ protected void onConfigure()
{
// logged in already?
if (isSignedIn() == false)
@@ -129,11 +131,7 @@ protected void onBeforeRender()
username = data[0];
password = data[1];
- // logon successful. Continue to the original destination
- continueToOriginalDestination();
- // Ups, no original destination. Go to the home page
- throw new RestartResponseException(getSession().getPageFactory().newPage(
- getApplication().getHomePage()));
+ onSignInRemembered();
}
else
{
@@ -143,8 +141,7 @@ protected void onBeforeRender()
}
}
- // don't forget
- super.onBeforeRender();
+ super.onConfigure();
}
/**
@@ -251,6 +248,26 @@ protected void onSignInSucceeded()
}
/**
+ * Called when sign-in was remembered.
+ * <p>
+ * By default tries to continue to the original destination or switches to the application's
+ * home page.
+ * <p>
+ * Note: This method will be called during rendering of this panel, thus a
+ * {@link RestartResponseException} has to be used to switch to a different page.
+ *
+ * @see #onConfigure()
+ */
+ protected void onSignInRemembered()
+ {
+ // logon successful. Continue to the original destination
+ continueToOriginalDestination();
+
+ // Ups, no original destination. Go to the home page
+ throw new RestartResponseException(getApplication().getHomePage());
+ }
+
+ /**
* Sign in form.
*/
public final class SignInForm extends StatelessForm<SignInPanel>

0 comments on commit cd632a5

Please sign in to comment.