コード例 #1
0
ファイル: POST.ashx.cs プロジェクト: ekah/pinsite
        private void RequestInvite(HttpContext context)
        {
            string email = context.Request.Params["email"];

            EyeShadow.dbml.AppUsers user = this.GetEyeShadowContext2.AppUsers.FirstOrDefault(o => o.Email == email);
            if (user == null)
            {
                user        = new EyeShadow.dbml.AppUsers();
                user.Email  = email;
                user.Name   = Common.RemoveSpecialCharacters(email);
                user.Points = Common.Points;
                SmtpClient  client = new SmtpClient();
                string      hash   = Common.GetString(Common.Hash.ComputeString(Guid.NewGuid().ToString()).GetBytes());
                MailMessage mess   = new MailMessage("*****@*****.**", email);
                mess.Body       = string.Format(File.ReadAllText(context.Server.MapPath("signuptmpl.html")), string.Format("<a href='{0}{1}?s={2}'>Click here to register</a>", Common.Domain, Common.InviteUrl, hash));
                mess.Subject    = "Sign Up for PinPolish";
                mess.IsBodyHtml = true;
                client.Send(mess);
                user.Invite = hash;
                this.GetEyeShadowContext2.AppUsers.InsertOnSubmit(user);
                this.GetEyeShadowContext2.SubmitChanges();
                context.Response.Write("An Invitation has been sent to your email address.Please follow the instructions to complete the registration");
            }
            else
            {
                context.Response.Write("The email address has already been registered with our application");
            }
        }
コード例 #2
0
ファイル: POST.ashx.cs プロジェクト: ekah/pinsite
        private void ChangePassword(HttpContext context)
        {
            string pass = context.Request.Params["pass"];

            if (!string.IsNullOrEmpty(pass))
            {
                EyeShadow.dbml.AppUsers u = this.GetEyeShadowContext2.AppUsers.First(o => o.ID == Common.UserID);
                IHash      hash           = Common.Hash;
                HashResult res            = hash.ComputeString(pass);
                u.Password = Common.GetString(res.GetBytes());
                this.GetEyeShadowContext2.SubmitChanges();
                context.Response.Write("Password has been updated");
            }
        }
コード例 #3
0
ファイル: GET.ashx.cs プロジェクト: ekah/pinsite
        private void Invite(HttpContext context)
        {
            string invite = context.Request.QueryString["s"];

            if (!string.IsNullOrEmpty(invite))
            {
                EyeShadow.dbml.AppUsers au = GetEyeShadowContext2.AppUsers.FirstOrDefault(o1 => o1.Invite == invite);
                if (au != null)
                {
                    CookieUtil.WriteCookie(Common.AuthCookie, EncDec.Encrypt(JsonConvert.SerializeObject(new { ID = au.ID }), Common.DefaultPassword), false);
                    CookieUtil.WriteCookie(Common.InfoCookie, JsonConvert.SerializeObject(new { email = au.Email, name = au.Name, avatar = string.IsNullOrWhiteSpace(au.Avatar) ? null : Common.UploadedImageRelPath + au.Avatar }), false);
                    context.Response.Redirect("~/home#settings", false);
                }
            }
        }
コード例 #4
0
ファイル: POST.ashx.cs プロジェクト: ekah/pinsite
 private void SaveProfile(HttpContext context)
 {
     EyeShadow.dbml.AppUsers u = this.GetEyeShadowContext2.AppUsers.First(o => o.ID == Common.UserID);
     if (string.IsNullOrEmpty(u.Password))
     {
         context.Response.WriteError("Password not updated");
     }
     else
     {
         string email      = context.Request.Params["email"];
         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"];
         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.Email     = email;
         u.FirstName = first_name;
         u.Website   = website;
         u.Location  = location;
         u.About     = about;
         u.Name      = name;
         GetEyeShadowContext2.SubmitChanges();
         CookieUtil.WriteCookie(Common.AuthCookie, EncDec.Encrypt(JsonConvert.SerializeObject(new { ID = u.ID }), Common.DefaultPassword), false);
         CookieUtil.WriteCookie(Common.InfoCookie, JsonConvert.SerializeObject(new { email = u.Email, name = u.Name, avatar = string.IsNullOrWhiteSpace(u.Avatar) ? null : Common.UploadedImageRelPath + u.Avatar }), false);
     }
 }
コード例 #5
0
ファイル: POST.ashx.cs プロジェクト: ekah/pinsite
        private void ValidateContributor(HttpContext context)
        {
            string contributor = context.Request.Params["contributor"];

            EyeShadow.dbml.AppUsers user = this.GetEyeShadowContext2.AppUsers.FirstOrDefault(o => o.Email == contributor || o.Name == contributor);
            if (user != null)
            {
                context.Response.Write(JsonConvert.SerializeObject(new
                {
                    user.Email,
                    user.Avatar,
                    user.FirstName,
                    user.Name
                }));
            }
            else
            {
                context.Response.WriteError("User does not exist");
            }
        }
コード例 #6
0
ファイル: POST.ashx.cs プロジェクト: ekah/pinsite
        private void ResetPass(HttpContext context)
        {
            string email = context.Request.Params["email"];

            EyeShadow.dbml.AppUsers user = this.GetEyeShadowContext2.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 PinPolish account";
                mess.IsBodyHtml = true;
                client.Send(mess);
                user.Password = Common.GetHash(pass);
                GetEyeShadowContext2.SubmitChanges();
                context.Response.Write("The new password has been sent to your email address");
            }
            else
            {
                context.Response.Write("The email address is not registered with our application");
            }
        }
コード例 #7
0
ファイル: POST.ashx.cs プロジェクト: hurricanechaser/pindex
 private void RequestInvite(HttpContext context)
 {
     string email = context.Request.Params["email"];
     EyeShadow.dbml.AppUsers user = this.GetEyeShadowContext2.AppUsers.FirstOrDefault(o => o.Email == email);
     if (user == null)
     {
         user = new EyeShadow.dbml.AppUsers();
         user.Email = email;
         user.Name = Common.RemoveSpecialCharacters(email);
         user.Points = Common.Points;
         SmtpClient client = new SmtpClient();
         string hash = Common.GetString(Common.Hash.ComputeString(Guid.NewGuid().ToString()).GetBytes());
         MailMessage mess = new MailMessage("*****@*****.**", email);
         mess.Body = string.Format(File.ReadAllText(context.Server.MapPath("signuptmpl.html")), string.Format("<a href='{0}{1}?s={2}'>Click here to register</a>", Common.Domain, Common.InviteUrl, hash));
         mess.Subject = "Sign Up for PinPolish";
         mess.IsBodyHtml = true;
         client.Send(mess);
         user.Invite = hash;
         this.GetEyeShadowContext2.AppUsers.InsertOnSubmit(user);
         this.GetEyeShadowContext2.SubmitChanges();
         context.Response.Write("An Invitation has been sent to your email address.Please follow the instructions to complete the registration");
     }
     else
         context.Response.Write("The email address has already been registered with our application");
 }