Exemple #1
0
        private void RequestInvite(HttpContext context)
        {
            string email = context.Request.Params["email"];

            PindexProd.dbml.AppUsers user = this.GetPindexProdContext2.AppUsers.FirstOrDefault(o => o.Email == email);
            if (user == null)
            {
                user        = new PindexProd.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 FreshPin";
                mess.IsBodyHtml = true;
                client.Send(mess);
                user.Invite = hash;
                this.GetPindexProdContext2.AppUsers.InsertOnSubmit(user);
                this.GetPindexProdContext2.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");
            }
        }
Exemple #2
0
        private void ChangePassword(HttpContext context)
        {
            string pass = context.Request.Params["pass"];

            if (!string.IsNullOrEmpty(pass))
            {
                PindexProd.dbml.AppUsers u = this.GetPindexProdContext2.AppUsers.First(o => o.ID == Common.UserID);
                IHash      hash            = Common.Hash;
                HashResult res             = hash.ComputeString(pass);
                u.Password = Common.GetString(res.GetBytes());
                this.GetPindexProdContext2.SubmitChanges();
                context.Response.Write("Password has been updated");
            }
        }
Exemple #3
0
        private void Invite(HttpContext context)
        {
            string invite = context.Request.QueryString["s"];

            if (!string.IsNullOrEmpty(invite))
            {
                PindexProd.dbml.AppUsers au = GetPindexProdContext2.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);
                }
            }
        }
Exemple #4
0
 private void SaveProfile(HttpContext context)
 {
     PindexProd.dbml.AppUsers u = this.GetPindexProdContext2.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;
         GetPindexProdContext2.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);
     }
 }
Exemple #5
0
        private void ValidateContributor(HttpContext context)
        {
            string contributor = context.Request.Params["contributor"];

            PindexProd.dbml.AppUsers user = this.GetPindexProdContext2.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");
            }
        }
Exemple #6
0
        private void ResetPass(HttpContext context)
        {
            string email = context.Request.Params["email"];

            PindexProd.dbml.AppUsers user = this.GetPindexProdContext2.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 Freshpin account";
                mess.IsBodyHtml = true;
                client.Send(mess);
                user.Password = Common.GetHash(pass);
                GetPindexProdContext2.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");
            }
        }
Exemple #7
0
 private void RequestInvite(HttpContext context)
 {
     string email = context.Request.Params["email"];
     PindexProd.dbml.AppUsers user = this.GetPindexProdContext2.AppUsers.FirstOrDefault(o => o.Email == email);
     if (user == null)
     {
         user = new PindexProd.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 FreshPin";
         mess.IsBodyHtml = true;
         client.Send(mess);
         user.Invite = hash;
         this.GetPindexProdContext2.AppUsers.InsertOnSubmit(user);
         this.GetPindexProdContext2.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");
 }