private void ValidateContributor(HttpContext context) { string contributor = context.Request.Params["contributor"]; Data.dbml.AppUsers user = this.GetDataContext2.AppUsers.FirstOrDefault(o => o.Email == contributor || o.Name == contributor); if (user != null) { if (user.ID == Common.UserID) { context.Response.WriteError(strings.Contributor_Warn); } else { context.WriteJsonP(JsonConvert.SerializeObject(new { user.Email, user.Avatar, Name = string.IsNullOrEmpty(user.FirstName) ? user.Name : user.FirstName, UN = user.Name })); } } else { context.Response.WriteError(strings.User_Not_Exist); } }
private void RequestInvite(HttpContext context) { string email = context.Request.Params["email"]; Data.dbml.AppUsers user = GetDataContext2.AppUsers.FirstOrDefault(o => o.Email == email); if (GetDataContext2.AppUsers.Any(o => o.Email == email)) { context.Response.WriteError(strings.Email_Registered); } else { context.Server.Execute(string.Format("signup.aspx?email={0}", email)); } }
private void ChangePassword(HttpContext context) { string pass = context.Request.Params["pass"]; if (!string.IsNullOrEmpty(pass)) { Data.dbml.AppUsers u = this.GetDataContext2.AppUsers.First(o => o.ID == Common.UserID); IHash hash = Common.Hash; HashResult res = hash.ComputeString(pass); u.Password = Common.GetString(res.GetBytes()); GetDataContext2.SubmitChanges(); context.Response.Write(strings.Pass_Updated); } }
private void AddProfile(HttpContext context) { Data.dbml.AppUsers u = new Data.dbml.AppUsers(); string first_name = context.Request.Params["first_name"]; string about = context.Request.Params["about"]; string location = context.Request.Params["location"]; string fn = context.Request.Params["fn"]; string website = context.Request.Params["website"]; string name = context.Request.Params["name"]; string pass = context.Request.Params["pass"]; string email = context.Request.Params["email"]; string speciality = context.Request.Params["speciality"]; if (!string.IsNullOrEmpty(fn)) { Uri uri = new Uri(fn); string filename = uri.Segments.Last(); string fp = Path.Combine(Common.Temp, filename); string uploadedpath = Common.UploadedImagePath; FileInfo fInfo = new FileInfo(fp); string nfn = fInfo.Name; if (fInfo.DirectoryName != uploadedpath) { string dest = Path.Combine(uploadedpath, nfn); fInfo.MoveTo(dest); } u.Avatar = nfn; } u.Email = email; u.Location = location; u.Create_date = DateTime.Now; u.FirstName = first_name; u.Website = website; u.Location = location; u.About = about; u.Name = name; u.Speciality = speciality; u.Password = Common.GetHash(pass); GetDataContext2.AppUsers.InsertOnSubmit(u); GetDataContext2.SubmitChanges(); Common.WriteValue(Common.AuthCookie, u.ID.ToString()); Common.WriteValue(Common.InfoCookie, JObject.FromObject(new { email = u.Email, name = string.IsNullOrEmpty(u.FirstName) ? u.Name : u.FirstName, avatar = string.IsNullOrWhiteSpace(u.Avatar) ? null : Common.UploadedImageRelPath + u.Avatar })); }
private void SaveProfile(HttpContext context) { Data.dbml.AppUsers u = this.GetDataContext2.AppUsers.First(o => o.ID == Common.UserID); if (string.IsNullOrEmpty(u.Password)) { context.Response.WriteError(strings.Pass_Created); } else { string first_name = context.Request.Params["first_name"]; string about = context.Request.Params["about"]; string location = context.Request.Params["location"]; string fn = context.Request.Params["fn"]; string website = context.Request.Params["website"]; string name = context.Request.Params["name"]; string speciality = context.Request.Params["speciality"]; if (!string.IsNullOrEmpty(fn)) { Uri uri = new Uri(fn); string filename = uri.Segments.Last(); string fp = Path.Combine(Common.Temp, Common.UserID.ToString(), filename); string uploadedpath = Common.UploadedImagePath; FileInfo fInfo = new FileInfo(fp); string nfn = fInfo.Name; if (fInfo.DirectoryName != uploadedpath) { string dest = Path.Combine(uploadedpath, nfn); fInfo.MoveTo(dest); } u.Avatar = nfn; } u.Location = location; u.FirstName = first_name; u.Website = website; u.Location = location; u.About = about; u.Name = name; u.Speciality = speciality; GetDataContext2.SubmitChanges(); Common.WriteValue(Common.InfoCookie, JObject.FromObject(new { email = u.Email, speciality, name = string.IsNullOrEmpty(u.FirstName) ? u.Name : u.FirstName, avatar = string.IsNullOrWhiteSpace(u.Avatar) ? null : Common.UploadedImageRelPath + u.Avatar })); } }
private void AddComment(HttpContext context) { string comments = context.Request.Params["comments"]; int id = int.Parse(context.Request.Params["id"]); Data.dbml.Comments c = new Data.dbml.Comments(); c.Comment = comments; c.BoardsImagesMappingID = id; c.UserID = Common.UserID.Value; Data.dbml.AppUsers user = this.GetDataContext2.AppUsers.Single(o => o.ID == Common.UserID); this.GetDataContext2.Comments.InsertOnSubmit(c); this.GetDataContext2.SubmitChanges(); context.WriteJsonP(JsonConvert.SerializeObject(new { Comment = comments, Name = user.FirstName, Avatar = user.Avatar, UN = user.Name })); }
protected void Page_Load(object sender, EventArgs e) { Data.dbml.AppUsers o = GetDataContext2.AppUsers.Single(o1 => o1.ID == Common.UserID); aboutu.Value = o.About; email.Value = o.Email; first_name.Value = o.FirstName; username1.Value = o.Name; location.Value = o.Location; website.Value = o.Website; uploadedUserImage.Alt = strings.Image_1; if (!string.IsNullOrWhiteSpace(o.Avatar)) { uploadedUserImage.Src = Common.UploadedImageRelPath + o.Avatar + "?width=170"; } uploadedUserImage.Style.Add("display", "block"); usernameview.InnerHtml = Common.Domain + o.Name; Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1)); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetNoStore(); Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches); }
private void ResetPass(HttpContext context) { string email = context.Request.Params["email"]; Data.dbml.AppUsers user = this.GetDataContext2.AppUsers.FirstOrDefault(o => o.Email == email); if (user != null) { SmtpClient client = new SmtpClient(); MailMessage mess = new MailMessage("*****@*****.**", email); string pass = Common.RandomString(Common.PassMinChars); mess.Body = string.Format(File.ReadAllText(context.Server.MapPath("resetpasstmpl.html")), user.Name, user.Email, pass); mess.Subject = "Password reset for your Pinjimu account"; mess.IsBodyHtml = true; client.Send(mess); user.Password = Common.GetHash(pass); GetDataContext2.SubmitChanges(); context.Response.Write(strings.Pass_Reset); } else { context.Response.Write(strings.Email_Not_Reg); } }