Merge branch 'DotNetCore' of https://github.com/tidusjar/PlexRequests.Net into DotNetCore

pull/1510/head
Jamie.Rees 7 years ago
commit 7414f3284d

@ -8,5 +8,6 @@
public const string PowerUser = nameof(PowerUser);
public const string RequestTv = nameof(RequestTv);
public const string RequestMovie = nameof(RequestMovie);
public const string Disabled = nameof(Disabled);
}
}

@ -185,7 +185,7 @@ namespace Ombi.Core.Senders
{
var sonarrSeason = sonarrEpisodes.Where(x => x.seasonNumber == season.SeasonNumber);
var sonarrEpCount = sonarrSeason.Count();
var ourRequestCount = season.Episodes.Count();
var ourRequestCount = season.Episodes.Count;
if (sonarrEpCount == ourRequestCount)
{

@ -81,7 +81,6 @@ namespace Ombi.Store.Context
SaveChanges();
}
//Check if templates exist
var templates = NotificationTemplates.ToList();
//if (templates.Any())

@ -89,16 +89,32 @@ namespace Ombi.Controllers
var result = await UserManager.CreateAsync(userToCreate, user.Password);
if (result.Succeeded)
{
if (!await RoleManager.RoleExistsAsync(OmbiRoles.Admin))
{
await RoleManager.CreateAsync(new IdentityRole(OmbiRoles.Admin));
}
await CreateRoles();
await UserManager.AddToRoleAsync(userToCreate, OmbiRoles.Admin);
}
return true;
}
private async Task CreateRoles()
{
await CreateRole(OmbiRoles.AutoApproveMovie);
await CreateRole(OmbiRoles.Admin);
await CreateRole(OmbiRoles.AutoApproveTv);
await CreateRole(OmbiRoles.PowerUser);
await CreateRole(OmbiRoles.RequestMovie);
await CreateRole(OmbiRoles.RequestTv);
await CreateRole(OmbiRoles.Disabled);
}
private async Task CreateRole(string role)
{
if (!await RoleManager.RoleExistsAsync(role))
{
await RoleManager.CreateAsync(new IdentityRole(role));
}
}
/// <summary>
/// Gets all users.
/// </summary>

@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
using Ombi.Core.Claims;
using Ombi.Models;
using Ombi.Models.Identity;
using Ombi.Store.Entities;
@ -58,6 +59,11 @@ namespace Ombi.Controllers
{
var roles = await _userManager.GetRolesAsync(user);
if (roles.Contains(OmbiRoles.Disabled))
{
return new UnauthorizedResult();
}
var claims = new List<Claim>
{
new Claim(JwtRegisteredClaimNames.Sub, user.UserName),

Loading…
Cancel
Save