Example #1
0
        public ActionResult Login(AccountLoginInputModel input, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                var result = this.accountAdapter.LoginUser(input.UserName, input.Password);
                if (result.StatusCode == 200)
                {
                    // set auth cookie
                    CustomAuthentication.SetAuthCookie(result.Result.Username, result.Result.UserId, input.RememberMe);

                    // allow cross-browser auth cookie (IE8)
                    Response.AddHeader("p3p",
                                       "CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"");

                    // redirect the user
                    if (String.IsNullOrEmpty(returnUrl))
                    {
                        return(Redirect("/"));
                    }
                    else
                    {
                        return(Redirect(returnUrl));
                    }
                }

                // process failure
                var error = result.Errors.First();
                ModelState.AddModelError(error.MemberNames.First(), error.ErrorMessage);
            }
            return(View(new AccountLoginModel()
            {
                Input = input
            }));
        }
Example #2
0
        public ActionResult Checkout(int id, Guid?token)
        {
            if (!User.Identity.IsAuthenticated && token.HasValue)
            {
                var user = authAdapter.ValidateAuthToken(token.Value);

                if (user.StatusCode == 200)
                {
                    CustomAuthentication.SetAuthCookie(user.Result.Username, user.Result.UserId, true);
                    return(RedirectToAction("checkout"));
                }
            }

            var status = this.orderAdapter.GetOrderForCheckout(User.Identity.Name, id);

            if (status.StatusCode != 200)
            {
                return(this.NotFoundException());
            }

            Rentler.Web.Models.OrderCheckoutModel model = new Rentler.Web.Models.OrderCheckoutModel()
            {
                Order = status.Result,
                Input = new Rentler.Web.Models.OrderCheckoutInputModel()
            };

            // auto-select the first payment method
            if (status.Result.User.UserCreditCards.Count > 0)
            {
                model.Input.SelectedPaymentMethod = status.Result.User.UserCreditCards.First();
            }

            return(View(model));
        }
        public ActionResult Edit(long id, Guid?token)
        {
            if (!User.Identity.IsAuthenticated && token.HasValue)
            {
                var user = authAdapter.ValidateAuthToken(token.Value);

                if (user.StatusCode == 200)
                {
                    CustomAuthentication.SetAuthCookie(user.Result.Username, user.Result.UserId, true);
                    return(RedirectToAction("edit"));
                }
            }

            var request = this.propertyAdapter.GetProperty(id, User.Identity.Name);

            if (request.StatusCode != 200)
            {
                return(this.NotFoundException());
            }

            PropertyEditModel model = new PropertyEditModel(
                new PropertyEditInputModel(request.Result)
                );

            return(View(model));
        }
