private void ValidateToken(string token, Action <bool, string> onRecievedToken) { WWWForm form = new WWWForm(); form.AddField("token", token); StartCoroutine(WebRequests.PostRequest(_JWTValidationURL, form, onRecievedToken)); }
/// <summary> /// Registration /// </summary> public void Registration(string username, string password, string email, Action onSuccessfulRegistration, Action <ErrorDescription> onError) { var signUpData = new SignUpData(); signUpData.username = username; signUpData.password = password; signUpData.email = email; var signUpDataJson = JsonUtility.ToJson(signUpData); string proxy = _isProxy ? "proxy/registration" : "user"; StartCoroutine(WebRequests.PostRequest( string.Format("https://login.xsolla.com/api/{0}?projectId={1}&login_url={2}&engine=unity&engine_v={3}&sdk=login&sdk_v={4}", proxy, _loginId, _callbackURL, Application.unityVersion, sdk_v), signUpDataJson, (status, message) => { print(message); ErrorDescription error = CheckForErrors(status, message, CheckRegistrationError); if (error == null && onSuccessfulRegistration != null) { onSuccessfulRegistration.Invoke(); } else if (error != null && onError != null) { onError.Invoke(error); } })); }
/// <summary> /// Sending Reset Password Message to email by login. /// </summary> public void ResetPassword(string email, Action onSuccessfulResetPassword, Action <ErrorDescription> onError) { WWWForm form = new WWWForm(); form.AddField("username", email); string proxy = _isProxy ? "proxy/registration/password/reset" : "password/reset/request"; StartCoroutine(WebRequests.PostRequest(string.Format("https://login.xsolla.com/api/{0}?projectId={1}&engine=unity&engine_v={2}&sdk=login&sdk_v={3}", proxy, _loginId, Application.unityVersion, sdk_v), form, (status, message) => { ErrorDescription error = CheckForErrors(status, message, CheckResetPasswordError); if (error == null && onSuccessfulResetPassword != null) { onSuccessfulResetPassword.Invoke(); } else if (error != null && onError != null) { onError.Invoke(error); } })); }
/// <summary> /// Login /// </summary> public void SignIn(string username, string password, bool remember_user, Action <XsollaUser> onSuccessfulSignIn, Action <ErrorDescription> onError) { var loginData = new LoginData(); loginData.username = username; loginData.password = password; loginData.remember_me = remember_user; var loginDataJson = JsonUtility.ToJson(loginData); string proxy = _isProxy ? "proxy/" : string.Empty; StartCoroutine(WebRequests.PostRequest( string.Format("https://login.xsolla.com/api/{0}login?projectId={1}&login_url={2}&engine=unity&engine_v={3}&sdk=login&sdk_v={4}", proxy, _loginId, _callbackURL, Application.unityVersion, sdk_v), loginDataJson, (status, message) => { ErrorDescription error = CheckForErrors(status, message, CheckSignInError); if (error != null) { if (onError != null) { onError.Invoke(error); } return; } Action <XsollaUser> onSuccess = (xsollaUser) => { if (onSuccessfulSignIn != null) { onSuccessfulSignIn.Invoke(xsollaUser); } if (remember_user) { SaveLoginPassword(username, password); } }; if (_isJWTValidationToken) { JWTValidation(message, (xsollaUser, errorDescription) => { if (errorDescription != null && onError != null) { onError.Invoke(errorDescription); } else { onSuccess.Invoke(xsollaUser); } }); } else { onSuccess.Invoke(new XsollaUser()); } } )); }