Commits

Juan Carlos Picado Herrera committed 450d781

SignUp user account, in progress

  • Participants
  • Parent commits 99bf29f

Comments (0)

Files changed (6)

File encuestame-business/src/main/java/org/encuestame/business/mail/MailServiceImpl.java

      }
 
     /**
+     * Sent email to confirm user account by email.
+     * @param user
+     */
+    public void sendConfirmYourAccountEmail(final SignUpBean user, final String inviteCode) {
+        MimeMessagePreparator preparator = new MimeMessagePreparator() {
+           public void prepare(MimeMessage mimeMessage) throws Exception {
+              MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
+              message.setTo(user.getEmail());
+              message.setSubject("Confirm Your Account");
+              message.setFrom(noEmailResponse);
+              final Map<String, Object> model = new HashMap<String, Object>();
+              model.put("user", user);
+              model.put("inviteCode", inviteCode);
+              String text = VelocityEngineUtils.mergeTemplateIntoString(
+                              velocityEngine, "confirm-your-account.vm", model);
+              message.setText(text, true);
+           }
+        };
+        send(preparator);
+     }
+
+    /**
      * Send Renew Password Email.
      * @param unitUserBean {@link UnitUserBean}.
      */

File encuestame-business/src/main/java/org/encuestame/business/service/SecurityService.java

         getAccountDao().saveOrUpdate(account);
         final UserAccount userAccount = new UserAccount();
         userAccount.setUsername(singUpBean.getUsername());
-        userAccount.setPassword(encodingPassword(singUpBean.getPassword() == null
-                ? EnMePasswordUtils.createRandomPassword(this.DEFAULT_LENGTH_PASSWORD) : singUpBean.getPassword() ));
+
+        final String password = encodingPassword(singUpBean.getPassword() == null
+                ? EnMePasswordUtils.createRandomPassword(this.DEFAULT_LENGTH_PASSWORD) : singUpBean.getPassword());
+        if(singUpBean.getPassword() == null){
+            singUpBean.setPassword(password);
+        }
+        //Invite Code
+        final String inviteCode = "12345678910"; //BUG 98
+        userAccount.setPassword(password);
         userAccount.setEnjoyDate(Calendar.getInstance().getTime()); //current date
         userAccount.setAccount(account);
         userAccount.setUserStatus(Boolean.TRUE);
         userAccount.setUserEmail(singUpBean.getEmail());
         userAccount.setCompleteName("");
-        userAccount.setInviteCode("12345678910");
+        userAccount.setInviteCode(inviteCode);
         getAccountDao().saveOrUpdate(userAccount);
         log.debug("singupUser created user account");
         //Add default permissions, if user is signup we should add admin access
         this.assingPermission(userAccount, permissions);
         log.debug("singupUser assigned default user account");
         //Create login.
-        setSpringSecurityAuthentication(singUpBean.getUsername(), singUpBean.getPassword(), permissions);
+        setSpringSecurityAuthentication(singUpBean.getUsername(), password, permissions);
         log.debug("singupUser autenticated");
-        if(this.suspendedNotification){
-            getServiceMail().sendPasswordConfirmationEmail(singUpBean);
+        if (this.suspendedNotification) {
+            getServiceMail().sendConfirmYourAccountEmail(singUpBean, inviteCode); //TODO: BUG 97
         }
         log.debug("singupUser notificated");
         log.debug("new user "+userAccount.getUsername());

File encuestame-business/src/main/resources/confirm-your-account.vm

+<html>
+<body>
+    <div style="padding:14px;margin-bottom:4px;background-color:#008eb9">
+        <div style="font-size:16px;font-weidth:bold:padding:5px;">
+            Encuestame Survey System
+        </div>
+    </div>
+    <h2>Hi, ${user.username} </h2>
+    <p>
+    <div>Please confirm your encuestame account by clicking this link:</div>
+    <a href="http://localhost:8080/encuestame/account/confirm/email/${user.username}/${inviteCode}">
+        http://localhost:8080/encuestame/account/confirm/email/${user.username}/${inviteCode}
+    </a><br/>
+    <div>Once you have confirmed your account, you can access full access.</div><br/>
+
+    <div>${app.url}</div><br/>
+
+    <div>If you have received this message in error, please <a href="#">click here.</a></div><br/>
+
+    <div style="font-size:10px;">
+        footer message footer message footer message footer message footer message footer message footer message
+        footer message footer message footer messagefooter message footer message footer message footer message
+         footer message footer message footer message footer messagefooter message footer message
+    </div>
+    </p>
+</body>
+</html>

File encuestame-utils/src/main/java/org/encuestame/utils/security/SignUpBean.java

     }
 
     /**
-     * @param captcha the captcha to set
+     * @param captcha
+     *            the captcha to set
      */
     public void setCaptcha(String captcha) {
         this.captcha = captcha;
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     *
      * @see java.lang.Object#toString()
      */
     @Override

File encuestame-war/src/main/webapp/WEB-INF/flows/signup/findFriends.jsp

 <%@ include file="/WEB-INF/jsp/includes/initPage.jsp" %>
 <%@ include file="/WEB-INF/jsp/includes/publicBody.jsp" %>
     <div id="mainUserWrapper">
-        <div class="form">
-            find friends.
-        </div>
+        <!--
+            //FUTURE: get Friends
+            http://code.google.com/apis/contacts/docs/3.0/developers_guide_java.html#Retrieving
+         -->
          <form:form modelAttribute="signUpBean">
+            <h2>
+                No friend contacts right now, check in the future.
+            </h2>
             <input type="submit" name="_eventId_next" value="Next"/>
         </form:form>
     </div>

File encuestame-war/src/main/webapp/WEB-INF/flows/signup/profile.jsp

             profile
         </div>
         <form:form modelAttribute="signUpBean">
-            <input type="submit" name="_eventId_next" value="Next"/>
+            <div class="">
+
+
+            </div>
+            <input type="submit" name="_eventId_next" value="Update My Profile"/>
         </form:form>
     </div>
 <%@ include file="/WEB-INF/jsp/includes/footer.jsp" %>