Пример #1
0
        public ActionResult Register([Bind(Exclude = "isEmailVerified, Activation")] User user)
        {
            if (ModelState.IsValid)
            {
                if (IsEmailExist(user.Email))
                {
                    ModelState.AddModelError("Email", "* alamat email sudah terdaftar");
                    return(View(user));
                }

                // fill user data
                user.Activation      = Guid.NewGuid();
                user.Password        = Security.GetHashedSensitive(user.Password);
                user.ConfirmPassword = user.Password;
                user.Role            = "normal";
                user.Verified        = false;

                // save user to db
                var db = new AyobeliDBEntities();
                db.Users.Add(user);
                // db.Configuration.ValidateOnSaveEnabled = false
                db.SaveChanges();
                SendVerificationEmailLink(user.Email, user.Activation.ToString());

                ViewBag.CoreMessage          = StringResource.RegisterSuccessTopMessage;
                ViewBag.SupplementaryMessage = StringResource.RegisterSuccessExplanation;
                return(View("Success"));
            }

            return(View(user));
        }
Пример #2
0
        public ActionResult VerifyAccount(string id)
        {
            bool isValidRequest = false;

            using (AyobeliDBEntities db = new AyobeliDBEntities())
            {
                var user = db.Users.Where(u => u.Activation == new Guid(id)).FirstOrDefault();
                if (user != null)
                {
                    user.Verified   = true;
                    user.Activation = null;
                    isValidRequest  = true;
                    db.SaveChanges();
                }
            }

            return(View());
        }