Example #1
0
        public ActionResult LogOn(LogOnModel model)
        {
            if(!ModelState.IsValid)
            {
                ViewData["Error-login"] = "******";
                return View();
            }

            var user = UserService.FindByEmail(model.Email);

            var isNotValid = user == null || !user.IsActive || !PasswordHelper.ValidatePassword(model.Password, user.Password);
            if (isNotValid)
            {
                ViewData["Error-login"] = "******";
                return View();
            }

            AppService.SetCurrentOrganizationId(user.Organization.Id);

            var authCookie = AuthenticationService.CreateAuthCookie(user.Id.ToString(), user.Role.ToString());
            Response.Cookies.Add(authCookie);

            return RedirectToAction("index", "dashboard");
        }
Example #2
0
        public ActionResult LogOn(LogOnModel model)
        {
            if (!ModelState.IsValid)
            {
                ViewData["Error"] = "Invalid email/password. Please try again.";
            }

            var customer = CustomerService.FindByEmail(model.Email);

            var isNotValid = customer == null || !PasswordHelper.ValidatePassword(model.Password, customer.Password);
            if (isNotValid)
            {
                ViewData["Error"] = "Invalid email/password. Please try again.";
                return View();
            }

            var authCookie = AuthenticationService.CreateAuthCookie(customer.Id.ToString(), customer.Role.ToString());
            Response.Cookies.Add(authCookie);

            return RedirectToAction("index", "reservation");
        }