Exemple #1
0
        public ActionResult SignIn(AuthenticateQueryRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("SignIn"));
            }

            var response = _membershipQueryService.Authenticate(request);
            var user     = _membershipQueryService.GetUserByEmail(new GetUserQueryRequest {
                Email = request.Email
            });

            if (response.Failed)
            {
                return(JsonMessage(response));
            }

            var model = SetUserInformation(user.User);

            SerializeModel(model);
            TransferUnauthorizedBasket(model);

            if (request.RememberMe)
            {
                Response.Cookies["Email"].Expires    = DateTime.Now.AddDays(30);
                Response.Cookies["Password"].Expires = DateTime.Now.AddDays(30);
            }

            if (!string.IsNullOrEmpty(request.ReturnUrl))
            {
                ViewBag.ReturnUrl = Server.UrlDecode(request.ReturnUrl);
            }

            return(JsonMessage(response));
        }
        public override bool IsUserInRole(string username, string roleName)
        {
            var response = _membershipQueryService.GetUserByEmail(new GetUserQueryRequest());//ToDo

            if (response.Failed)
            {
                return(false);
            }
            return(response.User.Role.ToString() == roleName);
        }