1 Reply Latest reply on Apr 24, 2009 8:06 AM by Jabinara Begum

    Allowing only one user with one username to login

    Jabinara Begum Newbie

      Hello All


      My application requires that at a time multiple users with same username should not be allowed to login.  For this I was trying to get all the active sessions in the application.  But its not working.  Does anybody have any idea to implement this.


      Please do reply if u have an answer to this.


      Thanks guys

        • 1. Re: Allowing only one user with one username to login
          Jabinara Begum Newbie

          Hello All
          After spending 2 sleepless nights i got the answer, but not sure whether its the correct way or not. I want to sum it up here. 
          So what i did is I wrote a method where i checked for the logout time for that username, if the logout time is not null the n allow, i.e identity.login() else return back.


          Now while logging out we were able to catch the time stamp and persist it in the user table, but if session time out occurs, then we were not able to do this.  So in order to achieve this i wrote one ServletContextListener, in which i wrote one method with @Observer(org.jboss.seam.preDestroyContext.SESSION).  So it solved the problem of em is null and no transaction errors.  And I am able to persist successfully at the session time out.


          All the best