Skip to content

Commit 1be528c

Browse files
committed
Configure to use ApplicationRole
1 parent b77fcc0 commit 1be528c

File tree

1 file changed

+1
-78
lines changed

1 file changed

+1
-78
lines changed

TechStacks/Configure.Auth.cs

Lines changed: 1 addition & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public void Configure(IWebHostBuilder builder) => builder
1616
.ConfigureServices(services =>
1717
{
1818
Console.WriteLine("ConfigureAuth.ConfigureServices()");
19-
services.AddPlugin(new AuthFeature(IdentityAuth.For<ApplicationUser,int>(options => {
19+
services.AddPlugin(new AuthFeature(IdentityAuth.For<ApplicationUser,ApplicationRole,int>(options => {
2020
options.SessionFactory = () => new CustomUserSession();
2121
options.CredentialsAuth();
2222

@@ -61,82 +61,5 @@ public void Configure(IWebHostBuilder builder) => builder
6161
});
6262

6363
})));
64-
65-
services.TryAddScoped(typeof(RoleManager<IdentityRole>), CreateRoleManagerAdapter<ApplicationRole>);
6664
});
67-
68-
public static RoleManager<IdentityRole> CreateRoleManagerAdapter<TRole>(IServiceProvider services) where TRole : class
69-
{
70-
//var nativeRoleManager = services.GetRequiredService<RoleManager<TRole>>();
71-
var adapter = new RoleManager<IdentityRole>(
72-
CreateRoleStoreAdapter<TRole>(services),
73-
[],
74-
services.GetRequiredService<ILookupNormalizer>(),
75-
services.GetRequiredService<IdentityErrorDescriber>(),
76-
new Logger<RoleManager<IdentityRole>>(services.GetRequiredService<ILoggerFactory>())
77-
);
78-
return adapter;
79-
}
80-
81-
public static IRoleStore<IdentityRole> CreateRoleStoreAdapter<TRole>(IServiceProvider services) where TRole : class
82-
{
83-
return new AdapterRoleStore<TRole>(services.GetRequiredService<IRoleStore<TRole>>());
84-
}
85-
86-
class AdapterRoleStore<TRole>(IRoleStore<TRole> store) : IRoleStore<IdentityRole> where TRole : class
87-
{
88-
public void Dispose()
89-
{
90-
}
91-
92-
public Task<IdentityResult> CreateAsync(IdentityRole role, CancellationToken cancellationToken)
93-
{
94-
throw new NotImplementedException();
95-
}
96-
97-
public Task<IdentityResult> UpdateAsync(IdentityRole role, CancellationToken cancellationToken)
98-
{
99-
throw new NotImplementedException();
100-
}
101-
102-
public Task<IdentityResult> DeleteAsync(IdentityRole role, CancellationToken cancellationToken)
103-
{
104-
throw new NotImplementedException();
105-
}
106-
107-
public Task<string> GetRoleIdAsync(IdentityRole role, CancellationToken cancellationToken)
108-
{
109-
throw new NotImplementedException();
110-
}
111-
112-
public Task<string?> GetRoleNameAsync(IdentityRole role, CancellationToken cancellationToken)
113-
{
114-
throw new NotImplementedException();
115-
}
116-
117-
public Task SetRoleNameAsync(IdentityRole role, string? roleName, CancellationToken cancellationToken)
118-
{
119-
throw new NotImplementedException();
120-
}
121-
122-
public Task<string?> GetNormalizedRoleNameAsync(IdentityRole role, CancellationToken cancellationToken)
123-
{
124-
throw new NotImplementedException();
125-
}
126-
127-
public Task SetNormalizedRoleNameAsync(IdentityRole role, string? normalizedName, CancellationToken cancellationToken)
128-
{
129-
throw new NotImplementedException();
130-
}
131-
132-
public Task<IdentityRole?> FindByIdAsync(string roleId, CancellationToken cancellationToken)
133-
{
134-
throw new NotImplementedException();
135-
}
136-
137-
public Task<IdentityRole?> FindByNameAsync(string normalizedRoleName, CancellationToken cancellationToken)
138-
{
139-
throw new NotImplementedException();
140-
}
141-
}
14265
}

0 commit comments

Comments
 (0)