public virtual ReturnInfo <LoginReturnInfo> Login(LoginInfo loginInfo)
        {
            if (IdentityAuth == null && IdentityBasicAuth == null)
            {
                var re = new ReturnInfo <LoginReturnInfo>();
                re.SetFailureMsg("不支持登录");

                return(re);
            }

            return(ExecLogin(loginInfo, (user, pwd, reInfo) =>
            {
                if (IdentityAuth != null)
                {
                    var busRe = IdentityAuth.Accredit(loginInfo.LoginId, loginInfo.Password);
                    reInfo.FromBasic(busRe);
                }
                else
                {
                    var busRe = IdentityBasicAuth.Accredit(loginInfo.LoginId, loginInfo.Password);
                    reInfo.FromBasic(busRe);
                }

                reInfo.Data = reInfo.Data;
            }));
        }
Beispiel #2
0
        public virtual ReturnInfo <LoginReturnInfo> Login(LoginInfo loginInfo)
        {
            if (IdentityAuth == null && IdentityBasicAuth == null)
            {
                var re = new ReturnInfo <LoginReturnInfo>();
                re.SetFailureMsg("不支持登录");

                return(re);
            }


            var comData = HttpContext.CreateCommonUseData(ComDataFactory, menuCode: "Authorization", functionCodes: "Login");

            return(ExecLogin(loginInfo, (user, pwd, reInfo) =>
            {
                if (IdentityAuth != null)
                {
                    var busRe = IdentityAuth.Accredit(loginInfo.LoginId, loginInfo.Password, comData);
                    reInfo.FromBasic(busRe);
                }
                else
                {
                    var busRe = IdentityBasicAuth.Accredit(loginInfo.LoginId, loginInfo.Password, comData);
                    reInfo.FromBasic(busRe);
                }

                reInfo.Data = reInfo.Data;
            }));
        }
Beispiel #3
0
        public override void Configure(Container container)
        {
            SetConfig(new HostConfig {
                AdminAuthSecret = "secretz"
            });

            Plugins.Add(new AuthFeature(IdentityAuth.For <IdentityUser>(options => {
                options.IncludeRegisterService    = true;
                options.IncludeAssignRoleServices = true;
            })));
        }
Beispiel #4
0
        public ActionResult LogOn(string returnUrl = null, string token = null)
        {
            if (returnUrl != null)
            {
                if (returnUrl.Contains('%'))
                {
                    try
                    {
                        returnUrl = Server.HtmlDecode(returnUrl);
                    }
                    catch {}
                }
            }

            if (AuthUtility.IsAuthenticated(User.Identity))
            {
                return(RedirectToLocal(returnUrl));
            }

            if (!string.IsNullOrEmpty(token))
            {
                AuthenticationTicket ticket = IdentityAuth.GetTicketFromToken(token);
                if (ticket != null)
                {
                    var identity = ticket.Identity;
                    if (identity != null && identity.IsAuthenticated)
                    {
                        var userId = identity.GetUserId <long>();
                        var user   = _userManager.FindById(userId);
                        if (user != null)
                        {
                            _signInManager.SignIn(user, false, false);
                            //  Writelog(string.Format("allowanonymous log: {0}",user.UserName));
                            return(RedirectToLocal(returnUrl));
                        }
                    }
                }
            }

            return(View());
        }