Adds error handling for login and registration