/// <summary> /// 登录同时绑定第三方登录平台信息 /// </summary> /// <param name="_account">登录用户名</param> /// <param name="_pwd">登录密码</param> /// <param name="_type">绑定的第三方平台类型(1:微信 2:QQ 3:新浪微博)</param> /// <param name="_assessToken"></param> public void Login(string _account, string _pwd, EMobileLoginType _type, string _assessToken) { //绑定第三方登录 Model.UserPlatform _userPlatform = new BLL.UserPlatform().GetModel(_assessToken, ( int )this.loginType); if (_userPlatform == null) { //检查用户密码是否正确 int _userRow = 0; string _md5Pwd = Utils.MD5Str(_pwd); BCW.Model.User _user = new BCW.Model.User(); _user.UsPwd = _md5Pwd; if (_account.ToString().Length == 11) { _user.Mobile = _account; _userRow = new BCW.BLL.User().GetRowByMobile(_user); } else { _user.ID = int.Parse(_account); _userRow = new BCW.BLL.User().GetRowByID(_user); } if (_userRow <= 0) { rspLoginData.header.status = ERequestResult.faild; rspLoginData.header.statusCode = MOBILE_ERROR_CODE.LOGIN_USER_PWD_ERROR; return; } _user = new BCW.BLL.User().GetKey(_userRow); Model.UserPlatform _newUserPlatform = new BCW.Mobile.Model.UserPlatform(); try { _newUserPlatform.platformId = _assessToken; _newUserPlatform.platformType = ( int )_type; _newUserPlatform.userId = _user.ID; rspLoginData.user.platformId = _assessToken; new BLL.UserPlatform().Add(_newUserPlatform); } catch (Exception e) { ; } } base.Login(_account, _pwd); }
public void Login(string _account, string _pwd, bool platform = false) { //检查用户密码是否正确 int _userRow = 0; string _md5Pwd = platform == true ? _pwd : Utils.MD5Str(_pwd); BCW.Model.User _user = new BCW.Model.User(); _user.UsPwd = _md5Pwd; if (_account.ToString().Length == 11) { _user.Mobile = _account; _userRow = new BCW.BLL.User().GetRowByMobile(_user); } else { _user.ID = int.Parse(_account); _userRow = new BCW.BLL.User().GetRowByID(_user); } if (_userRow <= 0) { rspLoginData.header.status = ERequestResult.faild; rspLoginData.header.statusCode = MOBILE_ERROR_CODE.LOGIN_USER_PWD_ERROR; return; } _user = new BCW.BLL.User().GetKey(_userRow); int UsId = _user.ID; string UsKey = _user.UsKey; string UsPwd = _user.UsPwd; BCW.Model.User modelgetbasic = new BCW.BLL.User().GetBasic(_user.ID); //设置keys string keys = ""; keys = BCW.User.Users.SetUserKeys(UsId, UsPwd, UsKey); string bUrl = string.Empty; if (Utils.getPage(1) != "") { bUrl = Utils.getUrl(Utils.removeUVe(Utils.getPage(1))); } else { bUrl = Utils.getUrl("/default.aspx"); } //更新识别串 string SID = ConfigHelper.GetConfigString("SID"); bUrl = UrlOper.UpdateParam(bUrl, SID, keys); //----------------------写入日志文件作永久保存 new BCW.BLL.User().UpdateTime(UsId); //APP全部在线登录 new BCW.BLL.User().UpdateState(UsId, 0); TimeSpan timediff = DateTime.Now - Convert.ToDateTime("1970-01-01 00:00:00"); long stt = (Int64)timediff.TotalMilliseconds; rspLoginData.header.status = ERequestResult.success; rspLoginData.user.keys = keys; rspLoginData.user.userId = UsId; rspLoginData.user.userName = modelgetbasic.UsName; rspLoginData.user.userImg = "http://" + Utils.GetDomain() + modelgetbasic.Photo; rspLoginData.user.userKey = UsKey; //获取用户管理版块 int GroupId = new BCW.BLL.Group().GetID(UsId); DataSet ds = new BCW.BLL.Role().GetList("ID,UsName,RoleName,ForumID,ForumName,Include", "UsID=" + UsId + " and (OverTime>='" + DateTime.Now + "' OR OverTime='1990-1-1 00:00:00') and Status=0 ORDER BY FORUMID ASC"); if (ds != null && ds.Tables[0].Rows.Count > 0 || GroupId > 0) { if (ds != null && ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { rspLoginData.user.lstFLimit.Add(int.Parse(ds.Tables[0].Rows[i]["ForumID"].ToString())); } } } }