1 Reply Latest reply on Mar 4, 2008 2:43 AM by tony.herstell1

    login-redirect question

    tony.herstell1

      When the user attempts to go to a page that is protected by a must be logged in trap (in components.xml) I present the login page.
      This works fine, for login, and I get back to the page I was trying to get to when the John logs in.


      However... This page also allows the user to register AND also auto-logs them in at the end of the rego process.


      @End
        @TransactionAttribute(TransactionAttributeType.REQUIRED)
          public String processCaptcha() {
                  String valueToBeReturned = null;
               
                  if (user.getAvatar() == null || user.getAvatar().getName() == null || user.getAvatar().getName().equals("")) {
                    // The user didn't upload an image so clear this image holder.
                    user.setAvatar(null);
               }
      
               em.persist(user);
      
               if (!Identity.instance().isLoggedIn()) {
                   Identity.instance().setUsername(user.getEmail());
                   Identity.instance().setPassword(encryptionController.decrypt(user.getPassword()));
                   try {
                       Identity.instance().authenticate();
                        valueToBeReturned = "success";
                        user = null;
                        facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_INFO,"entity_user_create_successful");
      
                        try {
                             renderer.render("/WEB-INF/pages/user/registerSuccessful.xhtml");
                             log.info("Welcome Email sent!");
                        } catch (Exception e) {
                             log.info("Email sending failed: "+e);
                        }
                   
                   } catch (LoginException le) {
                       log.error("Could not login using party I just created." + le);
                       valueToBeReturned = null;
                   }
               }
               return valueToBeReturned;
          }
      



      This is causing a problem...


      Registering is a multi paged exercise... so my thinking was to make it a NESTED conversation so that when the conversation ended I would pop out to the outer conversation and automagically it would realise that I as now logged in and return to the returnToCapturedView as if I had just logged in.


      Ok, it was ambitious; and it didn't work.


      Any suggestions?