nettoyages de code
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Data.Entity.Infrastructure;
|
||||
using Microsoft.Data.Entity.Metadata;
|
||||
using Microsoft.Data.Entity.Migrations;
|
||||
using Yavsc.Models;
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Data.Entity.Migrations;
|
||||
|
||||
namespace Yavsc.Migrations
|
||||
|
@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Data.Entity.Infrastructure;
|
||||
using Microsoft.Data.Entity.Metadata;
|
||||
using Microsoft.Data.Entity.Migrations;
|
||||
using Yavsc.Models;
|
||||
|
||||
namespace Yavsc.Migrations
|
||||
|
@ -1,4 +1,6 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
@ -57,6 +59,28 @@ namespace Yavsc.Controllers
|
||||
}
|
||||
return Ok(new {message="you owned it."});
|
||||
}
|
||||
public class RoleInfo {
|
||||
public string Name { get; set; }
|
||||
public IEnumerable<string> Users { get; set; }
|
||||
}
|
||||
[Authorize(Roles=Constants.AdminGroupName)]
|
||||
[Produces("application/json")]
|
||||
public async Task<IActionResult> Index() {
|
||||
var adminCount = await _userManager.GetUsersInRoleAsync(
|
||||
Constants.AdminGroupName);
|
||||
var youAreAdmin = await _userManager.IsInRoleAsync(
|
||||
await _userManager.FindByIdAsync(User.GetUserId()),
|
||||
Constants.AdminGroupName);
|
||||
var roles = _roleManager.Roles.Select(x=>
|
||||
new RoleInfo {
|
||||
Name = x.Name,
|
||||
Users = x.Users.Select( u=>u.UserId )
|
||||
} );
|
||||
return Ok (new { Roles = roles, AdminCount = adminCount.Count,
|
||||
YouAreAdmin = youAreAdmin
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void AddErrors(IdentityResult result)
|
||||
{
|
||||
|
@ -86,6 +86,7 @@ namespace Yavsc.Controllers
|
||||
|
||||
var user = await GetCurrentUserAsync();
|
||||
long pc = _dbContext.Blogspot.Count(x => x.AuthorId == user.Id);
|
||||
|
||||
var model = new IndexViewModel
|
||||
{
|
||||
HasPassword = await _userManager.HasPasswordAsync(user),
|
||||
|
@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Yavsc
|
||||
namespace Yavsc
|
||||
{
|
||||
public class SiteSettings
|
||||
{
|
||||
|
@ -407,7 +407,6 @@ namespace Yavsc
|
||||
options.LogoutPath = new PathString("/signout");
|
||||
});
|
||||
|
||||
|
||||
branch.UseMiddleware<GoogleMiddleware>(googleOptions);
|
||||
|
||||
// Facebook
|
||||
@ -420,10 +419,12 @@ namespace Yavsc
|
||||
});
|
||||
|
||||
});
|
||||
var authProvider = new AuthorizationProvider(loggerFactory);
|
||||
|
||||
app.UseOpenIdConnectServer(options =>
|
||||
{
|
||||
options.Provider = new AuthorizationProvider(loggerFactory);
|
||||
|
||||
options.Provider = authProvider;
|
||||
|
||||
// Register the certificate used to sign the JWT tokens.
|
||||
/* options.SigningCredentials.AddCertificate(
|
||||
assembly: typeof(Startup).GetTypeInfo().Assembly,
|
||||
@ -442,6 +443,7 @@ namespace Yavsc
|
||||
options.AllowInsecureHttp = true;
|
||||
options.AuthenticationScheme = "oidc"; // was = OpenIdConnectDefaults.AuthenticationScheme;
|
||||
options.LogoutEndpointPath = new PathString("/connect/logout");
|
||||
|
||||
/* options.ValidationEndpointPath = new PathString("/connect/introspect"); */
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user