From d785e04768509d7f770038b04eccbe6c9146426f Mon Sep 17 00:00:00 2001 From: strentini <none@none> Date: Wed, 25 Jan 2012 11:52:39 +0100 Subject: [PATCH] OO-92 : improve registration-process (last step) and fix password-check in form (step 4) --- .../registration/RegistrationController.java | 116 ++++++++++-------- .../olat/registration/RegistrationForm2.java | 2 + .../olat/registration/_content/finish.html | 27 ++++ .../_i18n/LocalStrings_de.properties | 2 +- .../_i18n/LocalStrings_en.properties | 2 +- .../_i18n/LocalStrings_es.properties | 2 +- .../_i18n/LocalStrings_fr.properties | 2 +- .../_i18n/LocalStrings_it.properties | 2 +- 8 files changed, 99 insertions(+), 56 deletions(-) create mode 100644 src/main/java/org/olat/registration/_content/finish.html diff --git a/src/main/java/org/olat/registration/RegistrationController.java b/src/main/java/org/olat/registration/RegistrationController.java index 955a46b2897..6c93e7a6e4b 100644 --- a/src/main/java/org/olat/registration/RegistrationController.java +++ b/src/main/java/org/olat/registration/RegistrationController.java @@ -38,6 +38,8 @@ import org.olat.core.commons.fullWebApp.LayoutMain3ColsController; import org.olat.core.gui.UserRequest; import org.olat.core.gui.components.Component; import org.olat.core.gui.components.form.flexible.FormItem; +import org.olat.core.gui.components.link.Link; +import org.olat.core.gui.components.link.LinkFactory; import org.olat.core.gui.components.panel.Panel; import org.olat.core.gui.components.velocity.VelocityContainer; import org.olat.core.gui.control.Controller; @@ -322,63 +324,31 @@ public class RegistrationController extends BasicController { } } else if (source == dclController) { if (event == Event.DONE_EVENT) { - + // OO-92 + // disclaimer done -> now display all entered information (as table, see http://jira.openolat.org/browse/OO-92) + // this is step 5 wic.setCurStep(5); - myContent.contextRemove("text"); + + // hide the text we don't need anymore myContent.contextPut("pwdhelp", ""); myContent.contextPut("loginhelp", ""); - myContent.contextPut("disclaimer", ""); - //myContent.contextPut("yourdata", translate("step5.reg.yourdata")); + myContent.contextPut("text", ""); - rf2.freeze(); - regarea.setContent(rf2.getInitialComponent()); + // finalize the registration by creating the user + User persitedUser = createNewUserAfterRegistration(); - // create user with mandatory fields from registrationform - //FIXME - UserManager um = UserManager.getInstance(); - User volatileUser = um.createUser( - rf2.getFirstName(), - rf2.getLastName(), - tempKey.getEmailAddress() - ); - // set user configured language - Preferences preferences = volatileUser.getPreferences(); + // show last screen + VelocityContainer finishVC = createVelocityContainer("finish"); - preferences.setLanguage(rf2.getLangKey()); - volatileUser.setPreferences(preferences); - // create an identity with the given username / pwd and the user object - String login = rf2.getLogin(); - String pwd = rf2.getPassword(); - Identity persistedIdentity = rm.createNewUserAndIdentityFromTemporaryKey(login, pwd, volatileUser, tempKey); - if (persistedIdentity == null) { - showError("user.notregistered"); - } else { - // update other user properties from form - List<UserPropertyHandler> userPropertyHandlers = um.getUserPropertyHandlersFor(RegistrationForm2.USERPROPERTIES_FORM_IDENTIFIER, false); - User persistedUser = persistedIdentity.getUser(); - for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) { - FormItem fi = rf2.getPropFormItem(userPropertyHandler.getName()); - userPropertyHandler.updateUserFromFormItem(persistedUser, fi); - } - // persist changes in db - um.updateUserFromIdentity(persistedIdentity); - // send notification mail to sys admin - String notiEmail = RegistrationModule.getRegistrationNotificationEmail(); - if (notiEmail != null) { - rm.sendNewUserNotificationMessage(notiEmail, persistedIdentity); - } - - // tell system that this user did accept the disclaimer - RegistrationManager.getInstance().setHasConfirmedDislaimer(persistedIdentity); - - // show last screen - myContent.contextPut("text", getTranslator().translate( - "step5.reg.text", - new String[] { WebappHelper.getServletContextPath(), login } - )); - } - - + List<UserPropertyHandler> userPropertyHandlers = UserManager.getInstance().getUserPropertyHandlersFor(RegistrationForm2.USERPROPERTIES_FORM_IDENTIFIER, false); + finishVC.contextPut("userPropertyHandlers", userPropertyHandlers); + finishVC.contextPut("user", persitedUser); + finishVC.contextPut("locale", getLocale()); + finishVC.contextPut("username", rf2.getLogin()); + finishVC.contextPut("text", getTranslator().translate("step5.reg.text", new String[] {"notused",rf2.getLogin() })); + finishVC.contextPut("loginhref", WebappHelper.getServletContextPath()); + + regarea.setContent(finishVC); } else if (event == Event.CANCELLED_EVENT) { ureq.getDispatchResult().setResultingMediaResource(new RedirectMediaResource(Settings.getServerContextPathURI())); } @@ -386,6 +356,50 @@ public class RegistrationController extends BasicController { } + /** + * OO-92 + * this will finally create the user, set all it's userproperties + * + * @return User the newly created, persisted User Object + */ + private User createNewUserAfterRegistration() { + // create user with mandatory fields from registration-form + UserManager um = UserManager.getInstance(); + User volatileUser = um.createUser(rf2.getFirstName(), rf2.getLastName(), tempKey.getEmailAddress()); + // set user configured language + Preferences preferences = volatileUser.getPreferences(); + + preferences.setLanguage(rf2.getLangKey()); + volatileUser.setPreferences(preferences); + // create an identity with the given username / pwd and the user object + String login = rf2.getLogin(); + String pwd = rf2.getPassword(); + Identity persistedIdentity = rm.createNewUserAndIdentityFromTemporaryKey(login, pwd, volatileUser, tempKey); + if (persistedIdentity == null) { + showError("user.notregistered"); + return null; + } else { + // update other user properties from form + List<UserPropertyHandler> userPropertyHandlers = um.getUserPropertyHandlersFor(RegistrationForm2.USERPROPERTIES_FORM_IDENTIFIER, false); + User persistedUser = persistedIdentity.getUser(); + for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) { + FormItem fi = rf2.getPropFormItem(userPropertyHandler.getName()); + userPropertyHandler.updateUserFromFormItem(persistedUser, fi); + } + // persist changes in db + um.updateUserFromIdentity(persistedIdentity); + // send notification mail to sys admin + String notiEmail = RegistrationModule.getRegistrationNotificationEmail(); + if (notiEmail != null) { + rm.sendNewUserNotificationMessage(notiEmail, persistedIdentity); + } + + // tell system that this user did accept the disclaimer + RegistrationManager.getInstance().setHasConfirmedDislaimer(persistedIdentity); + return persistedUser; + } + } + protected void doDispose() { // } diff --git a/src/main/java/org/olat/registration/RegistrationForm2.java b/src/main/java/org/olat/registration/RegistrationForm2.java index 2626bdb88d9..e2da4c143b8 100644 --- a/src/main/java/org/olat/registration/RegistrationForm2.java +++ b/src/main/java/org/olat/registration/RegistrationForm2.java @@ -242,6 +242,8 @@ public class RegistrationForm2 extends FormBasicController { } if (!newpass1.getValue().equals(newpass2.getValue())) { newpass2.setErrorKey("form.check5", null); + // OO-92 : must return false, if passwords don't match! + return false; } return true; } diff --git a/src/main/java/org/olat/registration/_content/finish.html b/src/main/java/org/olat/registration/_content/finish.html new file mode 100644 index 00000000000..915eb6fda66 --- /dev/null +++ b/src/main/java/org/olat/registration/_content/finish.html @@ -0,0 +1,27 @@ + + +#* + velocity template for the last step (5) in the registration process + it displays all entered values (except pw and language) in a table and + provides a button that links to the login-screen of OpenOLAT +*# + +$r.translate("step5.reg.yourdata") +<div class="b_border_box" style="width:20%;"> + <table> + <tr> + <td><label>$r.translate("user.login"):</label></td> + <td>$username</td> + </tr> + #foreach( $propertyHandler in $userPropertyHandlers ) + <tr> + <td><label>$r.translate($propertyHandler.i18nFormElementLabelKey()):</label></td> + <td>$!propertyHandler.getUserPropertyAsHTML($user, $locale)</td> + </tr> + #end + </table> +</div> +<p style="margin-top:12px;"> +$text<br /> +<a href="$loginhref" class="b_button b_button_preferred"><span>Login</span></a> +</p> \ No newline at end of file diff --git a/src/main/java/org/olat/registration/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/registration/_i18n/LocalStrings_de.properties index a9c623efb47..4e2d1268f3d 100644 --- a/src/main/java/org/olat/registration/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/registration/_i18n/LocalStrings_de.properties @@ -74,7 +74,7 @@ step3.pw.text=Bitte beachten Sie bei der Eingabe des neuen OpenOLAT-Passwortes f step3.reg.text=Um die Registrierung abzuschliessen, f\u00FCllen Sie bitte das Formular mit Ihren Angaben aus. step4.pw.text=Sie haben Ihr OpenOLAT-Passwort neu gesetzt. step4.reg.text=<b>Bitte akzeptieren Sie die Nutzungsbedingungen, bevor Sie fortfahren.</b> -step5.reg.text=<p><b>Willkommen bei OpenOLAT\!</b><p>Sie k\u00F6nnen sich nun <a href\="{0}/">mit Ihrem Benutzernamen <b>{1}</b> und Passwort anmelden.</a> +step5.reg.text=Sie k\u00F6nnen sich nun mit Ihrem Benutzernamen <b>{1}</b> und Passwort anmelden: step5.reg.yourdata=Zusammenfassung Ihrer Angaben\: pwchange.homelink=Klicken Sie hier um sich anzumelden submit.accept=Akzeptieren diff --git a/src/main/java/org/olat/registration/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/registration/_i18n/LocalStrings_en.properties index 16aa62f0733..88434f65694 100644 --- a/src/main/java/org/olat/registration/_i18n/LocalStrings_en.properties +++ b/src/main/java/org/olat/registration/_i18n/LocalStrings_en.properties @@ -75,7 +75,7 @@ step3.pw.text=Please consider the following instructions for setting an OpenOLAT step3.reg.text=In order to finish your registration, please fill in the form. step4.pw.text=You have changed your OpenOLAT password successfully. step4.reg.text=<b>Please read the terms of use before proceeding.</b> -step5.reg.text=<p><b>Welcome to OpenOLAT\!</b></p>You can now log in <a href\="{0}/">with your OpenOLAT user name <b>{1}</b> and password.</a> +step5.reg.text=You can now log in with your OpenOLAT user name <b>{1}</b> and password: step5.reg.yourdata=Summary of your data\: submit.accept=Accept submit.cancel=Cancel diff --git a/src/main/java/org/olat/registration/_i18n/LocalStrings_es.properties b/src/main/java/org/olat/registration/_i18n/LocalStrings_es.properties index d7d5e6fa2ca..13325a45b1e 100644 --- a/src/main/java/org/olat/registration/_i18n/LocalStrings_es.properties +++ b/src/main/java/org/olat/registration/_i18n/LocalStrings_es.properties @@ -59,7 +59,7 @@ step3.pw.text=Por favor utiliza las siguientes instrucciones para establecer tu step3.reg.text=Para terminar tu registro, por favor completa el formulario. step4.pw.text=Has cambiado tu contrase\u00F1a OpenOLAT con \u00E9xito. step4.reg.text=<b>Por favor lee las condiciones de uso antes de proceder.</b> -step5.reg.text=<p><b>Bienvenido a OpenOLAT\!</b></p>Ahora puedes identificarte <a href\="{0}/">con tu nombre de usuario <b>{1}</b> y contrase\u00F1a.</a> +step5.reg.text=Ahora puedes identificarte con tu nombre de usuario <b>{1}</b> y contrase\u00F1a: step5.reg.yourdata=Resumen de tus datos\: submit.accept=Aceptar submit.cancel=Cancelar diff --git a/src/main/java/org/olat/registration/_i18n/LocalStrings_fr.properties b/src/main/java/org/olat/registration/_i18n/LocalStrings_fr.properties index e93cf465b9b..d0facd46507 100644 --- a/src/main/java/org/olat/registration/_i18n/LocalStrings_fr.properties +++ b/src/main/java/org/olat/registration/_i18n/LocalStrings_fr.properties @@ -74,7 +74,7 @@ step3.pw.text=Lors de l'introduction du nouveau mot de passe, veuillez SVP tenir step3.reg.text=Pour terminer l'enregistrement, veuillez remplir le formulaire avec vos donn\u00E9es step4.pw.text=Un nouveau mot de passe OpenOLAT vous a \u00E9t\u00E9 affect\u00E9. step4.reg.text=<b>Veuillez SVP accepter les conditions d'utilisation avant de continuer.</b> -step5.reg.text=<p><b>Bienvenue dans OpenOLAT\!</b><p>Vous pouvez maintenant vous annoncer <a href\="{0}/">avec votre nom d'utilisateur <b>{1}</b> et votre mot de passe.</a> +step5.reg.text=Vous pouvez maintenant vous annoncer avec votre nom d'utilisateur <b>{1}</b> et votre mot de passe: step5.reg.yourdata=R\u00E9sum\u00E9 de vos donn\u00E9es submit.accept=Accepter submit.cancel=Annuler diff --git a/src/main/java/org/olat/registration/_i18n/LocalStrings_it.properties b/src/main/java/org/olat/registration/_i18n/LocalStrings_it.properties index 42356fbdfab..bbc8c292134 100644 --- a/src/main/java/org/olat/registration/_i18n/LocalStrings_it.properties +++ b/src/main/java/org/olat/registration/_i18n/LocalStrings_it.properties @@ -74,7 +74,7 @@ step3.pw.text=Quando imposta la Sua password consideri i punti seguenti, p.f.\: step3.reg.text=Per concludere la registrazione completi il modulo con i Suoi dati, p.f. step4.pw.text=Ha impostato la Sua nuova password. step4.reg.text=<b>Legga le condizioni prima di procedere, p.f.</b> -step5.reg.text=<p><b>Benvenuta/o a OpenOLAT</b><p>Ora si pu\u00F2 connettere <a href\="{0}/">con il Suo nome d'utente <b>{1}</b> e la password.</a> +step5.reg.text=Ora si pu\u00F2 connettere con il Suo nome d'utente <b>{1}</b> e la password: step5.reg.yourdata=Riassunto dei Suoi dati\: submit.accept=Accetta submit.cancel=Interrompere -- GitLab