Announcement Announcement Module
Collapse
No announcement yet.
How to know if user is logged in? Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to know if user is logged in?

    Hi,

    Is it possible to know if a user is logged in or not? I would like to display a link ‘login’ if a user is not login and the link ‘logout’ if the user is already logged in. However I do not know how best to do this. For this project I am using only SpringFramework for my web flow and Acegi to manage the website security. If there is any documentation available regarding this I would be more then happy to read it out.

    Thanks and Regards,
    Sim085

  • #2
    I believe there is a tag for this:

    <authz:authorize ifAllGranted="ROLE_USER">
    <a href="..."> blah </a>
    </authz:authorize>

    Comment


    • #3
      hmm ...

      I will check on that one, if so, then I would not need a controller for that articular side of the application

      Thanks and Regards,
      Sim085

      Comment


      • #4
        You can check by

        session.getAttribute("ACEGI_SECURITY_CONTEXT");

        Once authentication successfully the object will store in the session.

        SecurityContextImpl obj = (SecurityContextImpl) session.getAttribute("ACEGI_SECURITY_CONTEXT");

        Comment


        • #5
          I would agree with peetdenny, the Authentication and Authorize tags are more convient then asking the session or request.

          Comment


          • #6
            Thanks to all

            I used the Authorize tags and it worked like a charm

            Thanks to all again,
            Regards,
            Sim085

            Comment

            Working...
            X