コード例 #1
0
ファイル: PageBase.cs プロジェクト: alexan1/marketweb
		protected void AddToListIfAdmin()
		{
			BPUsers bp = new BPUsers();
			DataTable dt = bp.GetAdminForOnlineList(COPRUser.COPRIdentity.MemberID);
			if(dt != null)
			{
				dt.Columns.Add(new DataColumn("Session", Type.GetType("System.String")));
				dt.Rows[0]["Session"] = Session.SessionID;
				if(Application["LoggedInAdmins"] is DataTable)
				{
					DataTable dt2 = ((DataTable)Application["LoggedInAdmins"]);
					bool b = true;
					foreach(DataRow dr in dt2.Rows)
					{
						if(Convert.ToInt32(dr["UserID"]) == Convert.ToInt32(dt.Rows[0]["UserID"]))
							b = false;

					}
					if(b)
					{
						DataRow dr = dt.Rows[0];
						dt2.ImportRow(dr);
					}
					Application["LoggedInAdmins"] = dt2;
				}
				else
					Application["LoggedInAdmins"] = dt;

			}
		}
コード例 #2
0
ファイル: Login.aspx.cs プロジェクト: alexan1/marketweb
		protected void btnLogin_Click(object sender, EventArgs e)
		{
			BPUsers bpUsers = new BPUsers();
			BPGroupPermissions bpGroupPermissions = new BPGroupPermissions();
			int memberID;
			string returnURL;

			returnURL = Request.QueryString["returnURL"];
			if (returnURL == null)
				returnURL = "Index.aspx";

			memberID = bpUsers.Login(txtLoginID.Text, txtPassword.Text);

			if (memberID > 0)
			{
				FormsAuthenticationTicket ticket;
				string hash;
				HttpCookie cookie;

				ticket = new FormsAuthenticationTicket(1, txtLoginID.Text, DateTime.Now, DateTime.Now.AddMinutes(30), true, memberID + ";" + bpGroupPermissions.SelectByUserID(memberID), FormsAuthentication.FormsCookiePath);

				hash = FormsAuthentication.Encrypt(ticket);

				cookie = FormsAuthentication.GetAuthCookie(txtLoginID.Text, false, FormsAuthentication.FormsCookiePath);
				cookie.Name = FormsAuthentication.FormsCookieName;
				cookie.Value = hash;

				Response.AppendCookie(cookie);
				Response.Redirect(returnURL);
			}
			else
				lblErr.Visible = true;
		}