get autologin working
refactor