Example #1
0
        public ActionResult LoginPost(string redirectUrl, Login model)
        {
            ViewBag.redirectUrl = redirectUrl;
            if (ModelState.IsValid)
            {
                UserMembershipProvider mp = new UserMembershipProvider();
                if (mp.ValidateUser(model.Email, model.Password))
                {
                    System.Web.HttpContext.Current.Session["Email"] = model.Email;

                    var users = Adapter.UserRepository.Find(a => a.Email == model.Email, null);
                    if (users != null && users.Any())
                    {
                        User user = users.First();
                        if (user.ApprovedDate == null)
                        {
                            ModelState.AddModelError("", "Je hebt je profiel nog niet geactiveerd met de activatielink in de e-mail.");
                            return View(model);
                        }
                        if (user.LockedDate != null)
                        {
                            ModelState.AddModelError("", "Een administrator heeft je profiel gelockt. Gelieve contact op te nemen met onze support.");
                            return View(model);
                        }

                        user.CreatedDate = DateTime.UtcNow;
                        Adapter.UserRepository.Update(user);
                        Adapter.Save();

                        HttpCookie cookie = new HttpCookie("RadarEmail", model.Email);
                        this.ControllerContext.HttpContext.Response.Cookies.Add(cookie);
                        HttpCookie cookieP = new HttpCookie("RadarPassword", user.Password);
                        this.ControllerContext.HttpContext.Response.Cookies.Add(cookieP);

                        if (!String.IsNullOrEmpty(redirectUrl))
                        {
                            byte[] b = Convert.FromBase64String(redirectUrl);
                            string url = System.Text.Encoding.UTF8.GetString(b);
                            return Redirect(url + "?&message=login");
                        }
                        else
                            return Redirect("http://localhost:4911/Radar/app/#/?message=login");
                    }

                }
                else
                    ModelState.AddModelError("", "Het emailadres of het paswoord is niet geldig.");
            }
            return View(model);
        }
Example #2
0
 public ActionResult Login(string redirectUrl = "")
 {
     Login model = new Login();
     ViewBag.redirectUrl = redirectUrl;
     return View(model);
 }