Results 1 to 4 of 4

Thread: Assessing the user from within Spring webflow - how to?

  1. #1

    Default Assessing the user from within Spring webflow - how to?

    I have tried every approach I can think of to access the currentUser from within Spring webflow.

    My user has authenticated via Spring Social LinkedIn.

    What would be the strategy?

    It is not, for me, <evaluate expression="currentUser" result="currentUser" result-type=""/>

    Greg

  2. #2

    Default

    I'm not sure about 'social user', I'll face the issue later, but now for getting 'internal authenticated user' I have something like that in -flow.xml and in Controller class:
    Code:
        <on-start>
            <evaluate expression="myController.initializeForm(currentUser)" result="flowScope.myForm"/>
             ..........
        </on-start>
    ......
    
    @Controller
    public class MyController {
        @Autowired
        private YourUserService userService;
    
    ....
        public FormBeanClass initializeForm(Principal principal) {
    ......
            FormBeanClass myFormBean = new FormBeanClass()
            if (principal != null && principal.getName() != null) {
                UserXXClass user = userService.findByUserName(principal.getName());
                // most probably user will never be == null, otherwise it won't be authenticated
                ...............
               // do whenever you want
               myFormBean.setUser(...)
               myFormBean.setUserId(.......)
           }
           return myFormBean;
        }
    Best regards.

  3. #3

    Default Nice

    Thanks blandger.

    I would never have thought of that. Firstly because I assume (and still do) that there must be a way to directly assess from webflow. But also I am not cleaver enough to think of using a controller like that. I presume @Controller means you get access to the principal.

    Thanks again.

  4. #4

    Default

    You are welcome.
    Quote Originally Posted by greg.soulsby View Post
    Thanks blandger.
    I would never have thought of that. ......... But also I am not cleaver enough to think of using a controller like that.
    I'm also not so clever as I wanted to be, I found it somewhere.
    Quote Originally Posted by greg.soulsby View Post
    I presume @Controller means you get access to the principal.Thanks again.
    Yes, that means...
    Code:
        @RequestMapping(value = "/profile", method = RequestMethod.GET)
        public String profile(Model model, Principal principal) {
    .....
    Quote Originally Posted by greg.soulsby View Post
    Thanks again.
    When you need to pass request parameter into web-flow (controller or service class) you can ask me how.
    Best regards.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •