Beispiel #1
0
        public ActionResult AuthCheck(AM.Web.Models.UniversalViewModel model, string returnUrl)
        {
            if (model.IsLogin)
            {
                if (ModelState.ContainsKey("Password"))
                {
                    ModelState["Password"].Errors.Clear();
                }

                if (ModelState.IsValid)
                {
                    return(Json(new { IsSuccess = true, StatusMessage = "" }));
                }
                else
                {
                    return(Json(new { IsSuccess = false, StatusMessage = string.Join(" ", ModelState.Errors()) }));
                }
            }

            if (model.IsAuthCheck)
            {
                if (model.Email.IsNullOrWhiteSpace())
                {
                    return(Json(new { IsSuccess = true, IsNotValidLogin = false, StatusMessage = "Your email or username is required." }));
                }

                // check if the username is a project login
                MembershipUser memUser = null;

                try {
                    memUser = Membership.GetUser(model.Email);
                } catch (Exception ex) {
                    return(Json(new { IsSuccess = true, IsNotValidLogin = false, StatusMessage = "Your user could not be validated at this time. Please try again or let support know about it." }));
                }

                if (memUser.IsNotNull())
                {
                    if (memUser.ProviderUserKey.IsNotNull())
                    {
                        if (memUser.ProviderUserKey.ToString().ToGuid() != Guid.Empty)
                        {
                            if (memUser.Roles().Contains(UserRoles.Manager.ToString()))
                            {
                                return(Json(new { IsSuccess = true, IsNotValidLogin = false, StatusMessage = "" }));
                            }
                        }
                    }
                }
            }

            return(Json(new { IsSuccess = true, IsNotValidLogin = true, StatusMessage = "" }));
        }