Beta 3 - multi user and login mechanism

Hi,
I am quite new to Vaadin and i am trying to port some old outdated Vaadin 6 project (written by somebody else) to Vaadin 7 (beta status does not matter)

I need a login mechanism in the application. In Vaadin 6, this was done by implementing the HttpServletRequestListener and setting a threadLocal instance on a new request and set some user object in the Application class. Then it was possible to get the userObject via the instance and some punlic getter Method.

How can the same be achieved in Vaadin 7? Unfortunately (and understandable), the book and Mini Tutorials are not updated to the latest version yet.

In Beta 3 now there is the VaadinServiceSession. If i understand it right, A new Session is created on the init() Method in the class which extends the UI.

Is it now enough to do something like this and store the userObject of the loggedIn User via VaadinServiceSession().getCurrent().setAttribute(“loggedInUser”, new User());?
Or do I still miss a very important point here.


Class MyUI extends UI{

@Override
public void init(VaadinRequest request){

 if(Boolean.TRUE.equals(VaadinServiceSession.getCurrent().getAttribute("loggedIn")){
  drawMainUserInterface(); 
 }
 else{
  //drawLoginUnterface and do some login mechanism. If successful, do:
  VaadinServiceSession.getCurrent().setAttribute("loggedIn", true);
  VaadinServiceSession.getCurrent().setAttribute("loggedInUser", new User());
  drawMainUserInterface();  
 }

}

The userObject of the user can then be accessed via VaadinServiceSession.getCurrent().getAttribute(“loggedInUser”);

And setting the UserInterface according to the loggedIn state can be handled via setContent() on UI.getCurrent() ?

Vaadin 7 has a threadlocal pattern built into it directly! You don’t have to implement it yourself as you had in Vaadin 6. You can anytime call MyUI ui = (MyUI)MyUI.getCurrent();. Then just put a setUser(User) and getUser(User) into your MyUI and you’re done.

That is easy. Thank you for the reply.

Hello,

I am quite new to Vaadin and similarly porting a Vaadin 6.8.0 project to 7.2.6
I am trying the same as mentioned but no success.
Can anybody give a snippet how it is implemented?
I do not find the setUser and getUser functions as prompt.

Thanks.