Announcement Announcement Module
Collapse
No announcement yet.
Bind a session variable upon login. Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bind a session variable upon login.

    Hello,

    I have set of users which are shop managers. I would like to bind shop object into session upon manager login.

    How do I do that?

    Thanks.

  • #2
    i did something similar by implementing my dao and extending the UserClass. It's not hard at all, looking at acegi source code may help, e.g. JdbcDaoImpl

    Comment


    • #3
      Also see the FAQ at http://acegisecurity.sourceforge.net for how to obtain the UserDetails from the ContextHolder post-authentication.

      Comment


      • #4
        another way to do it

        you could subclass AuthenticationProcessingFilter and override onSuccessfulAuthentication

        Code:
        protected void onSuccessfulAuthentication(HttpServletRequest req, HttpServletResponse resp, Authentication auth) throws IOException {
        		super.onSuccessfulAuthentication(req, resp, auth);
        		
        		Store store = getMyStore();
        		req.getSession().setAttribute("store",store);
        
        }

        Comment


        • #5
          Re: another way to do it

          Originally posted by dlevine
          Store store = getMyStore();
          This would be OK if the getMyStore() method just comes from somewhere local to your AuthenticationProcessingFilter subclass, but generally the "store" would likely be user-specific. As such you would want to use a custom AuthenticationDao that build a custom UserDetails and that UserDetails provides a "store" getter/setter pair. The "store" can then be accessed at any future time not from HttpSession but from ((MyUserDetails)((SecureContext)ContextHolder.getC ontext()).getAuthentication()).getStore().

          Comment

          Working...
          X