Ejemplo n.º 1
0
        public ActionResult Create(User user)
        {
            if (ModelState.IsValid)
            {
                user.password = GetMd5Hash(md5Hash,user.password);
                user.foto = "";
                user.role = "member";
                user.active = false;
                db.Users.Add(user);
                db.SaveChanges();
                MailMessage mail = new MailMessage();
                SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com",587);
                SmtpServer.Credentials = new System.Net.NetworkCredential("aluno33731", "ISEL MVC");
                SmtpServer.EnableSsl = true;

                mail.From = new MailAddress("*****@*****.**");
                mail.To.Add(user.email);
                mail.Subject = "Regist Confirm";
                mail.Body = "To confirm regist follow the link: http://localhost:13365/Users/Activate?user="******"Confirm");
            }

            return View(user);
        }
Ejemplo n.º 2
0
        public ActionResult Logon(User user)
        {
            User targetUser = db.Users.Find(user.username);
            if (targetUser!=null && VerifyMd5Hash(md5Hash, user.password, targetUser.password) && targetUser.active)
            {
                FormsAuthentication.SetAuthCookie(targetUser.username, false);
                string url = TempData["url"] as string;
                if (url != null)
                    FormsAuthentication.RedirectFromLoginPage(targetUser.username, false);
                else
                    return RedirectToRoute("Default","Boards");
            }

            return View(user);
        }
Ejemplo n.º 3
0
 public ActionResult Edit(User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(user);
 }