// GET: VerifyAccount
        public ActionResult Index(String email)
        {
            var base64EncodedBytes = Convert.FromBase64String(email);
            string e = System.Text.Encoding.UTF8.GetString(base64EncodedBytes);

            ViewBag.Email = e;
            try
            {
                //https://joaoeduardosousa.wordpress.com/2014/04/23/asp-net-mvc-5-connect-with-azure-sqlserver-database/
                homesecurity_dbEntities context = new homesecurity_dbEntities();
                Account acc = context.Accounts.Where(a => a.Email == e).SingleOrDefault(); //find account with this email

                if (acc != null) //set the verified variable to true
                {
                    acc.Verified = true;
                    context.Entry(acc).CurrentValues.SetValues(acc);
                    context.SaveChanges();
                }
                else
                    return RedirectToAction("Error", "VerifyAccount", new { Email = e});

            }
            catch (Exception ex)
            {
                //Response.Write("<script>alert('ERROR " + e.StackTrace + ", " + e.Message + "')</script>"); this is a handy way of debugging
                return RedirectToAction("Error", "VerifyAccount", new { Email = e });
            }
            return View();
        }
        public ActionResult Login(LoginViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }
            homesecurity_dbEntities context = new homesecurity_dbEntities();
            Account acc = context.Accounts.Where(a => a.Email == model.Email).SingleOrDefault();

            if (acc != null)
            {
                byte[] incoming = CustomLoginProviderUtils
                    .hash(model.Password, acc.Salt);

                if (CustomLoginProviderUtils.slowEquals(incoming, acc.SaltedAndHashedPassword)) //passwords match
                {
                    if (acc.Verified)
                    {
                        FormsAuthentication.SetAuthCookie(model.Email, false);
                        return RedirectToAction("Index", "Security");
                    }
                    else
                        ModelState.AddModelError("", "Please validate your email");
                }
                else
                    ModelState.AddModelError("", "Invalid email and password combination");
            }
            //account is null which means the email doesnt exist
            else
                ModelState.AddModelError("", "Invalid email and password combination");

            return View(model);

        }