Updating login query and error code handling for logins