authenticationcheckfilter.cs

来自「工作流的基本资料(文档资料」· CS 代码 · 共 30 行

CS
30
字号
using System;
using System.Security.Principal;
using System.Threading;
using Castle.MonoRail.Framework;
using log4net;

namespace NetBpm.Web.Presentation.Filters
{
	public class AuthenticationCheckFilter : IFilter
	{
		private IFilter _userAddFilter=new UserAddFilter();
		private static readonly ILog log = LogManager.GetLogger(typeof (AuthenticationCheckFilter));
		public AuthenticationCheckFilter()
		{
		}

		public bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller controller)
		{
			_userAddFilter.Perform(exec,context,controller);
			if (Thread.CurrentPrincipal!=null && Thread.CurrentPrincipal.Identity.IsAuthenticated){
				log.Debug("authenticated");
				return true;
			}
			log.Debug("not authenticated");
			controller.Redirect("intro","index");
			return false;
		}
	}
}

⌨️ 快捷键说明

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