6 Replies Latest reply on Mar 19, 2007 6:21 AM by ikazarno

    additional fields on the login page

    ikazarno

      Hi!

      Is it possible to add additional fields to the login page (login form) and access the input values after login during the first render phase of a portlet?

      Thanks!

      Igor

        • 1. Re: additional fields on the login page
          antoine_h

          Should not be easy in a proper way.

          1) Look at the Tomcat Authentification process.
          look how the UserName and Password from the form are passed to the Jaas login module.
          and then add a parameter and get it in the jaas login module, then up to the portlet (see 2).

          but you may have to modify Tomcat... which is not recommended.
          may be all the parameters from the form are passed to the login module. Then do as in 2) to retrieve them.

          2) add the parameter to the username (concatenation with a special separator), then create your own jaas login module (similar to the one provided), and parse the username to retrieve the name and parameter.
          use javascript to concatenate the name with the extra parameter.
          In the jaas login module : make your own Principal (inherited from java Principal), with the added parameters. In the porlet, retrieve the parameter from your Principal.

          3) in the html form : add some javascript to write a cookie with the parameter. Then, in the javascript, send the form httprequest.
          in the portlet render method, retrieve the cookie (it should be in the list of cookies in the httprequest). use the helper in this post :
          http://jboss.org/index.html?module=bb&op=viewtopic&t=104250

          just curious : parameter what for ?

          • 2. Re: additional fields on the login page
            ikazarno

            our customer would like to set the application language during login?

            • 3. Re: additional fields on the login page
              ikazarno

              this is not a proper way to set the locale, it is saved in the user profile... but customer is a king! :)

              • 4. Re: additional fields on the login page
                theute

                This sounds weird... Like 'very' weird to me.

                Are you sure he wants this ?

                I mean if the user can log in it means that there is an account for him, if there is an account the preferred language could have been defined.

                Unless your client has users who want to change their language on different login i don't see a rational reason behing this.

                At worse, If the accounts have been created for the user, you could intercept the call and ask the user *after* login to fill his profile with his favorite language (and probably other things)

                Otherwise Antoine_h is right :)

                • 5. Re: additional fields on the login page
                  ikazarno

                  This not only sounds weird, this is weird :) Particularly if the user can always change his preferred location in the profile! But it simply for me to quickly implement this requirement than to convince the customer that such behavior is atypical.

                  • 6. Re: additional fields on the login page
                    ikazarno

                    I have a problem with the approach 2.

                    "Antoine_h" wrote:


                    2) add the parameter to the username (concatenation with a special separator), then create your own jaas login module (similar to the one provided), and parse the username to retrieve the name and parameter.
                    use javascript to concatenate the name with the extra parameter.



                    I have implemented my own login module in the way described above. However, although the method getUsername() of the module returns a correct value, I have a problem with the UserInterceptor. The method req.getRemoteUser() returns a not parsed username with the separator and as a consequence I get NoSuchUserException in UserModule:

                    org.jboss.portal.core.model.NoSuchUserException: No such user No such user user@mydomain.com#en
                    org.jboss.portal.core.impl.user.UserModuleImpl.findUserByUserName(UserModuleImpl.java:123)
                    org.jboss.portal.core.aspects.server.UserInterceptor.invoke(UserInterceptor.java:100)

                    I think I should try implement the third approach with the cookie? Or there is a simple solution for the problem of UserInterceptor?