예제 #1
0
        public ActionResult Index()
        {
            PassportService pass = new PassportService();

            ViewData["userName"] = pass.GetUserInfo().UserName;
            return(View());
        }
예제 #2
0
        /// <summary>
        /// 获取学生 GetWxOpenId
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2019-03-15</para>
        /// </summary>
        /// <param name="studentId">学生Id</param>
        /// <returns>微信OPENID</returns>
        internal static List <string> GetWxOpenId(long studentId)
        {
            List <string>   phones          = GetMobiles(studentId);
            PassportService passportService = new PassportService();

            return(passportService.GetByUserCodes(phones).Select(x => x.UnionId).ToList());
        }
        private void TestAttend()
        {
            WxNotifyProducerService publisher       = WxNotifyProducerService.Instance;
            PassportService         passportService = new PassportService();
            WxNotifyInDto           wxNotify        = new WxNotifyInDto();

            wxNotify.Data = new List <WxNotifyItemInDto>()
            {
                new WxNotifyItemInDto {
                    DataKey = "first", Value = "杨宏家长,您的孩子已经到校上课。(感谢您对孩子坚持学术艺术的鼓励)"
                },
                new WxNotifyItemInDto {
                    DataKey = "keyword1", Value = $"2018.02.28 14:29"
                },
                new WxNotifyItemInDto {
                    DataKey = "keyword2", Value = "米罗小小班"
                },
                new WxNotifyItemInDto {
                    DataKey = "keyword3", Value = "302"
                },
                new WxNotifyItemInDto {
                    DataKey = "keyword4", Value = "2018-02-28 14:30-15:30"
                },
                new WxNotifyItemInDto {
                    DataKey = "remark", Value = "杨梅红深圳市东海校区 [以上信息如有误,请点击留言]"
                }
            };
            wxNotify.ToUser = passportService.GetByUserCodes(new List <string> {
                "18138878080"
            }).Where(t => !string.IsNullOrEmpty(t.UnionId)).Select(t => t.UnionId).ToList();
            wxNotify.TemplateId = 14000000000000003;
            wxNotify.Url        = "";
            publisher.Publish(wxNotify);
        }
        public JsonResult Register(RegisterUser user)
        {
            //if (Session[CAPTCHAS_TEXT] != null)
            //{
            //    if (user.Captchas != Session[CAPTCHAS_TEXT].ToString())
            //        return new JsonNetResult(OpResult.Fail("验证码错误", code: "captchas"));
            //}
            if (new PhoneCodeService().CheckMobileCode(user.UserName, user.MsgVerifyCode) == false)
            {
                return(new JsonNetResult(OpResult.Fail("短信验证码错误", code: "msgVerifyCode")));
            }
            var svc    = new PassportService();
            var result = svc.Register(user);

            if (result.Successed)
            {
                //注册成功 直接登录
                FormAuthProvider formAuth = new FormAuthProvider();
                formAuth.SetLogin((Customers)result.Data, false, Request.Url.Host);
                CurrentMember.IsLogin = true;
                //清空cookie中原先要提交到订单列表的cartId,保证点击立即购买->结算再登录跳转至购物车页面
                CookieHelper.SetCookie("cartids", "");
                //合并购物车
                _cartService.MergeCart();
                return(new JsonNetResult(OpResult.Success(message: "注册成功", data: Url.Action("Index", "Home"))));
            }
            else
            {
                return(new JsonNetResult(OpResult.Fail(result.Message, code: "error")));
            }
        }
        /// <summary>
        /// 登录验证
        /// </summary>
        /// <param name="model"></param>
        /// <param name="urlHost"></param>
        /// <returns></returns>
        public OpResult Authenticate(LoginUser model, string urlHost)
        {
            if (string.IsNullOrEmpty(model.UserName) || string.IsNullOrEmpty(model.Password))
            {
                return(OpResult.Fail());
            }

            //验证是否有登录权限
            var svc         = new PassportService();
            var loginResult = svc.CheckLogin(model.UserName, model.Password);
            var result      = false;

            if (loginResult.Successed)
            {
                result = true;
                var member = (Customers)loginResult.Data;
                result = SetLogin(member, model.IsRememberMe, urlHost);
            }
            else
            {
                return(OpResult.Fail(loginResult.Message));
            }

            if (result)
            {
                return(OpResult.Success());
            }
            else
            {
                return(OpResult.Fail());
            }
        }
예제 #6
0
        public ActionResult ModifyPassword(string oldPwd, string newPwd)
        {
            var userId = CurrentMember.MemberId.ToString();
            var result = new PassportService().ModifyPassword(userId, oldPwd, newPwd);

            return(Json(result));
        }
        private void TestFeedBack()
        {
            WxNotifyProducerService publisher       = WxNotifyProducerService.Instance;
            PassportService         passportService = new PassportService();
            WxNotifyInDto           wxNotify        = new WxNotifyInDto();

            wxNotify.Data = new List <WxNotifyItemInDto>()
            {
                new WxNotifyItemInDto()
                {
                    DataKey = "first", Color = "#173177", Value = "您好!我们会尽快处理您提交的信息。 感谢您的支持!"
                },
                new WxNotifyItemInDto()
                {
                    DataKey = "keyword1", Color = "#173177", Value = "总部客服"
                },
                new WxNotifyItemInDto()
                {
                    DataKey = "keyword2", Color = "#173177", Value = "2018.02.01 15:23"
                },
                new WxNotifyItemInDto()
                {
                    DataKey = "remark", Color = "#173177", Value = "杨梅红国际私立美校深圳校区"
                }
            };
            wxNotify.ToUser = passportService.GetByUserCodes(new List <string> {
                "18138878080"
            }).Where(t => !string.IsNullOrEmpty(t.UnionId)).Select(t => t.UnionId).ToList();
            wxNotify.TemplateId = 14000000000000001;
            wxNotify.Url        = "www.ymm.cn";
            publisher.Publish(wxNotify);
        }
예제 #8
0
        /// <summary>
        /// 获取学生 GetWxOpenId
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2019-03-15</para>
        /// </summary>
        /// <param name="student">学生信息</param>
        /// <returns>微信OPENID</returns>
        internal static List <string> GetWxOpenId(TblCstStudent student)
        {
            PassportService passportService = new PassportService();

            List <string> phones = GetMobileList(student.LinkMobile, student.ContactPersonMobile);

            return(passportService.GetByUserCodes(phones).Select(x => x.UnionId).ToList());
        }
예제 #9
0
 public ServiceContext()
 {
     Session      = new Session();
     CacheContext = CacheContext.Instance;
     CacheContext.ServiceContext = this;
     PassportService             = new PassportService(this);
     DeviceService = new DeviceService(this);
     StoreService  = new StoreService(this);
 }
예제 #10
0
 public AccountController(Database db, UserManager <User> userManager,
                          ProfileService profile, PassportService passport, INotificator <bool> notify)
 {
     _db       = db;
     _user     = userManager;
     _profile  = profile;
     _passport = passport;
     _notify   = notify;
 }
        /// <summary>
        /// 校验学生是否绑定公众号
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2019-03-06</para>
        /// </summary>
        /// <param name="studentId">学生Id</param>
        /// <exception cref="BussinessException">
        /// 异常ID:38 ->学生未绑定家校互联
        /// </exception>
        private void VerifyStudentBindWeiXin(long studentId)
        {
            List <string>   phones       = StudentService.GetMobiles(studentId);
            PassportService service      = new PassportService();
            bool            isMobileBind = service.IsMobileBind(phones);

            if (!isMobileBind)
            {
                //未绑定家校互联
                throw new BussinessException(ModelType.Timetable, 69);
            }
        }
        public void GetCaptchas()
        {
            var    svc    = new PassportService();
            Random rdm    = new Random();
            var    result = svc.GetCaptchas();

            Session[CAPTCHAS_TEXT] = result.Text;
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            result.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
            Response.ClearContent();
            Response.ContentType = "image/Gif";
            Response.BinaryWrite(ms.ToArray());
        }
