2014-08-30 73 views
1

是否有人使用membershipreboot.owin創建了一個多租戶示例,並使用了自定義useraccount?我應該如何使用MembershipReboot.Owin註冊一個自定義UserAccount?

我很難弄清楚如何在使用自定義帳戶時配置會員中間件。 未包含在默認示例中。我想我對Funcs的體驗還不夠。任何幫助,將不勝感激。

Thx。

的OwinExtentionMethods樣子:

 public static class MembershipRebootOwinExtensions 
    { 
     public static void UseMembershipReboot<TAccount>(
     this IAppBuilder app, 
     Func<IDictionary<string, object>, UserAccountService<TAccount>>   userAccountServiceFactory, 
     Func<IDictionary<string, object>, AuthenticationService<TAccount>> authenticationServiceFactory = null 
     ) 
     where TAccount : UserAccount 
     { 
      app.Use<MembershipRebootMiddleware<TAccount>>(userAccountServiceFactory, authenticationServiceFactory); 
      app.UseMembershipReboot(); 
     } 

    public static void UseMembershipReboot<TAccount>(
     this IAppBuilder app, 
     CookieAuthenticationOptions cookieOptions, 
     Func<IDictionary<string, object>, UserAccountService<TAccount>> userAccountServiceFactory, 
     Func<IDictionary<string, object>, AuthenticationService<TAccount>> authenticationServiceFactory = null 
     ) 
     where TAccount : UserAccount 
     { 
      app.Use<MembershipRebootMiddleware<TAccount>>(userAccountServiceFactory, authenticationServiceFactory); 
      app.UseMembershipReboot(cookieOptions); 
     } 

我將如何填補這兩個FUNC的?

Func<IDictionary<string, object>, UserAccountService<TAccount>> 

Func<IDictionary<string, object>, AuthenticationService<TAccount>> 

回答

0
+0

該示例不使用Owin!對? – 2014-09-01 08:25:22

+0

不,但它以獨立方式顯示如何使用具有所有泛型的自定義用戶帳戶。 – 2014-09-03 13:47:42

+0

也許是我對Func的理解不夠,但這個例子並沒有幫助我。它僅顯示如何實例化通用數據源類,通用存儲庫類。我的問題是我很難理解如何提供funcs作爲通用參數。 – 2014-10-06 12:15:02

0

只需獲得的當前上下文owin作爲

var owin = ctx.Resolve<IOwinContext>(); 

然後註冊您的自定義使用帳號爲

var owinAuth = new OwinAuthenticationService<CustomUserAccount>(AuthenticationTypes.Negotiate, ctx.Resolve<UserAccountService<CustomUserAccount>>(), owin.Environment); 

我希望這不是太晚。

+0

Thx評論我會研究這一點。看起來有希望 – 2016-03-10 08:57:12

相關問題