/// <summary>
        /// Verify an email address and unlock an account by supplying a key that was emailed to the address.
        /// </summary>
        /// <returns></returns>
        public ActionResult Verify(VerifyAccountModel model)
        {
            if (Request.HttpMethod == "GET" && model.UserName == null && model.Key == null)
            {
                ModelState.Clear();
            }
            else if (ModelState.IsValid)
            {
                using (var ctx = GetRepository())
                {
                    User u = ctx.Users.Single(f => f.Username == model.UserName);

                    if (u.State == UserState.Verification && u.ValidationKey.HasValue)
                    {
                        if (model.Key.Equals(u.ValidationKey.Value.ToString(), StringComparison.OrdinalIgnoreCase))
                        {
                            u.ValidationKey = null;
                            u.State = UserState.Okay;
                            ctx.SaveChanges();
                            Permissions.SetAuthCookie(model.UserName);

                            return RedirectToAction("Index", "Home");
                        }
                        else
                        {
                            ModelState.AddModelError("Key", "Invalid verification key");
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("UserName", "Invalid user or account is not pending verification");
                    }
                }
            }

            return View(model);
        }
 public ActionResult Verified()
 {
     VerifyAccountModel model = new VerifyAccountModel { UserName = Permissions.UserLogin };
     return View(model);
 }