Announcement Announcement Module
Collapse
No announcement yet.
Change GrantedAuthority dinamically Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Change GrantedAuthority dinamically

    Hi!,
    In our application, one of the requirements is this: when an administrator manages users, he can update his own user and depromote himshelf to, for example, an user.

    This means that if he changes his own account from administrator to user he should have inmediatly just user rights. The problem is that, althougt I change logged user role, in the Authentication object of the SecurityApplicationContext the Granted authority is remains as an administrator.

    The question is, is there a way to change the GrantedAuthority content by code and without loging out and reathenticate?

    Thanks.

  • #2
    You can replace the security context with anything you want programatically. Just create a new Authentication object with the data you require and set it using

    Code:
    SecurityContextHolder.getContext().setAuthentication();

    Comment


    • #3
      Worked

      Done. It worked fine!

      Thanks Luke

      Comment

      Working...
      X