当前位置: 首页>>代码示例>>C#>>正文


C# IMansionContext.SetCurrentUserState方法代码示例

本文整理汇总了C#中IMansionContext.SetCurrentUserState方法的典型用法代码示例。如果您正苦于以下问题:C# IMansionContext.SetCurrentUserState方法的具体用法?C# IMansionContext.SetCurrentUserState怎么用?C# IMansionContext.SetCurrentUserState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMansionContext的用法示例。


在下文中一共展示了IMansionContext.SetCurrentUserState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Authenticate

		/// <summary>
		/// Authenticates the user.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="authenticationProviderName">The name of the authentication provider.</param>
		/// <param name="parameters">The parameters used for authentication.</param>
		/// <returns>Returns the <see cref="AuthenticationResult"/>.</returns>
		public AuthenticationResult Authenticate(IMansionContext context, string authenticationProviderName, IPropertyBag parameters)
		{
			// validate arguments
			if (context == null)
				throw new ArgumentNullException("context");
			if (string.IsNullOrEmpty(authenticationProviderName))
				throw new ArgumentNullException("authenticationProviderName");
			if (parameters == null)
				throw new ArgumentNullException("parameters");

			// get the authentication provider
			var authenicationProvider = ResolveAuthenticationProvider(context, authenticationProviderName);

			// invoke template method
			var result = DoAuthenticate(context, authenicationProvider, parameters);

			// set the user on the context if authentication was succesful
			if (result.WasSuccesful)
				context.SetCurrentUserState(result.UserState);

			// return result
			return result;
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:30,代码来源:SecurityServiceBase.cs

示例2: Logoff

		/// <summary>
		/// Logs the user of from the current <see cref="IMansionContext"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		public void Logoff(IMansionContext context)
		{
			// validate arguments
			if (context == null)
				throw new ArgumentNullException("context");

			// if the user was not authenticated, there is noone to logoff
			if (!context.CurrentUserState.IsAuthenticated)
				return;

			// get the authentication provider name of the user being logged off
			var authenticationProviderName = context.CurrentUserState.AuthenticationProviderName;
			var authenicationProvider = ResolveAuthenticationProvider(context, authenticationProviderName);

			// invoke template method
			DoLogoff(context, authenicationProvider);

			// set the anonymous user
			context.SetCurrentUserState(UserState.AnonymousUser);
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:24,代码来源:SecurityServiceBase.cs


注:本文中的IMansionContext.SetCurrentUserState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。