public ActionResult Index(CloudUser cloudUser) { if (cloudUser.IsGoodInfo()) { try { using (var context = new StorageBoxContext()) { using (var transaction = context.Database.BeginTransaction()) { try { cloudUser.SetPersonalFolder(); context.Users.Add(cloudUser); context.SaveChanges(); transaction.Commit(); } catch { transaction.Rollback(); } } } } catch (Exception ex) { Debug.WriteLine(ex); } } return(RedirectToAction("Index", "Authorization")); }
static public Task <CloudUser> LogIn(String uName, String uPas) { CloudApp.Init(code, key); var u2 = new CloudUser(); u2.Set("username", uName); u2.Set("password", uPas); Debug.WriteLine("Starting login"); return(u2.LoginAsync()); }
static public Task <CloudUser> SignUp(String uName, String uPas, String uEmail) { CloudApp.Init(code, key); var u2 = new CloudUser(); u2.Username = uName; u2.Password = uPas; u2.Email = uEmail; return(u2.SignupAsync()); }
// ========================================================================================================================= // === public interface ==================================================================================================== // ========================================================================================================================= #region --- internal ... static CloudUser GetInstance() { if (ms_Instance == null) { GameObject go = new GameObject("CloudUser"); ms_Instance = go.AddComponent <CloudUser>(); GameObject.DontDestroyOnLoad(ms_Instance); ms_Instance.LoadAuthenticationData(); } return(ms_Instance); }
protected override void OnViewShow() { m_PasswordLength = -1; CloudUser cloudUser = CloudUser.instance; if (cloudUser.GetLoginData(ref m_LoadedNickName, ref m_LoadedUserName, ref m_LoadedPassword, ref m_LoadedPasswordLength, ref m_LoadedRememberMe, ref m_LoadedAutoLogin) == false) { m_LoadedUserName = m_UserName = s_DefaultUserNameText; m_LoadedPassword = m_PasswordHash = s_DefaultPasswordText; m_LoadedPasswordLength = m_PasswordLength = 0; m_LoadedRememberMe = m_RememberMe = true; m_LoadedAutoLogin = m_AutoLogin = false; } else { m_UserName = m_LoadedUserName.ToLower(); m_PasswordHash = m_LoadedPassword; m_RememberMe = m_LoadedRememberMe; m_PasswordLength = m_LoadedPasswordLength; m_AutoLogin = m_LoadedAutoLogin; } string userName = GuiBaseUtils.FixNameForGui(m_UserName); m_UserNameButton.SetNewText(userName); if (m_UserName != s_DefaultUserNameText) { m_UserNameButton.TextFieldText = userName; } m_PasswordButton.TextFieldText = ""; m_PasswordButton.SetNewText(passwordGUIText); ; m_RememberMeButton.SetValue(m_RememberMe); m_AutoLoginButton.SetValue(m_AutoLogin); UpdateLoginButton(); #if UNITY_STANDALONE //there is no back on PC/MAC GetWidget("Back_Button").Show(false, true); #endif base.OnViewShow(); }
public ActionResult Index(string userName, string password) { user = flashCardDataContex.CloudUsers.First(x => x.UserEmail == userName & x.Password == password); if (user == null) { ViewBag.ErrorMessage = "No User Found Please Check Password"; } Session.Add("UserID", user.Id); List<CloudFlashCardSet> cloudSets = flashCardDataContex.CloudFlashCardSets.Where(x => x.UserID == user.Id).ToList(); List<FlashCardSet> sets = cloudConverter.ConvertCloudSetToSet(cloudSets); ViewBag.UserIsLoggedIn = true; return View(sets); }
public object Get(GetOneCurrentUser request) { WebOneUser result = new WebOneUser(); var context = TepWebContext.GetWebContext(PagePrivileges.UserView); try { context.Open(); context.LogInfo(this, string.Format("/one/user/current GET ProviderId='{0}'", request.ProviderId)); int provId = (request.ProviderId != 0 ? request.ProviderId : context.GetConfigIntegerValue("One-default-provider")); User user = User.FromId(context, context.UserId); string username = user.Email; try{ CloudUser usercloud = CloudUser.FromIdAndProvider(context, context.UserId, provId); if (!String.IsNullOrEmpty(usercloud.CloudUsername)) { username = usercloud.CloudUsername; } }catch (Exception) {} OneCloudProvider oneCloud = (OneCloudProvider)CloudProvider.FromId(context, provId); USER_POOL pool = oneCloud.XmlRpc.UserGetPoolInfo(); foreach (object u in pool.Items) { if (u is USER_POOLUSER) { USER_POOLUSER oneuser = u as USER_POOLUSER; if (oneuser.NAME == username) { result = new WebOneUser { Id = oneuser.ID, Name = oneuser.NAME, Password = oneuser.PASSWORD, AuthDriver = oneuser.AUTH_DRIVER }; break; } } } context.Close(); } catch (Exception e) { context.LogError(this, e.Message, e); context.Close(); throw e; } return(result); }
private void btnSignUp_Click(object sender, EventArgs e) { _username = tbUserName.Text; _password = tbPassword.Text; _email = tbEmail.Text; if (!CheckFields()) { return; } try { CloudUser outuser; Debug.WriteLine("Thread #{0} is calling Signup...", Thread.CurrentThread.ManagedThreadId); try { var task = Task.Run(async() => await ServerUpDown.SignUp(_username, _password, _email)); task.Wait(); outuser = task.Result; } catch { outuser = new CloudUser(); outuser.Username = "******"; } Debug.WriteLine("Signup has finished..."); if (outuser.Username == "Exception") { MessageBox.Show("Error has occured"); } else { MessageBox.Show("User created Successfully!"); this.DialogResult = DialogResult.OK; this.Close(); } } catch (Exception) { MessageBox.Show("Unknonw Error has occured."); this.Close(); } }
public void Login() { _helper.ToggleInputs(false); _helper.SetInfoText("Logging in..."); IUIWindowButton iButton = (IUIWindowButton)button; _state = State.Waiting; // _username = "******"; // _password = "******"; CloudUser.Login(_username, _password, () => { _state = State.Success; }, s => { _state = State.Failed; Debug.Log(s); }); }
public ActionResult Index(CloudUser user) { if (user != null && WS.IsGoodString(user.Login) && WS.IsGoodString(user.Passwords)) { try { using (var context = new StorageBoxContext()) { CloudUser cloudUser = context.Users.FirstOrDefault( x => x.Login.ToLower().Equals(user.Login.ToLower()) && x.Passwords.Equals(user.Passwords)); if (cloudUser != null) { if (WS.IsGoodString(cloudUser.FolderName)) { string basePath = Server.MapPath("~/Upload/PrivateRepository"); if (Directory.Exists(basePath)) { string path = Path.Combine(basePath, cloudUser.FolderName); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } Session["currPuth"] = path; Session["rootPuth"] = path; Session["authorized"] = true; } } } } } catch (Exception ex) { Debug.WriteLine(ex); } } return(RedirectToAction("Index", "Home")); }
public async Task <IActionResult> Register(RegisterViewModel vm) { if (ModelState.IsValid) { if (await _userManager.FindByEmailAsync(vm.Email) == null) { var user = new CloudUser() { UserName = vm.Username, Email = vm.Email, Registered = DateTime.Now }; var registerResult = await _userManager.CreateAsync(user, vm.Password); if (registerResult.Succeeded) { return(RedirectToAction("Login", "Home")); } } } return(View()); }
public object Post(CreateOneUser request) { WebOneUser result; var context = TepWebContext.GetWebContext(PagePrivileges.UserView); try { context.Open(); int provId = (request.ProviderId != 0 ? request.ProviderId : context.GetConfigIntegerValue("One-default-provider")); User user = User.FromId(context, context.UserId); string username = user.Email; try{ CloudUser usercloud = CloudUser.FromIdAndProvider(context, context.UserId, provId); if (!String.IsNullOrEmpty(usercloud.CloudUsername)) { username = usercloud.CloudUsername; } }catch (Exception) {} OneCloudProvider oneCloud = (OneCloudProvider)CloudProvider.FromId(context, provId); //create user int id = oneCloud.XmlRpc.UserAllocate(username, request.Password, (String.IsNullOrEmpty(request.AuthDriver) ? "x509" : request.AuthDriver)); USER oneuser = oneCloud.XmlRpc.UserGetInfo(id); context.LogInfo(this, string.Format("/one/user POST ProviderId='{0}',Id='{1}'", request.ProviderId, id)); List <KeyValuePair <string, string> > templatePairs = new List <KeyValuePair <string, string> >(); templatePairs.Add(new KeyValuePair <string, string>("USERNAME", username)); templatePairs.Add(new KeyValuePair <string, string>("VM_USERNAME", user.Username)); try{ GithubProfile github = GithubProfile.FromId(context, user.Id); if (!String.IsNullOrEmpty(github.Name)) { templatePairs.Add(new KeyValuePair <string, string>("GITHUB_USERNAME", github.Name)); } if (!String.IsNullOrEmpty(github.Email)) { templatePairs.Add(new KeyValuePair <string, string>("GITHUB_EMAIL", github.Email)); } if (!String.IsNullOrEmpty(github.Token)) { templatePairs.Add(new KeyValuePair <string, string>("GITHUB_TOKEN", github.Token)); } }catch (Exception) {} //update user template string templateUser = CreateTemplate((XmlNode[])oneuser.TEMPLATE, templatePairs); if (!oneCloud.XmlRpc.UserUpdate(id, templateUser)) { throw new Exception("Error during update of user"); } //add user to group GEP oneCloud.XmlRpc.UserUpdateGroup(id, context.GetConfigIntegerValue("One-GEP-grpID")); result = new WebOneUser { Id = oneuser.ID, Name = oneuser.NAME, Password = oneuser.PASSWORD, AuthDriver = oneuser.AUTH_DRIVER }; context.Close(); } catch (Exception e) { context.LogError(this, e.Message, e); context.Close(); throw e; } return(result); }
public void EndDelegate() { CloudUser cuser = CloudUser.FromIdAndProvider(context, context.UserId, oneCloud.Id); cloudusername = cuser.CloudUsername; }
public void StartDelegate(int idusr) { CloudUser cuser = CloudUser.FromIdAndProvider(context, idusr, oneCloud.Id); cloudusername = cuser.CloudUsername; }
IEnumerator BuyPremiumAccount_Coroutine(int acctType) { int idx = acctType - 1; int gold = ShopDataBridge.Instance.PlayerGold; int price = m_Accounts[idx].RealPrice; string acctTypeID = m_Accounts[idx].Id; CloudUser user = CloudUser.instance; // not enough golds if (price > gold) { ShopItemId itemId = ShopDataBridge.Instance.GetPremiumAcct(acctTypeID); if (itemId == ShopItemId.EmptyId) { // ... yield break; } int fundsNeeded = price - gold; bool buySucceed = true; ShopItemId reqIAP = ShopDataBridge.Instance.FindFundsItem(fundsNeeded, true); if (reqIAP.IsEmpty()) { yield break; } GuiShopNotFundsPopup.Instance.AddFundsID = reqIAP; GuiPopup popup = Owner.ShowPopup("NotFundsPopup", "", "", (inPopup, inResult) => { switch (inResult) { case E_PopupResultCode.Cancel: buySucceed = false; break; case E_PopupResultCode.Failed: buySucceed = false; break; } }); //Debug.Log("Popup Visible:" + popup.IsVisible); while (popup.IsVisible == true) { yield return(new WaitForEndOfFrame()); } if (buySucceed == false) { yield break; } //Debug.Log("IAP success:" + buySucceed); } // store current status of premium account bool hadPremiumAccount = user.isPremiumAccountActive; // create cloud action BaseCloudAction action = new BuyPremiumAccountAndFetchPPI(user.authenticatedUserID, acctTypeID); GameCloudManager.AddAction(action); // show message box GuiPopupMessageBox msgBox = (GuiPopupMessageBox)Owner.ShowPopup("MessageBox", TextDatabase.instance[01140017], TextDatabase.instance[01140018], (popup, result) => { if (action.isSucceeded == true) { Owner.Back(); SendResult(E_PopupResultCode.Ok); } }); msgBox.SetButtonVisible(false); msgBox.SetButtonEnabled(false); // wait for async action... while (action.isDone == false) { yield return(new WaitForEndOfFrame()); } // update message box int textId = 01140021; if (action.isSucceeded == true) { textId = hadPremiumAccount == true ? 01140020 : 01140019; } msgBox.SetText(TextDatabase.instance[textId]); msgBox.SetButtonVisible(true); msgBox.SetButtonEnabled(true); }
internal static object Deserialize(object data) { if (data.GetType() == typeof(ArrayList)) { ArrayList newList = new ArrayList(); for (int i = 0; i < ((ArrayList)data).Count; i++) { newList.Add(Deserialize((((ArrayList)data)[i]))); } return(newList); } else if (data.GetType().IsArray || data.GetType() == typeof(JArray)) { ArrayList newList = new ArrayList(((IEnumerable)data).Cast <object>() .Select(x => Deserialize(x)) .ToList()); return(newList); } else if (data.GetType() == typeof(Dictionary <string, Object>) || data.GetType() == typeof(JObject)) { CB.CloudObject obj = null; Dictionary <string, Object> tempData = null; if (data.GetType() == typeof(JObject)) { tempData = ((JObject)data).ToObject <Dictionary <string, object> >(); } else { tempData = (Dictionary <string, Object>)data; } if (((Dictionary <string, Object>)(tempData)).ContainsKey("_type")) { if (obj == null && ((Dictionary <string, Object>)(tempData))["_type"] != null && ((Dictionary <string, Object>)(tempData))["_type"].ToString() == "custom") { obj = new CloudObject(((Dictionary <string, Object>)(tempData))["_tableName"].ToString()); } if (obj == null && ((Dictionary <string, Object>)(tempData))["_type"] != null && ((Dictionary <string, Object>)(tempData))["_type"].ToString() == "user") { obj = new CloudUser(); } if (obj == null && ((Dictionary <string, Object>)(tempData))["_type"] != null && ((Dictionary <string, Object>)(tempData))["_type"].ToString() == "role") { obj = new CloudRole(((Dictionary <string, Object>)(tempData))["name"].ToString()); } if (obj == null && ((Dictionary <string, Object>)(tempData))["_type"] != null && ((Dictionary <string, Object>)(tempData))["_type"].ToString() == "point") { //return geopoint dictionary. CloudGeoPoint point = new CloudGeoPoint(Decimal.Parse(((Dictionary <string, Object>)(tempData))["longitude"].ToString()), Decimal.Parse(((Dictionary <string, Object>)(tempData))["latitude"].ToString())); return(point); } foreach (var param in ((Dictionary <string, Object>)(tempData))) { if (param.Value == null) { obj.dictionary[param.Key] = null; } else if (param.Key == "ACL") { var acl = new CB.ACL(); obj.dictionary[param.Key] = acl; } else if (param.Key == "expires") { obj.dictionary["expires"] = ((Dictionary <string, Object>)(tempData))["expires"]; } else if (param.Value != null && typeof(JObject) == param.Value.GetType() && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >().ContainsKey("_type") && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["_type"].ToString() == "custom") { CB.CloudObject cbObj = new CB.CloudObject(((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["_tableName"].ToString()); cbObj = (CloudObject)Deserialize(((JObject)(param.Value)).ToObject <Dictionary <string, object> >()); obj.dictionary[param.Key] = cbObj; } else if (param.Value != null && typeof(JObject) == param.Value.GetType() && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >().ContainsKey("_type") && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["_type"].ToString() == "user") { CB.CloudUser cbObj = new CB.CloudUser(); cbObj = (CloudUser)Deserialize(((JObject)(param.Value)).ToObject <Dictionary <string, object> >()); obj.dictionary[param.Key] = cbObj; } else if (param.Value != null && typeof(JObject) == param.Value.GetType() && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >().ContainsKey("_type") && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["_type"].ToString() == "custom") { CB.CloudRole cbObj = new CB.CloudRole(((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["name"].ToString()); cbObj = (CloudRole)Deserialize(((JObject)(param.Value)).ToObject <Dictionary <string, object> >()); obj.dictionary[param.Key] = cbObj; } else if (param.Value != null && typeof(JObject) == param.Value.GetType() && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >().ContainsKey("_type") && ((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["_type"].ToString() == "point") { CB.CloudGeoPoint cbObj = new CB.CloudGeoPoint(Decimal.Parse(((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["longitude"].ToString()), Decimal.Parse(((JObject)(param.Value)).ToObject <Dictionary <string, object> >()["latitude"].ToString())); cbObj = (CloudGeoPoint)(Deserialize(((JObject)(param.Value)).ToObject <Dictionary <string, object> >())); obj.dictionary[param.Key] = cbObj; } else if (param.Value.GetType() == typeof(ArrayList)) { obj.dictionary[param.Key] = Deserialize(param.Value); } else if (param.Value.GetType().IsArray) { obj.dictionary[param.Key] = Deserialize(param.Value); } else if (param.Value.GetType() == typeof(JArray)) { obj.dictionary[param.Key] = Deserialize(param.Value); } else { obj.dictionary[param.Key] = param.Value; } } return(obj); } else { return(tempData); } } return(data); }
// ========================================================================================================================= // === MonoBehaviour interface ============================================================================================= void OnDestroy() { ms_Instance = null; }
public void Init() { instance = new CloudUser(); }
public void Logout() { CloudUser.Logout(); }
IEnumerator Login_Coroutine() { GuiPopupMessageBox msgBox = Owner.ShowPopup("MessageBox", TextDatabase.instance[02040016], TextDatabase.instance[02040017]) as GuiPopupMessageBox; // get primary key string primaryKey; { UserGetPrimaryKey action = new UserGetPrimaryKey(m_UserName); GameCloudManager.AddAction(action); while (action.isDone == false) { yield return(new WaitForEndOfFrame()); } primaryKey = action.primaryKey; } #if UNITY_IPHONE || TEST_IOS_VENDOR_ID if (string.IsNullOrEmpty(m_UserName) == false && m_UserName.StartsWith("guest") == true) { string userid = SysUtils.GetUniqueDeviceID(); string vendorID = null; while (string.IsNullOrEmpty(vendorID) == true) { vendorID = MFNativeUtils.IOS.VendorId; yield return(new WaitForEndOfFrame()); } string id = string.IsNullOrEmpty(userid) ? vendorID : userid; string idtype = string.IsNullOrEmpty(userid) ? CloudServices.LINK_ID_TYPE_IOSVENDOR : CloudServices.LINK_ID_TYPE_DEVICE; //Debug.Log(">>>> ID="+id+", IDType="+idtype); GetPrimaryKeyLinkedWithID action = new GetPrimaryKeyLinkedWithID(E_UserAcctKind.Guest, id, idtype); GameCloudManager.AddAction(action); while (action.isDone == false) { yield return(new WaitForEndOfFrame()); } msgBox.ForceClose(); //Debug.Log(">>>> action.isSucceeded="+action.isSucceeded+", action.primaryKey="+action.primaryKey+", primaryKey="+primaryKey); bool force = action.isFailed == true || action.isPrimaryKeyForSHDZ == false || action.primaryKey != primaryKey; bool migrate = false; GuiPopupMigrateGuest migratePopup = (GuiPopupMigrateGuest)Owner.ShowPopup("MigrateGuest", null, null, (inPopup, inResult) => { migrate = inResult == E_PopupResultCode.Ok; }); migratePopup.Usage = force ? GuiPopupMigrateGuest.E_Usage.QuickPlay : GuiPopupMigrateGuest.E_Usage.LoginScreen; migratePopup.PrimaryKey = primaryKey; migratePopup.Password = m_PasswordHash; while (migratePopup.IsVisible == true) { yield return(new WaitForEndOfFrame()); } if (migrate == true) { yield break; } } #endif if (msgBox.IsVisible == true) { msgBox.ForceClose(); } CloudUser cloudUser = CloudUser.instance; cloudUser.SetLoginData(primaryKey, m_UserName, m_UserName, m_PasswordHash, m_PasswordLength, m_RememberMe, m_AutoLogin); CloudUser.instance.AuthenticateLocalUser(); Owner.ShowPopup("Authentication", TextDatabase.instance[02040016], "", AuthenticationResultHandler); // Invoke("AuthenticationDeadLoopFixer", 20); // TODO disable Login screen. }
public void Init() { instance = new CloudUser(); }