protected void Change(object sender, EventArgs e) { Usr u = new Usr(int.Parse(UsrK.Text)); if (!u.IsAdmin) { u.SetPassword(UsrPassword.Text, true); OutLabel.Text = "Done."; } else OutLabel.Text = "Can't change an admin password on this page."; }
//public static bool GetCompliantUniqueNickName(string inNickName, out string outNickName) //{ // outNickName = inNickName; // int index; // // if it's an email address, remove domain // if (index = outNickName.IndexOf("@") > 0) // { // outNickName = outNickName.Substring(0, outNickName.IndexOf(index)); // } // outNickName = Usr.GetCompliantNickName(outNickName); // if (!Usr.NickNameRegex.IsMatch(outNickName)) // return false; // else // { // Query q = new Query(); // q.QueryCondition = new Q(Usr.Columns.NickName, outNickName); // q.ReturnCountOnly = true; // UsrSet us = new UsrSet(q); // us.Count == 0; // } //} #endregion #region CreateNewUsr //public static Usr CreateNewUsr(string email, string password) //{ // return CreateNewUsr(email, password, "", ""); //} //public static Usr CreateNewUsr(string email, string password, string firstName, string lastName) //{ // return CreateNewUsr(email, password, firstName, lastName, ""); //} //public static Usr CreateNewUsr(string email, string password, string firstName, string lastName, string emailIp) //{ // return CreateNewUsr(email, password, firstName, lastName, emailIp, true); //} public static Usr CreateNewUsrMaster(string email, string password, string firstName, string lastName, string emailIp, bool runUpdate) { Usr u = new Usr(); Random r = new Random(); #region Add data from form u.DateTimeSignUp = Time.Now; u.DateTimeLastAccess = Time.Now; u.DateTimeLastPageRequest = Time.Now; u.Email = email.Trim(); u.EmailDateTime = Time.Now; u.EmailIp = emailIp; if (password.Trim().Length > 0) u.SetPassword(password.Trim(), false); u.LoginString = Cambro.Misc.Utility.GenRandomText(6, r); u.RandomNumber = r.NextDouble(); u.IsEmailVerified = false; u.IsAdmin = false; u.LoginCount = 0; u.FirstName = firstName; u.LastName = lastName; u.NickName = ""; u.IsSkeleton = true; u.SendSpottedEmails = true; u.UpdateLargeEvents = 5000; u.UpdateSendBuddies = false; u.UpdateSendGenericMusic = true; u.SendSpottedTexts = true; u.SendFlyers = true; u.SendInvites = true; u.SendPartnerEmails = false; u.SendPartnerTexts = false; #endregion if (runUpdate) u.Update(); return u; }
public static Hashtable NoFacebookLogin( string nickNameOrEmail, string password, Hashtable captchaData, Hashtable noFacebookSignupPanelData, Hashtable detailsPanelData, bool autoLogin, int autoLoginUsrK, string autoLoginString) { Hashtable ret = new Hashtable(); Usr u = null; if (!autoLogin) { if (nickNameOrEmail.Trim().Length == 0) { ret["Error"] = true; return ret; } Q q = null; if (nickNameOrEmail.Contains("@")) q = new Q(Usr.Columns.Email, nickNameOrEmail.Trim()); else q = new Q(Usr.Columns.NickName, nickNameOrEmail.Trim()); UsrSet us = new UsrSet(new Query(q)); if (us.Count == 0) { ret["Error"] = true; return ret; } u = us[0]; if (u.HasNullPassword) { u.SendPasswordResetLink(); ret["Error"] = true; ret["HasNullPassword"] = true; return ret; } if (!u.CheckPassword(password.Trim())) { ret["Error"] = true; return ret; } } else { if (autoLoginUsrK == 0 || autoLoginString.Length == 0) { ret["Error"] = true; return ret; } try { u = new Usr(autoLoginUsrK); } catch { ret["Error"] = true; return ret; } if (u.LoginString.ToLower() != autoLoginString.ToLower()) { ret["Error"] = true; return ret; } if (u.IsSkeleton) { string passwordFromAutoLoginSkeletonData = noFacebookSignupPanelData["Password"].ToString(); if (passwordFromAutoLoginSkeletonData.Length > 0) { if (passwordFromAutoLoginSkeletonData.Length < 4) throw new Exception("Password too short"); u.SetPassword(passwordFromAutoLoginSkeletonData, false); } } } bool passedCaptcha = false; if (!captchaIsOk(u, u.Email, ret, captchaData, ref passedCaptcha)) return ret; if (passedCaptcha) { u.NeedsCaptcha = false; u.PassedCaptcha = true; } noFacebookLogin(u, ret, noFacebookSignupPanelData, detailsPanelData); return ret; }