fixed login logic and isAuthenticated in event handler