Example #1
0
        public static int LoginSuccess(IWxUsersRepository repository, IWxFriendsRepository wxFriendsRepository,
                                       HttpResponse Response, IAuthCore authcore, string uuid, string tip, ref string url)
        {
            var status = WeiXinHelper.GetLoginStatus(uuid, tip, ref url);

            return(status);
        }
Example #2
0
        /// <summary>
        /// 登录初始化
        /// </summary>
        /// <returns></returns>
        public static void LoginInitialization(IWxUsersRepository repository, IWxFriendsRepository wxFriendsRepository, HttpResponse Response, IAuthCore authcore, string url)
        {
            var wxCookie = String.Empty;
            var keys     = WeiXinHelper.GetUserKeys(url, ref wxCookie);

            //计算域名
            string hosts = url.IndexOf("wx.qq.com") > 0 ? "wx.qq.com" : "wx2.qq.com";

            //获取用户信息
            var userInfo = WeiXinHelper.GetWxUserInfo(hosts, keys);
            //创建用户
            var userModel = WxUsers.SetWxUserInfo(repository, userInfo.User, keys);

            //设置基础操作域名
            userModel.SetWxHosts(hosts);
            //同步好友
            var friends = WeiXinHelper.GetWxFriends(hosts, keys.skey, wxCookie);

            userModel.SyncFriends(wxFriendsRepository, friends);
            //创建状态通知
            WeiXinHelper.StartWxStatusNotify(hosts, wxCookie, keys, userModel.UserName);

            //心跳检测转到前端
            Thread thread = new Thread(m => HeartbeatWxStatus(Response, hosts, wxCookie, keys, userInfo.SyncKey));

            thread.IsBackground = true;
            thread.Start();

            //添加缓存
            AuthCore.SetUin(Response, userModel.Uin);
            authcore.SetUserName(userModel.Uin, userModel.UserName);
            authcore.SetUserHosts(userModel.Uin, hosts);
            authcore.SetUserKeys(userModel.Uin, keys);
            authcore.SetUserCookie(userModel.Uin, wxCookie);
            authcore.SetUserSyncKeys(userModel.Uin, userInfo.SyncKey);
        }
Example #3
0
 public LoginController(IAuthCore authcore, IWxUsersRepository repository, IWxFriendsRepository wxFriendsRepository)
 {
     _authcore            = authcore;
     _repository          = repository;
     _wxFriendsRepository = wxFriendsRepository;
 }