Webアプリケーションのカスタムユーザーストアを実装しました。これまでのところすべて正常に動作します。 今、私は役割をサポートするために、ストアクラスを拡張したかったのです。私は、次のインターフェイス実装:ASP.MVC IUserRoleStore <>がまったく呼び出されていません
IUserStore<UserViewModel>, IUserLockoutStore<UserViewModel, string>, IUserPasswordStore<UserViewModel, string>, IUserTwoFactorStore<UserViewModel, string>, IUserRoleStore<UserViewModel, string>, IRoleStore<RoleModel, string>
を、以下のようにOwin AppBuilderでサービスを登録:
var ctx = UnityMvcActivator.Context.Container;
app.CreatePerOwinContext(() => ctx.Resolve<WebUserManager>());
app.CreatePerOwinContext(() => ctx.Resolve<RoleManager>());
app.CreatePerOwinContext(() => ctx.Resolve<WebApplicationUserStore>());
私は戻って私のコントローラに行くと店を取得するために呼び出されることはありませんUser.IsInRole(Constants.Roles.COMPANY_OWNER)
を呼び出す場合ユーザーの役割私はいくつかの種類の欠けているリンクがあると思うが、私はそれを見つけることができない。 SupportsUserRole
プロパティがtrueに設定されたUserManager<UserViewModel, string>
も実装しました。違いはありません。
ソリューションは、User.IsInRoleのために正常に動作しますが、AuthorizeAttibuteは動作しません。すべてのリクエストをフィルタリングし、ログインページにリダイレクトします。 –