⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 authorloginpanel.ascx.cs

📁 Portal C# Article Live
💻 CS
字号:
namespace Interspire.ArticleLive.Web.Templates.DefaultStretched.Panels
{
	using System;
	using System.Data;
	using System.Drawing;
	using System.Web;
	using System.Web.UI.WebControls;
	using System.Web.UI.HtmlControls;

	public abstract class AuthorLoginPanel : BaseUserControl
	{
		protected System.Web.UI.WebControls.TextBox Username;
		protected System.Web.UI.WebControls.TextBox Password;
		protected System.Web.UI.WebControls.Button LoginButton;
		protected Interspire.ArticleLive.Web.MessageControl MessageControl1;
		protected Interspire.ArticleLive.Web.ValidationAlerter ValidationAlerter1;
		protected CustomRequiredFieldValidator UsernameReqVal;
		protected CustomRequiredFieldValidator PasswordReqVal;
		protected System.Web.UI.WebControls.LinkButton LoginNewButton;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if (Action == "LogOut")
			{
				Security.Authentication.LogOut();
				Response.Redirect(Config.Current.HomePagePath);
			}

			if (!Config.Current.EnableAuthorLogin)
				Visible = false;
			else
			{
				if (!IsPostBack)
				{
					if (Action == "LogIn")
					{
						WindowTitle = ResourceHelper.GetString("AuthorLogin");
						Visible = true;
						DataBind();
					}
					else
						Visible = false;
				}
			}
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();

			this.LoginButton.Click += new System.EventHandler(this.LoginButton_Click);
			this.Load += new System.EventHandler(this.Page_Load);
			
			SetDefaultButton(Username, LoginButton);
			SetDefaultButton(Password, LoginButton);
			SetDefaultField(Username);

			base.OnInit(e);
		}
		
		///		Required method for Designer support - do not modify
		///		the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{

		}
		#endregion

		private void LoginButton_Click(object sender, System.EventArgs e)
		{
			try
			{
				User user = Security.Authentication.LogIn(Username.Text, Password.Text);
				if (user.UserID > 0)
				{
					if (new ArticleEngine(Config.Current).CountAuthorArticles(user.UserID, false) > 0 || (user.Permissions & UserPermissionsEnum.SubmitArticle) == UserPermissionsEnum.None)
						Response.Redirect(Config.Current.AuthorsPagePath + "?a=ViewAccount&AuthorID=" + user.UserID);
					else
						Response.Redirect(Config.Current.ArticlesPagePath + "?a=SubmitArticle");
				}
			}
			catch (Security.InvalidCredentialsException)
			{
				MessageControl.DisplayError(ResourceHelper.GetString("InvalidCredentials"));
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -