//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("user_oauth", DTEnums.ActionEnum.Delete.ToString()); //检查权限 int sucCount = 0; int errorCount = 0; BLL.user_oauth bll = new BLL.user_oauth(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { if (bll.Delete(id)) { sucCount += 1; } else { errorCount += 1; } } } AddAdminLog(DTEnums.ActionEnum.Delete.ToString(), "删除OAuth授权成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("user_oauth.aspx", "keywords={0}", this.keywords)); }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("user_oauth", DTEnums.ActionEnum.Delete.ToString()); //检查权限 int sucCount = 0; int errorCount = 0; BLL.user_oauth bll = new BLL.user_oauth(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { if (bll.Delete(id)) { sucCount += 1; } else { errorCount += 1; } } } AddAdminLog(DTEnums.ActionEnum.Delete.ToString(), "删除OAuth设置成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("oauth_list.aspx", "keywords={0}", this.keywords), "Success"); }
private void RptBind(string _strWhere, string _orderby) { this.page = DTRequest.GetQueryInt("page", 1); txtKeywords.Text = this.keywords; BLL.user_oauth bll = new BLL.user_oauth(); this.rptList.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount); this.rptList.DataBind(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("oauth_list.aspx", "keywords={0}&page={1}", this.keywords, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
private void RptBind(string _strWhere, string _orderby) { this.page = DTRequest.GetQueryInt("page", 1); this.txtKeywords.Text = this.keywords; BLL.user_oauth bll = new BLL.user_oauth(); this.rptList.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount); this.rptList.DataBind(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("oauth_user_list.aspx", "keywords={0}&page={1}", this.keywords, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
/// <summary> /// OnInit事件,检查用户是否已经登录 /// </summary> void UserPage_Init(object sender, EventArgs e) { QQ_UserName = Session["nick"].ToString(); QQ_Imager = Session["avatar"].ToString(); turl = Utils.GetCookie(DTKeys.COOKIE_URL_REFERRER); if (string.IsNullOrEmpty(turl) || turl == HttpContext.Current.Request.Url.ToString().ToLower()) { turl = linkurl("usercenter", "index"); } if (IsUserLogin()) { //自动登录,跳转URL HttpContext.Current.Response.Redirect(turl); return; } //检查是否已授权 if (HttpContext.Current.Session["oauth_name"] == null || HttpContext.Current.Session["oauth_access_token"] == null || HttpContext.Current.Session["oauth_openid"] == null) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("登录失败,用户授权已过期,请重新登录!"))); return; } Model.user_oauth oauthModel = new BLL.user_oauth().GetModel(HttpContext.Current.Session["oauth_name"].ToString(), HttpContext.Current.Session["oauth_openid"].ToString()); if (oauthModel != null) { //检查用户是否存在 Model.users model = new BLL.users().GetModel(oauthModel.user_name); if (model == null) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("登录失败,授权用户不存在或已被删除!"))); return; } //记住登录状态,防止Session提前过期 HttpContext.Current.Session[DTKeys.SESSION_USER_INFO] = model; HttpContext.Current.Session.Timeout = 45; Utils.WriteCookie(DTKeys.COOKIE_USER_NAME_REMEMBER, "DTcms", model.user_name); Utils.WriteCookie(DTKeys.COOKIE_USER_PWD_REMEMBER, "DTcms", model.password); //更新最新的Access Token oauthModel.oauth_access_token = HttpContext.Current.Session["oauth_access_token"].ToString(); oauthModel.oauth_name = HttpContext.Current.Session["avatar"].ToString(); oauthModel.user_name = HttpContext.Current.Session["nick"].ToString(); new BLL.user_oauth().Update(oauthModel); //自动登录,跳转URL HttpContext.Current.Response.Redirect(turl); return; } }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("app_oauth", DTEnums.ActionEnum.Delete.ToString()); //检查权限 BLL.user_oauth bll = new BLL.user_oauth(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { bll.Delete(id); } } JscriptMsg("批量删除成功啦!", Utils.CombUrlTxt("oauth_user_list.aspx", "keywords={0}", this.keywords), "Success"); }
/// <summary> /// OnInit事件,检查用户是否已经登录 /// </summary> void UserPage_Init(object sender, EventArgs e) { turl = Utils.GetCookie(MXKeys.COOKIE_URL_REFERRER); if (string.IsNullOrEmpty(turl) || turl == HttpContext.Current.Request.Url.ToString().ToLower()) { turl = linkurl("usercenter", "index"); } if (IsUserLogin()) { //自动登录,跳转URL HttpContext.Current.Response.Redirect(turl); return; } //检查是否已授权 if (HttpContext.Current.Session["oauth_name"] == null || HttpContext.Current.Session["oauth_access_token"] == null || HttpContext.Current.Session["oauth_openid"] == null) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("登录失败,用户授权已过期,请重新登录!"))); return; } Model.user_oauth oauthModel = new BLL.user_oauth().GetModel(HttpContext.Current.Session["oauth_name"].ToString(), HttpContext.Current.Session["oauth_openid"].ToString()); if (oauthModel != null) { //检查用户是否存在 Model.users model = new BLL.users().GetModel(oauthModel.user_name); if (model == null) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("登录失败,授权用户不存在或已被删除!"))); return; } //记住登录状态,防止Session提前过期 HttpContext.Current.Session[MXKeys.SESSION_USER_INFO] = model; HttpContext.Current.Session.Timeout = 45; Utils.WriteCookie(MXKeys.COOKIE_USER_NAME_REMEMBER, "MxWeiXinPF", model.user_name); Utils.WriteCookie(MXKeys.COOKIE_USER_PWD_REMEMBER, "MxWeiXinPF", model.password); //更新最新的Access Token oauthModel.oauth_access_token = HttpContext.Current.Session["oauth_access_token"].ToString(); new BLL.user_oauth().Update(oauthModel); //自动登录,跳转URL HttpContext.Current.Response.Redirect(turl); return; } }
private void user_oauth_bind(HttpContext context) { //检查URL参数 if (context.Session["oauth_name"] == null) { context.Response.Write("{\"msg\": 0, \"msgbox\": \"错误提示:授权参数不正确!\"}"); return; } //获取授权信息 string result = Utils.UrlExecute(siteConfig.webpath + "api/oauth/" + context.Session["oauth_name"].ToString() + "/result_json.aspx"); if (result.Contains("error")) { context.Response.Write("{\"msg\": 0, \"msgbox\": \"错误提示:请检查URL是否正确!\"}"); return; } //反序列化JSON Dictionary<string, object> dic = JsonMapper.ToObject<Dictionary<string, object>>(result); if (dic["ret"].ToString() != "0") { context.Response.Write("{\"msg\": 0, \"msgbox\": \"错误代码:" + dic["ret"] + ",描述:" + dic["msg"] + "\"}"); return; } //检查用户名密码 string username = DTRequest.GetString("txtUserName"); string password = DTRequest.GetString("txtPassword"); if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) { context.Response.Write("{\"msg\": 0, \"msgbox\": \"温馨提示:请输入用户名或密码!\"}"); return; } BLL.users bll = new BLL.users(); Model.users model = bll.GetModel(username, DESEncrypt.Encrypt(password), userConfig.emaillogin); if (model == null) { context.Response.Write("{\"msg\":0, \"msgbox\":\"错误提示:用户名或密码错误,请重试!\"}"); return; } //开始绑定 Model.user_oauth oauthModel = new Model.user_oauth(); oauthModel.oauth_name = dic["oauth_name"].ToString(); oauthModel.user_id = model.id; oauthModel.user_name = model.user_name; oauthModel.oauth_access_token = dic["oauth_access_token"].ToString(); oauthModel.oauth_openid = dic["oauth_openid"].ToString(); int newId = new BLL.user_oauth().Add(oauthModel); if (newId < 1) { context.Response.Write("{\"msg\":0, \"msgbox\":\"错误提示:绑定过程中出现错误,请重新登录授权!\"}"); return; } context.Session[DTKeys.SESSION_USER_INFO] = model; context.Session.Timeout = 45; //记住登录状态,防止Session提前过期 Utils.WriteCookie(DTKeys.COOKIE_USER_NAME_REMEMBER, "DTcms", model.user_name); Utils.WriteCookie(DTKeys.COOKIE_USER_PWD_REMEMBER, "DTcms", model.password); //写入登录日志 new BLL.user_login_log().Add(model.id, model.user_name, "会员登录", DTRequest.GetIP()); //返回URL context.Response.Write("{\"msg\":1, \"msgbox\":\"会员登录成功!\"}"); return; }
private void user_oauth_bind(HttpContext context) { //检查URL参数 if (context.Session["oauth_name"] == null) { context.Response.Write("{\"status\": 0, \"msg\": \"错误提示:授权参数不正确!\"}"); return; } //获取授权信息 string result = Vincent._DTcms.Utils.UrlExecute(siteConfig.webpath + "api/oauth/" + context.Session["oauth_name"].ToString() + "/result_json.aspx"); if (result.Contains("error")) { context.Response.Write("{\"status\": 0, \"msg\": \"错误提示:请检查URL是否正确!\"}"); return; } //反序列化JSON Dictionary <string, object> dic = JsonMapper.ToObject <Dictionary <string, object> >(result); if (dic["ret"].ToString() != "0") { context.Response.Write("{\"status\": 0, \"msg\": \"错误代码:" + dic["ret"] + ",描述:" + dic["msg"] + "\"}"); return; } //检查用户名密码 string username = Vincent._DTcms.DTRequest.GetString("txtUserName"); string password = Vincent._DTcms.DTRequest.GetString("txtPassword"); if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) { context.Response.Write("{\"status\": 0, \"msg\": \"温馨提示:请输入用户名或密码!\"}"); return; } BLL.users bll = new BLL.users(); Model.users model = bll.GetModel(username, password, userConfig.emaillogin, userConfig.mobilelogin, true); if (model == null) { context.Response.Write("{\"status\":0, \"msg\":\"错误提示:用户名或密码错误!\"}"); return; } //开始绑定 Model.user_oauth oauthModel = new Model.user_oauth(); oauthModel.oauth_name = dic["oauth_name"].ToString(); oauthModel.user_id = model.id; oauthModel.user_name = model.user_name; oauthModel.oauth_access_token = dic["oauth_access_token"].ToString(); oauthModel.oauth_openid = dic["oauth_openid"].ToString(); int newId = new BLL.user_oauth().Add(oauthModel); if (newId < 1) { context.Response.Write("{\"status\":0, \"msg\":\"错误提示:绑定过程中出错,请重新获取!\"}"); return; } context.Session[Vincent._DTcms.DTKeys.SESSION_USER_INFO] = model; context.Session.Timeout = 45; //记住登录状态,防止Session提前过期 Vincent._DTcms.Utils.WriteCookie(Vincent._DTcms.DTKeys.COOKIE_USER_NAME_REMEMBER, "BuysingooShop", model.user_name); Vincent._DTcms.Utils.WriteCookie(Vincent._DTcms.DTKeys.COOKIE_USER_PWD_REMEMBER, "BuysingooShop", model.password); //写入登录日志 new BLL.user_login_log().Add(model.id, model.user_name, "会员登录"); //返回URL context.Response.Write("{\"status\":1, \"msg\":\"会员登录成功!\"}"); return; }