protected override void Page_Show() { pagetitle = "用户登录"; if (userid > 0) { ShowMsg("登录消息", "您已经登录了,请不要重复登录!", "", "usercontrolpanel.aspx"); } if (ispost) { string loginid = YRequest.GetString("loginid"); string password = YRequest.GetString("password"); if (loginid != string.Empty && password != string.Empty) { UserInfo info = Users.GetUserInfo(loginid, Natsuhime.Common.Utils.MD5(password), 0); if (info != null) { YCookies cookie = new YCookies("cmsnt"); cookie.WriteCookieValue("userid", info.Uid.ToString()); cookie.WriteCookieValue("password", info.Password); cookie.WriteCookieValue("username", info.Username); cookie.WriteCookieValue("adminid", info.Adminid.ToString()); cookie.AddCookieExpiresTime(30 * 3600 * 24); cookie.SaveCookie(); #region 插件登录 bool pluglogin = false; if (pluglogin) { Plugin.IUserProvider provider = Plugin.ProviderUtitily.GetUserProvider("DNT"); int uid = provider.IsUserExits(info.Username); if (uid > 0) { provider.Login(info.Username, password, false, 16000, ""); } else { provider.Register(info.Username, info.Password, info.Email, true); } } #endregion ShowMsg("登录消息", "登录成功,跳转到用户中心.", "", "usercontrolpanel.aspx"); } else { ShowError("登录消息", "登录失败,帐号或密码错误!", "", ""); } } else { ShowError("登录消息", "登录失败,用户名或密码为空,请检查输入框是否填写!", "", ""); } } }
protected UserInfo GetUserInfo() { YCookies cookie = new YCookies("cmsnt"); int uid = cookie.GetCookieIntValue("userid", 0); string password = cookie.GetCookieStringValue("password").Trim(); if (uid > 0 && password != string.Empty) { return(LiteCMS.Core.Users.GetUserInfo(uid, password)); } return(null); }
/// <summary> /// 验证登录 /// </summary> protected virtual void CheckLogin() { string cookiename = "cmsnt"; userid = YCookies.GetCookieIntValue("userid", cookiename, 0); adminid = YCookies.GetCookieIntValue("adminid", cookiename, 0); if (userid > 0) { username = YCookies.GetCookieStringValue("username", cookiename); } else { username = "******"; } }
protected virtual bool IsAdminLogined() { //UserInfo userinfo = GetUserInfo(); if (userid > 0) { YCookies admincookie = new YCookies("cmsntadmin"); int adminid = admincookie.GetCookieIntValue("adminid", 0); string password = admincookie.GetCookieStringValue("password").Trim(); admininfo = null; if (adminid > 0 && password != string.Empty) { admininfo = Admins.GetAdminInfo(adminid, password); if (admininfo != null && admininfo.Uid == userid) { adminpath = admincookie.GetCookieStringValue("path").Trim(); return(true); } } } //登录失败 adminpath = ""; return(false); }