Example #1
0
        public async Task <ActionResult> DevLogin(DevLoginViewModel model, string returnUrl)
        {
            OnlySupportedInDevelopmentEnvironment();

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(model.Username, "", model.RememberMe, shouldLockout : false);

            switch (result)
            {
            case SignInStatus.Success:
                if (model.Password != Properties.Settings.Default.DevLoginPassword)
                {
                    goto case SignInStatus.Failure;
                }
                Log.Information("Dev Login success for user {NewUserName}", model.Username);
                return(RedirectToLocal(returnUrl));

            //case SignInStatus.LockedOut:
            //    return View("Lockout");
            //case SignInStatus.RequiresVerification:
            //    return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
            case SignInStatus.Failure:
            default:
                ModelState.AddModelError("", "Invalid login attempt.");
                return(View(model));
            }
        }
Example #2
0
        public ActionResult Login(DevLoginViewModel model, string returnUrl)
        {
            var redirectUrl = Properties.Settings.Default.SecureAuthUrl +
                              new QueryString(
                "ReturnUrl",
                $"https://{Request.Url.Host}/Account/ExternalLoginCallback");

            return(ExternalLogin(DefaultAuthenticationTypes.ExternalCookie, redirectUrl));
        }
Example #3
0
        /// <summary>
        /// 开放平台登录方法
        /// </summary>
        /// <param name="model"></param>
        public void Login(DevLoginViewModel model)
        {
            if (model == null)
            {
                throw new MessageException("登录参数不能为空");
            }

            var username = model.UserName.Trim();
            var userpwd  = model.UserPwd.Trim();

            if (string.IsNullOrEmpty(username))
            {
                throw new MessageException("帐号不能为空");
            }

            if (string.IsNullOrEmpty(userpwd))
            {
                throw new MessageException("密码不能为空");
            }

            var cc = new ConditionCollection()
            {
                new Condition("mobile", username)
            };
            var developer = this.GetRepository <McpDeveloperInfo>().GetModel(cc);

            if (developer == null || !developer.UserPwd.Equals(SecurityUtil.ConvertToMD5(userpwd)))
            {
                throw new MessageException("帐号或密码错误");
            }

            //if (developer.IsActived == (int) IsActived.NoActive)
            //{
            //    throw new MessageException("您的帐号未激活,请于注册后24小时内到您的注册邮箱激活帐号");
            //}

            if (developer.StatusCode == StatusCodeType.Disabled.GetHashCode() || developer.StatusCode == StatusCodeType.Disabled.GetHashCode())
            {
                throw new MessageException("您的帐号异常,请于管理员联系");
            }

            // 如果登录成功,更新业务表的最后登陆时间和登录IP
            developer.LastLoginDate = CommonUtil.GetDBDateTime();
            developer.LastLoginIp   = CommonUtil.GetLocalIpAddress();

            this.GetRepository <McpDeveloperInfo>().Update(developer);

            SessionUtil.Current = new SessionData()
            {
                Account = developer.DeveloperId,
                Mobile  = developer.Mobile
            };
        }
Example #4
0
        public async Task <ActionResult> DevLogin(DevLoginViewModel model, string returnUrl)
        {
            OnlySupportedInDevelopmentEnvironment();


            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var user = DB.AspNetUsers.FirstOrDefault(u => u.UserName == model.Username);

            if (user != null && model.Password == ConfigOptions.Value.DevLoginPassword)
            {
                await SignInManager.SignInAsync(user, model.RememberMe);

                Log.Information("Dev Login success for user {NewUserName}", model.Username);
                return(RedirectToLocal(returnUrl));
            }
            ModelState.AddModelError("", "Invalid login attempt.");
            return(View(model));
        }
        public ActionResult DoLogin(DevLoginViewModel dev)
        {
            SingleInstance <DeveloperService> .Instance.Login(dev);

            return(OK());
        }
Example #6
0
        public ActionResult Login(DevLoginViewModel model, string returnUrl)
        {
            var redirectUrl = WebHelpers.AppendParameter(ConfigOptions.Value.SecureAuthUrl, "ReturnUrl", $"https://{Request.Host.Host}/Account/ExternalLoginCallback");

            return(ExternalLogin(AuthenticationTypeExternalCookie, redirectUrl));
        }