Exemplo n.º 1
0
 public ActionResult Login(Project.Models.UserModel user)
 {
     if (ModelState.IsValid)
     {
         if (IsValid(user.Email, user.Password))
         {
             FormsAuthentication.SetAuthCookie(user.Email, false);
             return(RedirectToAction("Index", "Home"));
         }
         else
         {
             ModelState.AddModelError("", "Login is incorrect");
         }
     }
     return(View());
 }
Exemplo n.º 2
0
        public ActionResult Register(Project.Models.UserModel user)
        {
            if (ModelState.IsValid)
            {
                using (var db = new MainDbEntities()) {
                    var crypto = new SimpleCrypto.PBKDF2();

                    var encryptedPass = crypto.Compute(user.Password);
                    var sysuser       = db.SystemUsers.Create();
                    sysuser.email    = user.Email;
                    sysuser.username = user.Username;
                    sysuser.password = encryptedPass;
                    sysuser.password = crypto.Salt;
                    sysuser.Id       = Guid.NewGuid();
                    db.SystemUsers.Add(sysuser);
                    db.SaveChanges
                }
            }
            return(View());
        }