public ActionResult ExternalLoginCallback(string returnUrl)
        {
            var membership = GetMembership();
            var callbackUrl = GetCallbackUrl(returnUrl);
            var result = OAuthWebSecurity.VerifyAuthentication(membership, this.HttpContext, callbackUrl);
            if (!result.IsSuccessful)
            {
                return RedirectToAction("ExternalLoginFailure");
            }
            else
            {
                var membershipConnect = new MembershipConnect() { Membership = membership, Name = result.Provider }.AsActual();
                if (membershipConnect != null)
                {
                    var membershipUser = _membershipUserManager.CreateOrUpdateOAuthMember(membership, membershipConnect, result, null);

                    if (membershipUser.IsApproved && !membershipUser.IsLockedOut)
                    {
                        HttpContext.MemberAuthentication().SetAuthCookie(membershipUser.UserName, false);
                    }
                    else
                    {
                        return RedirectToAction("ExternalLoginFailure", new { reason = "LockedOut" });
                    }
                }

            }
            return RedirectToLocal(returnUrl);
        }
 public virtual ActionResult Create(MembershipConnect model, string @return)
 {
     JsonResultData data = new JsonResultData(ModelState);
     if (ModelState.IsValid)
     {
         data.RunWithTry((resultData) =>
         {
             model.Membership = Membership;
             _manager.Add(model);
             resultData.RedirectUrl = @return;
         });
     }
     return Json(data);
 }
Beispiel #3
0
        private static IAuthClient GetAuthClient(Membership membership, string connectName)
        {
            var membershipConnect = new MembershipConnect() { Membership = membership, Name = connectName }.AsActual();

            if (membershipConnect == null)
            {
                throw new ArgumentException("Invalid membership connect.");
            }

            var authClient = Kooboo.CMS.Common.Runtime.EngineContext.Current.Resolve<IAuthClient>(membershipConnect.Name.ToLower());
            authClient.MembershipConnect = membershipConnect;

            return authClient;
        }
        public virtual ActionResult Delete(MembershipConnect[] model)
        {
            ModelState.Clear();
            var data = new JsonResultData(ModelState);
            data.RunWithTry((resultData) =>
            {
                if (model != null)
                {
                    foreach (var o in model)
                    {
                        o.Membership = Membership;
                        _manager.Delete(o);
                    }
                }

                data.ReloadPage = true;
            });

            return Json(data);
        }
 public virtual ActionResult Edit(string uuid)
 {
     var membershipConnect = new MembershipConnect() { Membership = Membership, UUID = uuid }.AsActual();
     return View(membershipConnect);
 }
 public virtual ActionResult IsNameAvailable(string name)
 {
     var membershipConnect = new MembershipConnect() { Membership = Membership, Name = name }.AsActual();
     if (membershipConnect != null)
     {
         return Json(string.Format("{0} is duplicate.".Localize(), name), JsonRequestBehavior.AllowGet);
     }
     return Json(true, JsonRequestBehavior.AllowGet);
 }