Example #4
0
        public ActionResult Register(AccountRegisterInputModel input, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                var result = this.accountAdapter.RegisterUser(new User()
                {
                    Username  = input.UserName,
                    Email     = input.Email,
                    FirstName = input.FirstName,
                    LastName  = input.LastName
                }, input.Password);

                if (result.StatusCode == 200)
                {
                    CustomAuthentication.SetAuthCookie(result.Result.Username, result.Result.UserId, false);

                    // redirect the user
                    if (String.IsNullOrEmpty(returnUrl))
                    {
                        return(Redirect("/"));
                    }
                    else
                    {
                        return(Redirect(returnUrl));
                    }
                }

                HandleErrors(result);
            }

            return(View(new AccountRegisterModel()
            {
                Input = input
            }));
        }
        public ActionResult List(long?id, Guid?token)
        {
            if (!id.HasValue)
            {
                return(this.NotFoundException());
            }

            if (!User.Identity.IsAuthenticated && token.HasValue)
            {
                var user = authAdapter.ValidateAuthToken(token.Value);

                if (user.StatusCode == 200)
                {
                    CustomAuthentication.SetAuthCookie(user.Result.Username, user.Result.UserId, true);
                    return(RedirectToAction("list", new { id = id }));
                }
            }

            var status = this.propertyAdapter.GetPropertyListingInfo(id.Value, User.Identity.Name);

            if (status.StatusCode != 200)
            {
                return(this.NotFoundException());
            }

            Rentler.Web.Models.PropertyListModel model = new Models.PropertyListModel(status.Result);

            model.StepsAvailable = GetStepsAvailable(status.Result);

            return(View(model));
        }
        /// <summary>
        /// Entry point for landlord to manage a single property.
        /// </summary>
        /// <param name="id">the property identifier</param>
        /// <returns></returns>
        public ActionResult Manage(long id, Guid?token)
        {
            if (!User.Identity.IsAuthenticated && token.HasValue)
            {
                var user = authAdapter.ValidateAuthToken(token.Value);
                if (user.StatusCode == 200)
                {
                    CustomAuthentication.SetAuthCookie(user.Result.Username, user.Result.UserId, true);
                }
                return(Redirect("/property/manage/" + id));
            }

            if (!User.Identity.IsAuthenticated)
            {
                return(Redirect("/account/login?returnUrl=" + "/property/manage/" + id));
            }

            var listing = this.propertyFacade.ManageListingById(id);

            if (listing.StatusCode != 200)
            {
                throw new HttpException(404, "Not Found");
            }
            PropertyManageModel model = new PropertyManageModel();

            model.Listing = listing.Result;
            if (!model.Listing.IsValidListing)
            {
                return(View("Manage-NotValid", model));
            }
            return(View(model));
        }
        public ActionResult Index(long?ad, Guid?token)
        {
            if (!ad.HasValue)
            {
                return(this.NotFoundException());
            }

            RedisPublisher.Publish("token", "Listing page " + ad.Value + " token: " + token.HasValue.ToString());

            if (!User.Identity.IsAuthenticated && token.HasValue)
            {
                var user = authAdapter.ValidateAuthToken(token.Value);

                if (user.StatusCode == 200)
                {
                    CustomAuthentication.SetAuthCookie(user.Result.Username, user.Result.UserId, true);
                }

                return(Redirect("/ksl/listing/index?ad=" + ad.Value));
            }

            var status = this.listingAdapter.GetListing(ad.Value);

            // this is ok because the adapter will return 0 if count cannot
            // be retrieved
            var viewCount = this.listingAdapter.GetListingViews(ad.Value).Result;

            var userHasSaved = this.listingAdapter.ListingWasSavedBy(ad.Value, User.Identity.Name).Result;

            if (status.StatusCode != 200)
            {
                return(this.NotFoundException());
            }

            this.listingAdapter.IncrementListingViews(ad.Value);

            var model = new ListingIndexModel();

            model.Listing      = status.Result;
            model.ListingViews = viewCount;
            model.UserHasSaved = userHasSaved;

            //set the login url to Ksl
            model.LoginUrl = string.Format("{0}{1}?login_forward=",
                                           Rentler.Web.Config.KslDomain,
                                           Rentler.Web.Config.KslLoginPath);

            model.LoginUrl += Url.Encode(string.Format("{0}{1}{2}",
                                                       Rentler.Web.Config.KslDomain,
                                                       Rentler.Web.Config.KslListingPath,
                                                       status.Result.BuildingId));

            return(View(model));
        }
        public ActionResult Index(Search search, Guid?token)
        {
            if (!User.Identity.IsAuthenticated && token.HasValue)
            {
                var user = authAdapter.ValidateAuthToken(token.Value);

                if (user.StatusCode == 200)
                {
                    CustomAuthentication.SetAuthCookie(user.Result.Username, user.Result.UserId, true);
                }
            }


            // Fix for php sending goofy data to us.
            if (Request["Amenities[]"] != null)
            {
                if (search.Amenities == null)
                {
                    List <string> strings = new List <string>(
                        Request["Amenities[]"].Split(",".ToCharArray()));
                    search.Amenities = strings.ToArray();
                }
            }

            // Fix for php sending goofy data to us.
            if (Request["Terms[]"] != null)
            {
                if (search.Terms == null)
                {
                    List <string> strings = new List <string>(
                        Request["Terms[]"].Split(",".ToCharArray()));
                    search.Terms = strings.ToArray();
                }
            }

            var result = this.searchAdapter.Search(search);

            if (Request.IsAjaxRequest())
            {
                return(PartialView("SearchResults", result.Result));
            }

            return(View(result.Result));
        }
        public ActionResult Create(Guid?token, int?PropertyTypeCode)
        {
            if (!User.Identity.IsAuthenticated && token.HasValue)
            {
                var user = authAdapter.ValidateAuthToken(token.Value);

                if (user.StatusCode == 200)
                {
                    CustomAuthentication.SetAuthCookie(user.Result.Username, user.Result.UserId, true);
                    return(RedirectToAction("create"));
                }
            }

            Rentler.Web.Models.PropertyCreateModel model = new Models.PropertyCreateModel();
            model.IsKsl = true;

            // set property type from ksl from user selection
            model.Input.PropertyTypeCode = PropertyTypeCode.HasValue ? PropertyTypeCode.Value : 0;
            return(View(model));
        }
        public ActionResult Search(PropertySearch search, Guid?token)
        {
            if (!User.Identity.IsAuthenticated && token.HasValue)
            {
                var user = authAdapter.ValidateAuthToken(token.Value);
                if (user.StatusCode == 200)
                {
                    CustomAuthentication.SetAuthCookie(user.Result.Username, user.Result.UserId, true);
                }
                return(Redirect("/property/search"));
            }

            var result = this.propertyFacade.SearchForUserProperty(search);

            if (Request.IsAjaxRequest())
            {
                return(PartialView("SearchResults", result.Result));
            }
            return(View(result.Result));
        }
 public void SetAuthCookieNoException()
 {
     CustomAuthentication.SetAuthCookie("cyberkruz", 4, true);
 }