예제 #13
0
 public ActionResult PassportCenter()
 {
     //没有授权Token非法访问
     if (string.IsNullOrEmpty(Request["token"]))
     {
         return(Content("没有授权Token,非法访问"));
     }
     if (Session.GetByCookieRedis <UserInfo>() != null)
     {
         UserInfo userInfo = Session.GetByCookieRedis <UserInfo>();
         return(Redirect(PassportService.GetReturnUrl(userInfo.Id.ToString(), Request["token"], Request["returnUrl"])));
     }
     return(View());
 }
        /// <summary>
        /// 校验学生是否绑定公众号
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2019-03-06</para>
        /// </summary>
        /// <exception cref="BussinessException">
        /// 异常ID:38 ->学生未绑定家校互联
        /// </exception>
        private void VerifyStudentBindWeiXin()
        {
            List <string> phones = StudentService.GetMobiles(this._studentId);

            PassportService service      = new PassportService();
            bool            isMobileBind = service.IsMobileBind(phones);

            if (!isMobileBind)
            {
                //学生未绑定家校互联
                throw new BussinessException(ModelType.Default,
                                             (ushort)ScanCodeAttendStatusResponse.WARNING, ScanCodeAttendConstants.Unbound);
            }
        }
예제 #15
0
        public JsonResult CheckPassport(string passportNumber)
        {
            var passportService = new PassportService();
            var t = Task.Run(() => passportService.CheckPassport(passportNumber));

            t.Wait();
            var result = t.Result;

            if (result == 1)
            {
                var passportData = passportService.GetPassportData(passportNumber);
                return(Json(passportData, JsonRequestBehavior.AllowGet));
            }
            return(Json("Номер паспорта не правильный", JsonRequestBehavior.AllowGet));
        }
예제 #16
0
        public ActionResult PassportVertify()
        {
            var cookie = Request.Cookies[Constants.USER_COOKIE_KEY];

            if (cookie == null || string.IsNullOrEmpty(cookie.ToString()))
            {
                return(RedirectToAction("Login", new { ReturnUrl = Regex.Replace(Request["ReturnUrl"], @"ticket=(.{0,36})&token=(.{0,32})", String.Empty), Token = Request["Token"] }));
            }
            string userId  = cookie.Value;
            var    success = PassportService.AuthernVertify(Request["Token"], Convert.ToDateTime(Request["TimeStamp"]));

            if (!success)
            {
                return(RedirectToAction("Login", new { ReturnUrl = Regex.Replace(Request["ReturnUrl"], @"ticket=(.{0,36})&token=(.{0,32})", String.Empty), Token = Request["Token"] }));
            }
            return(Redirect(PassportService.GetReturnUrl(userId, Request["Token"], Request["ReturnUrl"])));
        }
        public JsonResult CheckUserName()
        {
            var result      = false;
            var queryStr    = Request.Params["userName"];
            var queryString = Request.QueryString["Mobile"];

            if (queryStr != null)
            {
                var svc = new PassportService();
                result = svc.CheckUserName(queryStr.ToString());
            }
            if (queryString != null)
            {
                var svc = new PassportService();
                result = svc.CheckUserName(queryString.ToString());
            }
            return(new JsonNetResult(result));
        }
