Example #1
0
        public void WeixinAuthUrl(WeiXinCallBackAuthViewModel weixinauth)
        {
            HttpContext.Response.AddHeader("Status", "200");
            HttpContext.Response.Write("接收成功");
            if (!string.IsNullOrEmpty(weixinauth.echostr))
            {
                var send   = UserBackendService.WeiXinAuthURL(weixinauth);
                var result = Newtonsoft.Json.JsonConvert.DeserializeObject <WeiXinMessageResult>(send);
                if (result.Status)
                {
                    HttpContext.Response.AddHeader("Status", "200");
                    HttpContext.Response.Write(result.Result);
                }
                else
                {
                    HttpContext.Response.Write(result.Code);
                }
            }
            var httpRequestStream = HttpContext.Request.InputStream;
            var message           = UserBackendService.SendCallBackMessage(weixinauth, httpRequestStream);
            var results           = Newtonsoft.Json.JsonConvert.DeserializeObject <WeiXinMessageResult>(message);

            if (results.Status)
            {
                HttpContext.Response.AddHeader("Status", "200");
                HttpContext.Response.Write(results.Result);
            }
        }
Example #2
0
        public JsonResult CheckReset(string NewPassword, string ConfirmPassword, string SMSCode, string Phone)
        {
            if (string.IsNullOrEmpty(NewPassword) || string.IsNullOrEmpty(ConfirmPassword))
            {
                return(Json(new { Status = "false", Result = "密码项不能为空!请仔细检查!" }));
            }
            if (string.IsNullOrEmpty(SMSCode))
            {
                return(Json(new { Status = false, Result = "短信验证码不为空!" }));
            }
            if (string.IsNullOrEmpty(Phone))
            {
                return(Json(new { Status = false, Result = "手机号不为空!" }));
            }
            if (!CheckerHelper.IsMobile(Phone.Trim()))
            {
                return(Json(new { Status = false, Result = "您发送的不是手机号!" }));
            }
            if (!UserBackendService.IsExist(Phone.Trim()))
            {
                return(Json(new { Status = false, Result = "系统不存在此用户!" }));
            }
            if (NewPassword != ConfirmPassword)
            {
                return(Json(new { Status = "false", Result = "新输入的密码不一致!" }));
            }
            var isdetectionon = PasswordStrengthDetectionService.IsDetectionOn();

            if (isdetectionon)
            {
                var isstonger = CheckPasswordStronger(ConfirmPassword.Trim());
                if (!isstonger)
                {
                    return(Json(new { Status = "false", Result = "密码不按规则" }));
                }
            }
            var smsresult = SystemService.CheckVerificationCode(Phone.Trim(), SMSCode);

            if (smsresult == null)
            {
                SystemService.SendVerificationCode(Phone.Trim(), 120);
                return(Json(new { Status = "false", Result = smsresult.FailReson }));
            }
            if (!smsresult.IsSuccess)
            {
                return(Json(new { Status = "false", Result = "发短信失败,重新发送!" }));
            }
            var result = UserManager.ResetPassword(Phone.Trim(), ApplicationUserManager.Admintoken, ConfirmPassword.Trim());

            if (!result.Succeeded)
            {
                return(Json(new { Status = false, Result = "更改密码失败,请重新确认修改!" }));
            }
            return(Json(new { Status = true, Result = "ResetSuccess" }));
        }
Example #3
0
 public JsonResult SMSVerificationCode(string phone, string captcha)
 {
     if (string.IsNullOrEmpty(phone) || string.IsNullOrEmpty(captcha))
     {
         return(Json(new { Status = "error", Msg = "手机号或者验证码不能为空!" }));
     }
     if (!CheckerHelper.IsMobile(phone))
     {
         return(Json(new { Status = "error", Msg = "输入的手机号不正确!" }));
     }
     if (!BConfigs.SimulateSendVCode && Session[CAPTCHA] != null && Session[CAPTCHA].ToString().ToUpper() != captcha.ToUpper())
     {
         return(Json(new { Status = "error", Msg = "验证码不正确!" }));
     }
     if (!UserBackendService.IsExist(phone))
     {
         return(Json(new { Status = "error", Msg = "您不是我们的成员,请联系后台管理员注册!" }));
     }
     SystemService.SendVerificationCode(phone, 120);
     return(Json(new { Status = "success", Msg = "短信已发送成功!" }));
 }
Example #4
0
        public async Task <ActionResult> WeixinLogin(string code, string state)
        {
            //if (string.IsNullOrEmpty(code))
            //{
            //    return RedirectToAction("Login");
            //}

            if (string.IsNullOrEmpty(state))
            {
                state = "~/Manage/index";
            }
            var weixinauthstatus = UserBackendService.IsWeiXinAuth(code);

            if (weixinauthstatus.AuthStatus)
            {
                var user = ReadOnlyRepository.Get(e => e.UserBackendId == weixinauthstatus.UserId.Value);
                if (user == null)
                {
                    ViewBag.State = state;
                    return(View());
                }
                #region 重新登录(跳过账号和密码)
                var userbankend = await UserManager.FindByNameAsync(user.UserName);

                if (userbankend == null)
                {
                    ViewBag.State = state;
                    return(View());
                }
                await SignInHelper.SignInAsync(userbankend, false, false);

                log4net.LogManager.GetLogger("RollingLog").Info(user.UserName + " Log in: 微信登录");
                #endregion
                //地址要改
                return(RedirectToLocal(state));
            }
            ViewBag.IsWeixin = !string.IsNullOrEmpty(code);
            ViewBag.State    = state;
            return(View());
        }