openmeetings-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From solo...@apache.org
Subject svn commit: r1455897 - in /openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/pages/auth: SignInPage.html SignInPage.java
Date Wed, 13 Mar 2013 11:57:49 GMT
Author: solomax
Date: Wed Mar 13 11:57:49 2013
New Revision: 1455897

URL: http://svn.apache.org/r1455897
Log:
HTML5: "remember me" functionality is added

Modified:
    openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/pages/auth/SignInPage.html
    openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/pages/auth/SignInPage.java

Modified: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/pages/auth/SignInPage.html
URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/pages/auth/SignInPage.html?rev=1455897&r1=1455896&r2=1455897&view=diff
==============================================================================
--- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/pages/auth/SignInPage.html
(original)
+++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/pages/auth/SignInPage.html
Wed Mar 13 11:57:49 2013
@@ -26,9 +26,10 @@
 			#login .ui-dialog .ui-dialog-titlebar-close {
 				display: none;
 			}
-			#login input {
-				width: 100px;
+			#login input:not([type='checkbox']) {
+				width: 170px;
 			}
+			#login input:
 		</style>
 	</wicket:head>
 	<wicket:extend>
@@ -57,6 +58,10 @@
 						<td><input wicket:id="pass" type="password" value="" /></td>
 					</tr>
 					<tr>
+						<td></td>
+						<td><input wicket:id="rememberMe" type="checkbox" /><label wicket:for="rememberMe"><wicket:ommessage
key="288" /></label></td>
+					</tr>
+					<tr>
 						<td align="right" colspan="2"><input type="submit" wicket:ommessage="value:112"/></td>
 					</tr>
 				</table>

Modified: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/pages/auth/SignInPage.java
URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/pages/auth/SignInPage.java?rev=1455897&r1=1455896&r2=1455897&view=diff
==============================================================================
--- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/pages/auth/SignInPage.java
(original)
+++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/pages/auth/SignInPage.java
Wed Mar 13 11:57:49 2013
@@ -22,6 +22,8 @@ import org.apache.openmeetings.web.app.A
 import org.apache.openmeetings.web.app.WebSession;
 import org.apache.openmeetings.web.pages.BasePage;
 import org.apache.wicket.RestartResponseException;
+import org.apache.wicket.authentication.IAuthenticationStrategy;
+import org.apache.wicket.markup.html.form.CheckBox;
 import org.apache.wicket.markup.html.form.HiddenField;
 import org.apache.wicket.markup.html.form.PasswordTextField;
 import org.apache.wicket.markup.html.form.RequiredTextField;
@@ -38,9 +40,6 @@ public class SignInPage extends BasePage
 	}
 	
 	public SignInPage() {
-		if (WebSession.get().isSignedIn()) {
-			throw new RestartResponseException(Application.get().getHomePage());
-		}
 		add(new SignInForm("signin"));
 	}
 	
@@ -49,23 +48,60 @@ public class SignInPage extends BasePage
         private String password;
         private String login;
         private String area = "";
+        private boolean rememberMe = false;
 
 		public SignInForm(String id) {
 			super(id);
 			
+			if (WebSession.get().isSignedIn()) {
+				alreadyLoggedIn();
+			} else {
+				IAuthenticationStrategy strategy = getApplication().getSecuritySettings().getAuthenticationStrategy();
+				// get username and password from persistence store
+				String[] data = strategy.load();
+
+				if ((data != null) && (data.length > 1)) {
+					// try to sign in the user
+					if (WebSession.get().signIn(data[0], data[1])) {
+						login = data[0];
+						password = data[1];
+
+						alreadyLoggedIn();
+					} else {
+						// the loaded credentials are wrong. erase them.
+						strategy.remove();
+					}
+				}
+			}
 			add(new FeedbackPanel("feedback"));
 			add(new RequiredTextField<String>("login", new PropertyModel<String>(this,
"login")));
 			add(new PasswordTextField("pass", new PropertyModel<String>(this, "password")).setResetPassword(true));
+			add(new CheckBox("rememberMe", new PropertyModel<Boolean>(this, "rememberMe")));
 			add(new HiddenField<String>("area", new PropertyModel<String>(this, "area"))
 					.setMarkupId("area")
 					.setOutputMarkupId(true));
 		}
+
+		private void alreadyLoggedIn() {
+			// logon successful. Continue to the original destination
+			continueToOriginalDestination();
+			// Ups, no original destination. Go to the home page
+			throw new RestartResponseException(Application.get().getHomePage());
+		}
 		
 		@Override
 		protected void onSubmit() {
+			IAuthenticationStrategy strategy = getApplication().getSecuritySettings().getAuthenticationStrategy();
 			if (WebSession.get().signIn(login, password)) {
 				WebSession.get().setArea(area);
 	 			setResponsePage(Application.get().getHomePage());
+				if (rememberMe) {
+					strategy.save(login, password);
+				} else {
+					strategy.remove();
+				}
+			} else {
+				strategy.remove();
 			}
 		}
 	}



Mime
View raw message