public JsonResult Find(string userName, string password)
        {
            UserManager manager = new UserManager();
            var user = manager.ValidateUser(userName, password);

            return Json(user, JsonRequestBehavior.AllowGet);
        }
 public HttpResponseMessage GetValidatedUser(LoginUser loginUser)
 {
     UserManager userManager = new UserManager();
     try
     {
         var savedUser = userManager.ValidateUser(loginUser.UserName.Trim(), loginUser.Password.Trim());
         HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Accepted, loginUser);
         return response;
     }
     catch (Exception ex)
     {
         return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message);
     }
 }
        public ActionResult SWT(string realm, string redirect_uri, string deflate, string wrap_name, string wrap_password, string sf_domain = "Default", string sf_persistent = "false", string is_form = "false")
        {
            var model = new LoginModel();
            UserManager um = new UserManager(sf_domain);
            if (um.ValidateUser(wrap_name, wrap_password))
            {
                Session["tfa.authState"] = 1;
                Session["tfa.realm"] = realm;
                Session["tfa.redirect_uri"] = redirect_uri;
                Session["tfa.deflate"] = deflate;
                Session["tfa.wrap_name"] = wrap_name;
                Session["tfa.sf_persistent"] = sf_persistent;

                UserProfileManager profileManager = UserProfileManager.GetManager();
                UserManager userManager = UserManager.GetManager();

                User user = userManager.GetUser(wrap_name);

                UserProfile profile = null;

                if (user != null)
                {
                    profile = profileManager.GetUserProfile<SitefinityProfile>(user);

                    string authyId = profile.GetValue<string>("AuthyId");

                    bool useTwoFactor = false;

                    if (!String.IsNullOrWhiteSpace(authyId))
                    {
                        useTwoFactor = true;

                        Session["tfa.authyId"] = authyId;
                    }

                    if (is_form == "false")
                    {
                        if (useTwoFactor)
                        {
                            return Json(new { url = "/TFA/Authenticate/Verify" });
                        }

                        return Json(new { url = GetLoginUri() });
                    }
                    else
                    {
                        if (useTwoFactor)
                        {
                            return Redirect("/TFA/Authenticate/Verify");
                        }

                        return Redirect(GetLoginUri());
                    }
                }
            }

            model.ProvidersList = GetProvidersList();

            ModelState.AddModelError("InvalidCredentials", "Incorrect Username/Password Combination");

            return View("Login", model);
        }
 public User ValidateUser(string userName, string password)
 {
     User result = null;
     using (UserManager manager = new UserManager())
     {
         result = manager.ValidateUser(userName, password);
     }
     return result;
 }