features/identity-roles #14
@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
using Newsbot.Collector.Api.Domain;
|
||||||
using Newsbot.Collector.Domain.Models.Config;
|
using Newsbot.Collector.Domain.Models.Config;
|
||||||
using Newsbot.Collector.Services.Jobs;
|
using Newsbot.Collector.Services.Jobs;
|
||||||
|
|
||||||
@ -24,6 +25,7 @@ public class CodeProjectController
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("check")]
|
[HttpPost("check")]
|
||||||
|
[Authorize(Roles = AuthorizationRoles.Administrators)]
|
||||||
public void PullNow()
|
public void PullNow()
|
||||||
{
|
{
|
||||||
BackgroundJob.Enqueue<CodeProjectWatcherJob>(x => x.InitAndExecute(new CodeProjectWatcherJobOptions
|
BackgroundJob.Enqueue<CodeProjectWatcherJob>(x => x.InitAndExecute(new CodeProjectWatcherJobOptions
|
||||||
|
@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
using Newsbot.Collector.Api.Domain;
|
||||||
using Newsbot.Collector.Domain.Models.Config;
|
using Newsbot.Collector.Domain.Models.Config;
|
||||||
using Newsbot.Collector.Domain.Models.Config.Sources;
|
using Newsbot.Collector.Domain.Models.Config.Sources;
|
||||||
using Newsbot.Collector.Services.Jobs;
|
using Newsbot.Collector.Services.Jobs;
|
||||||
@ -27,6 +28,7 @@ public class RssController
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("check")]
|
[HttpPost("check")]
|
||||||
|
[Authorize(Roles = AuthorizationRoles.Administrators)]
|
||||||
public void CheckReddit()
|
public void CheckReddit()
|
||||||
{
|
{
|
||||||
BackgroundJob.Enqueue<RssWatcherJob>(x => x.InitAndExecute(new RssWatcherJobOptions
|
BackgroundJob.Enqueue<RssWatcherJob>(x => x.InitAndExecute(new RssWatcherJobOptions
|
||||||
|
@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
using Newsbot.Collector.Api.Domain;
|
||||||
using Newsbot.Collector.Database.Repositories;
|
using Newsbot.Collector.Database.Repositories;
|
||||||
using Newsbot.Collector.Domain.Consts;
|
using Newsbot.Collector.Domain.Consts;
|
||||||
using Newsbot.Collector.Domain.Dto;
|
using Newsbot.Collector.Domain.Dto;
|
||||||
@ -199,12 +200,14 @@ public class SourcesController : ControllerBase
|
|||||||
return SourceDto.Convert(item);
|
return SourceDto.Convert(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Authorize(Roles = AuthorizationRoles.Administrators)]
|
||||||
[HttpPost("{id}/disable")]
|
[HttpPost("{id}/disable")]
|
||||||
public void Disable(Guid id)
|
public void Disable(Guid id)
|
||||||
{
|
{
|
||||||
_sources.Disable(id);
|
_sources.Disable(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Authorize(Roles = AuthorizationRoles.Administrators)]
|
||||||
[HttpPost("{id}/enable")]
|
[HttpPost("{id}/enable")]
|
||||||
public void Enable(Guid id)
|
public void Enable(Guid id)
|
||||||
{
|
{
|
||||||
@ -212,6 +215,7 @@ public class SourcesController : ControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
|
[Authorize(Roles = AuthorizationRoles.Administrators)]
|
||||||
public void Delete(Guid id, bool purgeOrphanedRecords)
|
public void Delete(Guid id, bool purgeOrphanedRecords)
|
||||||
{
|
{
|
||||||
_sources.Delete(id);
|
_sources.Delete(id);
|
||||||
|
@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
using Newsbot.Collector.Api.Domain;
|
||||||
using Newsbot.Collector.Domain.Models.Config;
|
using Newsbot.Collector.Domain.Models.Config;
|
||||||
using Newsbot.Collector.Domain.Models.Config.Sources;
|
using Newsbot.Collector.Domain.Models.Config.Sources;
|
||||||
using Newsbot.Collector.Services.Jobs;
|
using Newsbot.Collector.Services.Jobs;
|
||||||
@ -27,6 +28,7 @@ public class YoutubeController
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("check")]
|
[HttpPost("check")]
|
||||||
|
[Authorize(Policy = AuthorizationRoles.Administrators)]
|
||||||
public void CheckYoutube()
|
public void CheckYoutube()
|
||||||
{
|
{
|
||||||
BackgroundJob.Enqueue<YoutubeWatcherJob>(x => x.InitAndExecute(new YoutubeWatcherJobOptions
|
BackgroundJob.Enqueue<YoutubeWatcherJob>(x => x.InitAndExecute(new YoutubeWatcherJobOptions
|
||||||
|
@ -1,16 +1,19 @@
|
|||||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Newsbot.Collector.Api.Authentication;
|
using Newsbot.Collector.Api.Authentication;
|
||||||
using Newsbot.Collector.Domain.Entities;
|
using Newsbot.Collector.Domain.Entities;
|
||||||
using Newsbot.Collector.Domain.Interfaces;
|
using Newsbot.Collector.Domain.Interfaces;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Api.Controllers;
|
namespace Newsbot.Collector.Api.Controllers.v1;
|
||||||
|
|
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/v1/user")]
|
[Route("api/v1/user")]
|
||||||
public class UserController : Controller
|
public class UserController : Controller
|
||||||
{
|
{
|
||||||
private ILogger<UserController> _logger;
|
private readonly ILogger<UserController> _logger;
|
||||||
private IUserSourceSubscription _subscription;
|
private readonly IUserSourceSubscription _subscription;
|
||||||
|
|
||||||
public UserController(ILogger<UserController> logger, IUserSourceSubscription subscription)
|
public UserController(ILogger<UserController> logger, IUserSourceSubscription subscription)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user