private static AsyncHTTPClient.DoneCallback WrapLoginCallback(AssetStoreClient.DoneLoginCallback callback) { return(delegate(AsyncHTTPClient job) { string text = job.text; if (!job.IsSuccess()) { AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGIN_ERROR; AssetStoreClient.sLoginErrorMessage = ((job.responseCode < 200 || job.responseCode >= 300) ? "Failed to login - please retry" : text); } else if (text.StartsWith("<!DOCTYPE")) { AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGIN_ERROR; AssetStoreClient.sLoginErrorMessage = "Failed to login"; } else { AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGGED_IN; if (text.Contains("@")) { AssetStoreClient.ActiveSessionID = AssetStoreClient.SavedSessionID; } else { AssetStoreClient.ActiveSessionID = text; } if (AssetStoreClient.RememberSession) { AssetStoreClient.SavedSessionID = AssetStoreClient.ActiveSessionID; } } callback(AssetStoreClient.sLoginErrorMessage); }); }
internal static void LoginWithRememberedSession(AssetStoreClient.DoneLoginCallback callback) { if (AssetStoreClient.sLoginState == AssetStoreClient.LoginState.IN_PROGRESS) { DebugUtils.LogWarning("Tried to login with remembered session while already in progress of logging in"); return; } AssetStoreClient.sLoginState = AssetStoreClient.LoginState.IN_PROGRESS; AssetStoreClient.sLoginErrorMessage = null; if (!AssetStoreClient.RememberSession) { AssetStoreClient.SavedSessionID = string.Empty; } Uri uri = new Uri(string.Format("{0}/login?reuse_session={1}&unityversion={2}&toolversion={3}&xunitysession={4}", new object[] { AssetStoreClient.AssetStoreUrl, AssetStoreClient.SavedSessionID, Uri.EscapeDataString(Application.unityVersion), Uri.EscapeDataString("V5.0.0"), "26c4202eb475d02864b40827dfff11a14657aa41" })); AssetStoreWebClient assetStoreWebClient = new AssetStoreWebClient(); AssetStoreClient.Pending pending = new AssetStoreClient.Pending() { conn = assetStoreWebClient, id = "login", callback = AssetStoreClient.WrapLoginCallback(callback) }; AssetStoreClient.pending.Add(pending); assetStoreWebClient.Headers.Add("Accept", "application/json"); assetStoreWebClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(AssetStoreClient.DownloadStringCallback); try { assetStoreWebClient.DownloadStringAsync(uri, pending); } catch (WebException webException) { pending.ex = webException; AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGIN_ERROR; } }
private static AsyncHTTPClient.DoneCallback WrapLoginCallback(AssetStoreClient.DoneLoginCallback callback) { // ISSUE: object of a compiler-generated type is created // ISSUE: reference to a compiler-generated method return(new AsyncHTTPClient.DoneCallback(new AssetStoreClient.\u003CWrapLoginCallback\u003Ec__AnonStorey52() { callback = callback }.\u003C\u003Em__8F)); }
internal static void LoginWithRememberedSession(AssetStoreClient.DoneLoginCallback callback) { if (AssetStoreClient.sLoginState == AssetStoreClient.LoginState.IN_PROGRESS) { Debug.LogError((object)"Tried to login with remembered session while already in progress of logging in"); } else { AssetStoreClient.sLoginState = AssetStoreClient.LoginState.IN_PROGRESS; if (!AssetStoreClient.RememberSession) { AssetStoreClient.SavedSessionID = string.Empty; } string _toUrl = AssetStoreClient.AssetStoreUrl + "/login?skip_terms=1&reuse_session=" + AssetStoreClient.SavedSessionID; AssetStoreClient.sLoginErrorMessage = (string)null; AsyncHTTPClient asyncHttpClient = new AsyncHTTPClient(_toUrl); asyncHttpClient.header["X-Unity-Session"] = "26c4202eb475d02864b40827dfff11a14657aa41" + AssetStoreClient.GetToken(); asyncHttpClient.doneCallback = AssetStoreClient.WrapLoginCallback(callback); asyncHttpClient.Begin(); } }
private static AssetStoreClient.DoneCallback WrapLoginCallback(AssetStoreClient.DoneLoginCallback callback) { return((AssetStoreResponse resp) => { AssetStoreClient.UserIconUrl = null; int num = -1; if (resp.HttpHeaders != null) { num = Array.IndexOf <string>(resp.HttpHeaders.AllKeys, "X-Unity-Reason"); } if (!resp.ok) { AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGIN_ERROR; AssetStoreClient.sLoginErrorMessage = (num < 0 ? resp.HttpErrorMessage ?? "Failed communication" : resp.HttpHeaders.Get(num)); AssetStoreClient.sLoginErrorMessage = (resp.HttpStatusCode != 401 ? AssetStoreClient.sLoginErrorMessage : "The email and/or password you entered are incorrect. Please try again."); AssetStoreClient.sLoginErrorMessage = (resp.HttpStatusCode != 500 ? AssetStoreClient.sLoginErrorMessage : "Server error. Possibly due to excess incorrect login attempts. Try again later."); DebugUtils.LogError(resp.HttpErrorMessage ?? "Unknown http error"); } else if (!resp.data.StartsWith("<!DOCTYPE")) { AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGGED_IN; JSONValue jSONValue = JSONParser.SimpleParse(resp.data); AssetStoreClient.ActiveSessionID = jSONValue["xunitysession"].AsString(false); AssetStoreClient.UserIconUrl = jSONValue.Get("keyimage.icon").AsString(false); if (AssetStoreClient.RememberSession) { AssetStoreClient.SavedSessionID = AssetStoreClient.ActiveSessionID; } } else { AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGIN_ERROR; AssetStoreClient.sLoginErrorMessage = (num < 0 ? "Failed to login" : resp.HttpHeaders.Get(num)); DebugUtils.LogError(resp.data ?? "no data"); } callback(AssetStoreClient.sLoginErrorMessage); }); }
private static AssetStoreClient.DoneCallback WrapLoginCallback(AssetStoreClient.DoneLoginCallback callback) { return(delegate(AssetStoreResponse resp) { AssetStoreClient.UserIconUrl = null; int num = -1; if (resp.HttpHeaders != null) { num = Array.IndexOf <string>(resp.HttpHeaders.AllKeys, "X-Unity-Reason"); } if (!resp.ok) { AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGIN_ERROR; AssetStoreClient.sLoginErrorMessage = ((num < 0) ? "Failed communication" : resp.HttpHeaders.Get(num)); DebugUtils.LogError(resp.HttpErrorMessage ?? "Unknown http error"); } else if (resp.data.StartsWith("<!DOCTYPE")) { AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGIN_ERROR; AssetStoreClient.sLoginErrorMessage = ((num < 0) ? "Failed to login" : resp.HttpHeaders.Get(num)); DebugUtils.LogError(resp.data ?? "no data"); } else { AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGGED_IN; JSONValue jsonvalue = JSONParser.SimpleParse(resp.data); AssetStoreClient.ActiveSessionID = jsonvalue["xunitysession"].AsString(false); AssetStoreClient.UserIconUrl = jsonvalue.Get("keyimage.icon").AsString(false); if (AssetStoreClient.RememberSession) { AssetStoreClient.SavedSessionID = AssetStoreClient.ActiveSessionID; } } callback(AssetStoreClient.sLoginErrorMessage); }); }
internal static void LoginWithCredentials(string username, string password, bool rememberMe, AssetStoreClient.DoneLoginCallback callback) { if (AssetStoreClient.sLoginState == AssetStoreClient.LoginState.IN_PROGRESS) { Debug.LogError((object)"Tried to login with credentials while already in progress of logging in"); } else { AssetStoreClient.sLoginState = AssetStoreClient.LoginState.IN_PROGRESS; AssetStoreClient.RememberSession = rememberMe; string str = AssetStoreClient.AssetStoreUrl + "/login?skip_terms=1"; AssetStoreClient.sLoginErrorMessage = (string)null; AsyncHTTPClient asyncHttpClient = new AsyncHTTPClient(str.Replace("http://", "https://")); asyncHttpClient.postData = "user="******"&pass="******"X-Unity-Session"] = "26c4202eb475d02864b40827dfff11a14657aa41" + AssetStoreClient.GetToken(); asyncHttpClient.doneCallback = AssetStoreClient.WrapLoginCallback(callback); asyncHttpClient.Begin(); } }
internal static void LoginWithCredentials(string username, string password, bool rememberMe, AssetStoreClient.DoneLoginCallback callback) { if (AssetStoreClient.sLoginState == AssetStoreClient.LoginState.IN_PROGRESS) { DebugUtils.LogWarning("Tried to login with credentials while already in progress of logging in"); return; } AssetStoreClient.sLoginState = AssetStoreClient.LoginState.IN_PROGRESS; AssetStoreClient.RememberSession = rememberMe; AssetStoreClient.sLoginErrorMessage = null; Uri address = new Uri(string.Format("{0}/login", AssetStoreClient.AssetStoreUrl)); AssetStoreWebClient assetStoreWebClient = new AssetStoreWebClient(); NameValueCollection nameValueCollection = new NameValueCollection(); nameValueCollection.Add("user", username); nameValueCollection.Add("pass", password); nameValueCollection.Add("unityversion", Application.unityVersion); nameValueCollection.Add("toolversion", "V4.1.0"); nameValueCollection.Add("license_hash", AssetStoreClient.GetLicenseHash()); nameValueCollection.Add("hardware_hash", AssetStoreClient.GetHardwareHash()); AssetStoreClient.Pending pending = new AssetStoreClient.Pending(); pending.conn = assetStoreWebClient; pending.id = "login"; pending.callback = AssetStoreClient.WrapLoginCallback(callback); AssetStoreClient.pending.Add(pending); assetStoreWebClient.Headers.Add("Accept", "application/json"); assetStoreWebClient.UploadValuesCompleted += AssetStoreClient.UploadValuesCallback; try { assetStoreWebClient.UploadValuesAsync(address, "POST", nameValueCollection, pending); } catch (WebException ex) { pending.ex = ex; AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGIN_ERROR; } }