예제 #18
0
        private void InitPassportInfo()
        {
            PassportInfoProxy passportInfo = m_PassportInfo;

            if (passportInfo == null)
            {
                lock (locker)
                {
                    if (m_PassportInfo == null)
                    {
                        passportInfo = PassportService.Passport_GetInfo();
                        //m_PassportInfo = passportInfo;
                        this.m_LoginUrl           = UrlUtil.JoinUrl(this.PassportRoot, passportInfo.LoginUrl);
                        this.m_LogoutUrl          = UrlUtil.JoinUrl(this.PassportRoot, passportInfo.LogoutUrl);
                        this.m_RegisterUrl        = UrlUtil.JoinUrl(this.PassportRoot, passportInfo.RegisterUrl);
                        this.m_RecoverPasswordUrl = UrlUtil.JoinUrl(this.PassportRoot, passportInfo.RecoverPasswordUrl);
                        this.m_AvatarGeneratorUrl = UrlUtil.JoinUrl(this.PassportRoot, passportInfo.AvatarGeneratorUrl);

                        this.m_SettingAvatarUrl      = UrlUtil.JoinUrl(this.PassportRoot, passportInfo.SettingAvatarUrl);
                        this.m_SettingChangeEmailUrl = UrlUtil.JoinUrl(this.PassportRoot, passportInfo.SettingChangeEmailUrl);
                        this.m_SettingNotifyUrl      = UrlUtil.JoinUrl(this.PassportRoot, passportInfo.SettingNotifyUrl);
                        this.m_SettingPasswordUrl    = UrlUtil.JoinUrl(this.PassportRoot, passportInfo.SettingPasswordUrl);
                        this.m_SettingPrlofileUrl    = UrlUtil.JoinUrl(this.PassportRoot, passportInfo.SettingPrlofileUrl);

                        this.m_CenterUrl       = UrlUtil.JoinUrl(this.PassportRoot, passportInfo.CenterUrl);
                        this.m_CenterChatUrl   = UrlUtil.JoinUrl(this.PassportRoot, passportInfo.CenterChatUrl);
                        this.m_CenterNotifyUrl = UrlUtil.JoinUrl(this.PassportRoot, passportInfo.CenterNotifyUrl);

                        this.m_CookieName = passportInfo.CookieName;

                        #region 关联设置
                        AllSettings.Current.PhoneValidateSettings.Open            = passportInfo.EnablePhoneValidate;
                        AllSettings.Current.NameCheckSettings.EnableRealnameCheck = passportInfo.EnableRealnameCheck;
                        #endregion

                        m_PassportInfo = passportInfo;
                    }
                }
            }
        }
예제 #19
0
 /// <summary>
 /// 自动登录验证
 /// </summary>
 /// <param name="urlHost"></param>
 /// <returns></returns>
 public bool AutoLogin(string urlHost)
 {
     if (!CurrentMember.IsAuthenticated)
     {//todo:cookie 过期的判断
         var cookieVal = LoginCookie;
         if (!string.IsNullOrEmpty(cookieVal))
         {
             var  lgId  = cookieVal.Split(',')[0];
             var  stamp = cookieVal.Split(',')[2];
             long?changePasswordTimeStamp = null;
             if (!string.IsNullOrEmpty(stamp))
             {
                 changePasswordTimeStamp = long.Parse(stamp);
             }
             var svc    = new PassportService();
             var member = svc.GetUser(lgId);
             if (member != null)
             {
                 if (member.ChangePasswordTimeStamp != changePasswordTimeStamp)
                 {
                     CurrentMember.HasAutoLogin = false;
                     return(false);
                 }
                 if (member.IsDisabled == 1)
                 {
                     CurrentMember.HasAutoLogin = false;
                     return(false);
                 }
                 SetLogin(member, false, urlHost);
                 CurrentMember.HasAutoLogin = true;
             }
             return(true);
         }
         return(false);
     }
     return(true);
 }
 public NavigationViewComponent(PassportService passportService)
 {
     _passportService = passportService;
 }
예제 #21
0
 public PassportController()
 {
     passportservice = new PassportService();
 }
        public ActionResult Forget(string mobile, string code, string newPwd, string confirmPwd)
        {
            var opResult = new PassportService().ResetPassword(mobile, code, newPwd);

            return(Json(new { success = opResult.Successed, msg = opResult.Message }));
        }
 public SysOperatorController(PassportService passportService, IMapper mapper)
 {
     this.passportService = passportService;
     Mapper = mapper;
 }
 public SysRoleController(PassportService passportService)
 {
     this.passportService = passportService;
 }
예제 #25
0
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            PassportService pass = new PassportService();

            pass.Run();
        }
예제 #26
0
 /// <summary>
 /// ctor.
 /// </summary>
 public DefaultController(PassportService passportService)
 {
     this.passportService = passportService;
 }
예제 #27
0
 public PassprotController(PassportService passportService)
 {
     this.passportService = passportService;
 }
 public MenuController(PassportService passportService)
 {
     this.passportService = passportService;
 }
예제 #29
0
 public LoginController(PassportService passPortService)
 {
     _passPortService = passPortService;
 }
예제 #30
0
 public AdminController(PassportService passportService)
 {
     PassportService = passportService;
 }