本文整理汇总了C#中OwinContext.SetAuthenticationService方法的典型用法代码示例。如果您正苦于以下问题:C# OwinContext.SetAuthenticationService方法的具体用法?C# OwinContext.SetAuthenticationService怎么用?C# OwinContext.SetAuthenticationService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OwinContext
的用法示例。
在下文中一共展示了OwinContext.SetAuthenticationService方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Invoke
public async Task Invoke(IDictionary<string, object> env)
{
var ctx = new OwinContext(env);
using (var db = new BrockAllen.MembershipReboot.Ef.DefaultUserAccountRepository())
{
var settings = SecuritySettings.FromConfiguration();
var mrConfig = new MembershipRebootConfiguration(settings);
mrConfig.ConfigureCookieBasedTwoFactorAuthPolicy(new OwinCookieBasedTwoFactorAuthPolicy(env));
var appInfo = new OwinApplicationInformation(env,
"Test", "Test Email Signature",
"/Login",
"/Register/Confirm/",
"/Register/Cancel/",
"/PasswordReset/Confirm/",
"/ChangeEmail/Confirm/");
var emailFormatter = new EmailMessageFormatter(appInfo);
if (settings.RequireAccountVerification)
{
// uncomment if you want email notifications -- also update smtp settings in web.config
mrConfig.AddEventHandler(new EmailAccountCreatedEventHandler(emailFormatter));
}
// uncomment if you want email notifications -- also update smtp settings in web.config
mrConfig.AddEventHandler(new EmailAccountEventsHandler(emailFormatter));
var uaSvc = new UserAccountService(mrConfig, db);
var anSvc = new OwinAuthenticationService(uaSvc, env);
try
{
ctx.SetUserAccountService(uaSvc);
ctx.SetAuthenticationService(anSvc);
await next(env);
}
finally
{
ctx.SetUserAccountService(null);
ctx.SetAuthenticationService(null);
}
}
}
开发者ID:neogodless,项目名称:BrockAllen.MembershipReboot,代码行数:43,代码来源:MembershipRebootConfigurationMiddleware.cs