Redirection to undefined after logging in