added form for login. fixed bugs with problem seting of user state.