Proper error checking in login