Exemple #1
0
        public ActionResult Registration(UserValidation user)
        {
            Session.Clear();
            string conf  = MainHelper.Random32();
            int    count = db.Users.Count() + 1;

            db.Users.Add(new User()
            {
                Name         = user.Name,
                Surname      = user.Surname,
                Email        = user.Email,
                Password     = MainHelper.CalculateMD5Hash(user.Password + AuthSecret),
                Confirmation = conf,
                RegNumber    = user.Name + count,
                Search       = user.Name + " " + user.Surname,
                CreateDate   = DateTime.Now
            });
            db.SaveChanges();
            db.ProfilePhotoes.Add(new ProfilePhoto()
            {
                UserID = db.Users.Max(x => x.Id),
                Photo  = "noImage.png"
            });
            db.SaveChanges();
            TempData["Success"] = "წარმატებით გაიარეთ რეგისტრაცია, გთხოვთ გააქტიუროთ ელ.ფოსტა";
            string Url         = "http://*****:*****@gmail.com", "Activation");
            var    reciveEmail = new MailAddress(user.Email, "Reciver");


            var password = "******";
            var sub      = "Actiovation";


            var smtp = new SmtpClient
            {
                Host                  = "smtp.gmail.com",
                Port                  = 587,
                EnableSsl             = true,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,

                Credentials = new NetworkCredential(senderEmail.Address, password),
            };

            using (var mess = new MailMessage(senderEmail, reciveEmail)
            {
                Subject = sub,
                Body = body,
                IsBodyHtml = true,
            })
            {
                smtp.Send(mess);
            }

            return(RedirectToAction("Login"));
        }
Exemple #2
0
        public ActionResult Login(UserValidation user)
        {
            var useractive = db.Users.Where(x => x.Email == user.Email).FirstOrDefault();

            if (useractive.IsActive == false)
            {
                TempData["Error"] = "გააქტიურე ელ.ფოსტა";
                return(RedirectToAction("Login"));
            }
            string pass = MainHelper.CalculateMD5Hash(user.Password + AuthSecret);
            User   Us   = db.Users.Where(x => x.Email == user.Email && x.Password == pass).FirstOrDefault();

            if (Us == null)
            {
                TempData["Error"] = "ასეთი მომხამარებელი არ არსებობს";
                return(RedirectToAction("Login"));
            }
            Session["user"] = Us;

            return(RedirectToAction("Index", "Home"));
        }