Fix login bug, handle login errors