public override void BeforeSave() { base.BeforeSave(); this.Name = this.Name.Capitalize(); this.Surname = this.Surname.Capitalize(); if (this.Nick != null && !Regex.IsMatch(this.Nick, "^[a-zA-Z0-9_]+$")) { throw new Exception(Provider.TR("Kullanıcı adı sadece harf ve rakamlardan oluşabilir")); } if (Id == 0) { //this.Password = Provider.MD5(this.Password); // password işi SetFieldsByPostData'da hallediliyor this.Visible = false; this.Keyword = CMSUtility.MD5((this.Nick ?? "") + DateTime.Now.Ticks.ToString()); if (string.IsNullOrWhiteSpace(this.Country) && Provider.Request.UserLanguages != null && Provider.Request.UserLanguages.Length > 0) { this.Country = Provider.Request.UserLanguages[0]; } } else { //this.Visible = true; // böyle saçma şey olur mu lan? kim yazmış bunu! if (string.IsNullOrWhiteSpace(this.Password)) { this.Password = Provider.Database.GetString("select Password from User where Id={0}", this.Id); } } downloadPictureForFieldsThatStartsWithHttp(); }
public override List <string> Validate() { List <string> errorList = base.Validate(); object password2 = this["Password2"]; if (password2 == null || !CMSUtility.MD5(password2.ToString()).Equals(this.Password)) { errorList.Add("Şifreler boş bırakılmamalı ve aynı olmalıdır."); } return(errorList); }
public override void SetFieldsByPostData(NameValueCollection postData) { string oldPasswordHash = this.Id > 0 ? Provider.Database.GetString("select [Password] from [User] where Id={0}", this.Id) : this.Password; // eski şifre base.SetFieldsByPostData(postData); // formdan gelen verileri kaydedelim if (String.IsNullOrWhiteSpace(this.Password)) // eğer formdan gelen şifre boşsa eski şifreyi koruyalım { this.Password = oldPasswordHash; } else { this.Password = CMSUtility.MD5(this.Password); } this["Password2"] = postData["Password2"]; HttpPostedFile postedFile = Provider.Request.Files["Avatar"]; if (postedFile != null && postedFile.ContentLength > 0) { string avatarDir = Provider.AppSettings["avatarDir"]; if (String.IsNullOrEmpty(avatarDir)) { throw new Exception(Provider.GetResource("Avatar folder is not specified in config file.")); } if (!avatarDir.EndsWith("/")) { avatarDir += "/"; } string avatarUrlPath = avatarDir + this.Nick.MakeFileName() + DateTime.Now.Millisecond + Path.GetExtension(postedFile.FileName); Image bmp = Image.FromStream(Provider.Request.Files["Avatar"].InputStream); if (bmp.Width > 240) { Image bmp2 = bmp.ScaleImage(240, 0); avatarUrlPath = avatarUrlPath.Substring(0, avatarUrlPath.LastIndexOf('.')) + ".jpg"; bmp2.SaveJpeg(Provider.MapPath(avatarUrlPath), Provider.Configuration.ThumbQuality); } else { Provider.Request.Files["Avatar"].SaveAs(Provider.MapPath(avatarUrlPath)); } this.Avatar = avatarUrlPath; Provider.DeleteThumbFiles(avatarUrlPath); } }
public string SendPassword(string email) { Provider.Database.ExecuteNonQuery("update User set Keyword={0} where Email={1}", CMSUtility.MD5(DateTime.Now.Ticks.ToString()), email); User user = (User)Provider.Database.Read(typeof(User), "Email={0}", email); if (user == null) { return(Provider.GetModuleResource("There isn't any user with the email address you entered. Please check.")); } string msg = String.Format(@" {0} <br/> <a href=""http://{1}/LoginWithKeyword.ashx?keyword={2}&rempass=1"">http://{1}/LoginWithKeyword.ashx?keyword={2}&rempass=1</a>", Provider.GetModuleResource("Please change your password by using the address below"), Provider.Configuration.SiteAddress, user.Keyword); string res = Provider.SendMail(email, Provider.GetModuleResource("Your Password"), msg); if (res == "") { return(Provider.GetModuleResource("A message sent to your email address. Please read it.")); } else { return(res); } }