refacto API prefix + nav.back
This commit is contained in:
parent
bd6ca9d11f
commit
6825f74308
78 changed files with 770 additions and 222 deletions
|
|
@ -90,7 +90,7 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
"ConfirmYourAccountTitle"
|
||||
})
|
||||
Debug.Assert(!_localizer[name].ResourceNotFound);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
{
|
||||
await _events.RaiseAsync(new UserLoginSuccessEvent(user.UserName, user.Id, user.UserName, clientId: context?.Client.ClientId));
|
||||
|
||||
// only set explicit expiration here if user chooses "remember me".
|
||||
// only set explicit expiration here if user chooses "remember me".
|
||||
// otherwise we rely upon expiration configured in cookie middleware.
|
||||
await HttpContext.SignInAsync(user, _roleManager, model.RememberMe, _dbContext);
|
||||
var authResult = await HttpContext.AuthenticateAsync();
|
||||
|
|
@ -198,7 +198,7 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
/// <summary>
|
||||
/// Entry point into the login workflow
|
||||
/// </summary>
|
||||
[HttpGet(YavscConstants.SigninPath)]
|
||||
[HttpGet(Constants.SigninPath)]
|
||||
public async Task<IActionResult> Signin(SignInModel model)
|
||||
{
|
||||
// build a model so we know what to show on the login page
|
||||
|
|
@ -216,11 +216,11 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
/// <summary>
|
||||
/// Handle postback from username/password login
|
||||
/// </summary>
|
||||
///
|
||||
[HttpPost(YavscConstants.SigninPath)]
|
||||
///
|
||||
[HttpPost(Constants.SigninPath)]
|
||||
[ValidateAntiForgeryToken]
|
||||
[AllowAnonymous]
|
||||
|
||||
|
||||
public async Task<IActionResult> Signin([FromForm] SignInModel model, [FromForm] string button)
|
||||
{
|
||||
|
||||
|
|
@ -232,7 +232,7 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
{
|
||||
if (context != null)
|
||||
{
|
||||
// if the user cancels, send a result back into IdentityServer as if they
|
||||
// if the user cancels, send a result back into IdentityServer as if they
|
||||
// denied the consent (even if this client does not require consent).
|
||||
// this will send back an access denied OIDC error response to the client.
|
||||
await _interaction.DenyAuthorizationAsync(context, AuthorizationError.AccessDenied);
|
||||
|
|
@ -269,7 +269,7 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
{
|
||||
await _events.RaiseAsync(new UserLoginSuccessEvent(user.UserName, user.Id, user.UserName, clientId: context?.Client.ClientId));
|
||||
|
||||
// only set explicit expiration here if user chooses "remember me".
|
||||
// only set explicit expiration here if user chooses "remember me".
|
||||
// otherwise we rely upon expiration configured in cookie middleware.
|
||||
await HttpContext.SignInAsync(user, _roleManager, model.RememberMe, _dbContext);
|
||||
|
||||
|
|
@ -396,7 +396,7 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
var local = context.IdP == IdentityServer8.IdentityServerConstants.LocalIdentityProvider;
|
||||
|
||||
// this is meant to short circuit the UI and only trigger the one external IdP
|
||||
|
||||
|
||||
model.EnableLocalLogin = local;
|
||||
model.UserName = context?.LoginHint;
|
||||
model.IsExternalLoginOnly = false;
|
||||
|
|
@ -579,7 +579,7 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
// Send an email with this link
|
||||
|
||||
Uri authority = new Uri(Config.Authority);
|
||||
|
||||
|
||||
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
|
||||
var callbackUrl = Url.Action("ConfirmEmail", "Account",
|
||||
new { userId = user.Id, code },
|
||||
|
|
@ -659,7 +659,7 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
}
|
||||
//
|
||||
// POST: /Account/LogOff
|
||||
[HttpPost(YavscConstants.LogoutPath)]
|
||||
[HttpPost(Constants.LogoutPath)]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> LogOff(string returnUrl = null)
|
||||
{
|
||||
|
|
@ -829,7 +829,7 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
bool result = false;
|
||||
try
|
||||
{
|
||||
result = await _userManager.VerifyTwoFactorTokenAsync(user, YavscConstants.DefaultFactor, code);
|
||||
result = await _userManager.VerifyTwoFactorTokenAsync(user, Constants.DefaultFactor, code);
|
||||
_dbContext.SaveChanges(userId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -1024,12 +1024,12 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
}
|
||||
|
||||
// Generate the token and send it
|
||||
if (model.SelectedProvider == YavscConstants.MobileAppFactor)
|
||||
if (model.SelectedProvider == Constants.MobileAppFactor)
|
||||
{
|
||||
return View("Error", new Exception("No mobile app service was activated"));
|
||||
}
|
||||
else
|
||||
if (model.SelectedProvider == YavscConstants.SMSFactor)
|
||||
if (model.SelectedProvider == Constants.SMSFactor)
|
||||
{
|
||||
return View("Error", new Exception("No SMS service was activated"));
|
||||
// await _smsSender.SendSmsAsync(_twilioSettings, await _userManager.GetPhoneNumberAsync(user), message);
|
||||
|
|
|
|||
|
|
@ -50,12 +50,12 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
// ensure all roles existence
|
||||
foreach (string roleName in new string[] {
|
||||
YavscConstants.AdminGroupName,
|
||||
YavscConstants.StarGroupName,
|
||||
YavscConstants.PerformerGroupName,
|
||||
YavscConstants.FrontOfficeGroupName,
|
||||
YavscConstants.StarHunterGroupName,
|
||||
YavscConstants.BlogModeratorGroupName
|
||||
Constants.AdminGroupName,
|
||||
Constants.StarGroupName,
|
||||
Constants.PerformerGroupName,
|
||||
Constants.FrontOfficeGroupName,
|
||||
Constants.StarHunterGroupName,
|
||||
Constants.BlogModeratorGroupName
|
||||
})
|
||||
if (!await _roleManager.RoleExistsAsync(roleName))
|
||||
{
|
||||
|
|
@ -80,11 +80,11 @@ namespace Yavsc.Controllers
|
|||
public async Task<IActionResult> Take()
|
||||
{
|
||||
// If some amdin already exists, make this method disapear
|
||||
var admins = await _userManager.GetUsersInRoleAsync(YavscConstants.AdminGroupName);
|
||||
var admins = await _userManager.GetUsersInRoleAsync(Constants.AdminGroupName);
|
||||
if (admins != null && admins.Count > 0)
|
||||
{
|
||||
// All is ok, nothing to do here.
|
||||
if (User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
if (User.IsInMsRole(Constants.AdminGroupName))
|
||||
{
|
||||
|
||||
return Ok(new { message = "you already got it." });
|
||||
|
|
@ -100,7 +100,7 @@ namespace Yavsc.Controllers
|
|||
return new BadRequestObjectResult(ModelState);
|
||||
}
|
||||
|
||||
var addToRoleResult = await _userManager.AddToRoleAsync(user, YavscConstants.AdminGroupName);
|
||||
var addToRoleResult = await _userManager.AddToRoleAsync(user, Constants.AdminGroupName);
|
||||
if (!addToRoleResult.Succeeded)
|
||||
{
|
||||
AddErrors(addToRoleResult);
|
||||
|
|
@ -114,11 +114,11 @@ namespace Yavsc.Controllers
|
|||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var adminCount = await _userManager.GetUsersInRoleAsync(
|
||||
YavscConstants.AdminGroupName);
|
||||
Constants.AdminGroupName);
|
||||
var userCount = await _dbContext.Users.CountAsync();
|
||||
var youAreAdmin = await _userManager.IsInRoleAsync(
|
||||
await _userManager.FindByIdAsync(User.GetUserId()),
|
||||
YavscConstants.AdminGroupName);
|
||||
Constants.AdminGroupName);
|
||||
|
||||
var roles = await _roleManager.Roles.Select(x => new RoleInfo
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
using IdentityServer8.EntityFramework.Entities;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Server.Helpers;
|
||||
using static Yavsc.Constants;
|
||||
|
||||
namespace Yavsc.Org.Controllers.Administration
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[Route(APIPrefix + "/[controller]")]
|
||||
[ApiController]
|
||||
public class ApiScopesApiController : ControllerBase
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@ namespace Yavsc.Controllers
|
|||
readonly IStringLocalizer<AnnouncesController> _localizer;
|
||||
readonly IAuthorizationService _authorizationService;
|
||||
|
||||
public AnnouncesController(ApplicationDbContext context,
|
||||
public AnnouncesController(ApplicationDbContext context,
|
||||
IAuthorizationService authorizationService,
|
||||
IStringLocalizer<AnnouncesController> localizer)
|
||||
{
|
||||
_context = context;
|
||||
_context = context;
|
||||
_authorizationService = authorizationService;
|
||||
_localizer = localizer;
|
||||
}
|
||||
|
|
@ -59,16 +59,16 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
private async Task SetupView(Announce announce)
|
||||
{
|
||||
ViewBag.IsAdmin = User.IsInMsRole(YavscConstants.AdminGroupName);
|
||||
ViewBag.IsPerformer = User.IsInMsRole(YavscConstants.PerformerGroupName);
|
||||
ViewBag.IsAdmin = User.IsInMsRole(Constants.AdminGroupName);
|
||||
ViewBag.IsPerformer = User.IsInMsRole(Constants.PerformerGroupName);
|
||||
ViewBag.AllowEdit = announce==null || announce.Id<=0 || !_authorizationService.AuthorizeAsync(User,announce,new EditPermission()).IsFaulted;
|
||||
List<SelectListItem> dl = new List<SelectListItem>();
|
||||
var rnames = System.Enum.GetNames(typeof(Reason));
|
||||
var rvalues = System.Enum.GetValues(typeof(Reason));
|
||||
|
||||
|
||||
for (int i = 0; i<rnames.Length; i++) {
|
||||
dl.Add(new SelectListItem { Text =
|
||||
_localizer[rnames[i]],
|
||||
dl.Add(new SelectListItem { Text =
|
||||
_localizer[rnames[i]],
|
||||
Value= rvalues.GetValue(i).ToString() });
|
||||
}
|
||||
|
||||
|
|
@ -82,14 +82,14 @@ namespace Yavsc.Controllers
|
|||
if (ModelState.IsValid)
|
||||
{
|
||||
// Only allow admin to create corporate annonces
|
||||
if (announce.For == Reason.Corporate && ! User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
if (announce.For == Reason.Corporate && ! User.IsInMsRole(Constants.AdminGroupName))
|
||||
{
|
||||
ModelState.AddModelError("For", _localizer["YourNotAdmin"]);
|
||||
return View(announce);
|
||||
}
|
||||
|
||||
// Only allow performers to create ServiceProposal
|
||||
if (announce.For == Reason.ServiceProposal && ! User.IsInMsRole(YavscConstants.PerformerGroupName))
|
||||
// Only allow performers to create ServiceProposal
|
||||
if (announce.For == Reason.ServiceProposal && ! User.IsInMsRole(Constants.PerformerGroupName))
|
||||
{
|
||||
ModelState.AddModelError("For", _localizer["YourNotAPerformer"]);
|
||||
return View(announce);
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ namespace Yavsc.Org.Controllers
|
|||
{
|
||||
var blog = await blogSpotService.Details(User, id.Value);
|
||||
ViewBag.apicmtctlr = "/api/v1/blogcomments";
|
||||
ViewBag.moderatoFlag = User.IsInMsRole(YavscConstants.BlogModeratorGroupName);
|
||||
ViewBag.moderatoFlag = User.IsInMsRole(Yavsc.Constants.BlogModeratorGroupName);
|
||||
|
||||
return View(blog);
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ namespace Yavsc.Controllers
|
|||
Value = pt.FullName,
|
||||
Selected = currentCode == pt.FullName
|
||||
}).ToList();
|
||||
items.Add(new SelectListItem { Text = SR[YavscConstants.NoneCode], Value = YavscConstants.NoneCode, Selected = currentCode == null});
|
||||
items.Add(new SelectListItem { Text = SR[Constants.NoneCode], Value = Constants.NoneCode, Selected = currentCode == null});
|
||||
ViewBag.SettingsClassName = items;
|
||||
}
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ namespace Yavsc.Controllers
|
|||
Text = a.Name,
|
||||
Value = a.Code
|
||||
}).ToList();
|
||||
var nullItem = new SelectListItem { Text = SR[YavscConstants.NoneCode], Value = YavscConstants.NoneCode };
|
||||
var nullItem = new SelectListItem { Text = SR[Constants.NoneCode], Value = Constants.NoneCode };
|
||||
acts.Add(nullItem);
|
||||
if (code == null) return acts;
|
||||
var existing = _context.Activities.Include(a => a.Children).FirstOrDefault(a => a.Code == code);
|
||||
|
|
@ -123,9 +123,9 @@ namespace Yavsc.Controllers
|
|||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Create(Activity activity)
|
||||
{
|
||||
if (activity.ParentCode==YavscConstants.NoneCode)
|
||||
if (activity.ParentCode==Constants.NoneCode)
|
||||
activity.ParentCode=null;
|
||||
if (activity.SettingsClassName==YavscConstants.NoneCode)
|
||||
if (activity.SettingsClassName==Constants.NoneCode)
|
||||
activity.SettingsClassName=null;
|
||||
|
||||
if (ModelState.IsValid)
|
||||
|
|
@ -161,9 +161,9 @@ namespace Yavsc.Controllers
|
|||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Edit(Activity activity)
|
||||
{
|
||||
if (activity.ParentCode==YavscConstants.NoneCode)
|
||||
if (activity.ParentCode==Constants.NoneCode)
|
||||
activity.ParentCode=null;
|
||||
if (activity.SettingsClassName==YavscConstants.NoneCode)
|
||||
if (activity.SettingsClassName==Constants.NoneCode)
|
||||
activity.SettingsClassName=null;
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ using Yavsc.Server.Helpers;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/v1/dimiss")]
|
||||
[Route(Constants.APIPrefix + "/v1/dimiss")]
|
||||
public class DimissClicksApiController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
|
@ -140,7 +140,7 @@ namespace Yavsc.Controllers
|
|||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (!User.IsInRole("Administrator"))
|
||||
if (uid != id) return new ChallengeResult();
|
||||
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState);
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ namespace Yavsc.Controllers
|
|||
readonly IHtmlLocalizer _localizer;
|
||||
|
||||
private SiteSettings siteSettings;
|
||||
public HomeController(ILogger<HomeController> logger,
|
||||
IHtmlLocalizer<HomeController> localizer,
|
||||
public HomeController(ILogger<HomeController> logger,
|
||||
IHtmlLocalizer<HomeController> localizer,
|
||||
ApplicationDbContext context,
|
||||
IOptions<SiteSettings> settingsOptions,
|
||||
IOptions<SiteSettings> settingsOptions,
|
||||
IWebHostEnvironment env
|
||||
)
|
||||
{
|
||||
|
|
@ -37,9 +37,9 @@ namespace Yavsc.Controllers
|
|||
|
||||
public async Task<IActionResult> Index(string id)
|
||||
{
|
||||
ViewBag.IsFromSecureProx = Request.Headers.ContainsKey(YavscConstants.SshHeaderKey) && Request.Headers[YavscConstants.SshHeaderKey] == "on";
|
||||
ViewBag.IsFromSecureProx = Request.Headers.ContainsKey(Constants.SshHeaderKey) && Request.Headers[Constants.SshHeaderKey] == "on";
|
||||
ViewBag.SecureHomeUrl = "https://" + Request.Headers["X-Forwarded-Host"];
|
||||
ViewBag.SshHeaderKey = Request.Headers[YavscConstants.SshHeaderKey];
|
||||
ViewBag.SshHeaderKey = Request.Headers[Constants.SshHeaderKey];
|
||||
var uid = User.GetUserId();
|
||||
long[] clicked = null;
|
||||
if (uid == null)
|
||||
|
|
@ -140,8 +140,8 @@ namespace Yavsc.Controllers
|
|||
errorViewModel.Description ??= string.Empty;
|
||||
errorViewModel.Description += " Page: Home.";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return View("~/Views/Shared/Error.cshtml", errorViewModel);
|
||||
}
|
||||
public IActionResult Status(int id)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace Yavsc.Controllers
|
|||
|
||||
public InstrumentationController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: Instrumentation
|
||||
|
|
@ -50,7 +50,7 @@ namespace Yavsc.Controllers
|
|||
var owned = _context.Instrumentation.Include(i=>i.Tool).Where(i=>i.UserId==uid).Select(i=>i.InstrumentId);
|
||||
var ownedArray = owned.ToArray();
|
||||
|
||||
ViewBag.YetAvailableInstruments = _context.Instrument.Select(k=>new SelectListItem
|
||||
ViewBag.YetAvailableInstruments = _context.Instrument.Select(k=>new SelectListItem
|
||||
{ Text = k.Name, Value = k.Id.ToString(), Disabled = ownedArray.Contains(k.Id) });
|
||||
|
||||
return View(new Instrumentation { UserId = uid });
|
||||
|
|
@ -64,7 +64,7 @@ namespace Yavsc.Controllers
|
|||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
if (model.UserId != uid) if (!User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
if (model.UserId != uid) if (!User.IsInMsRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
|
||||
_context.Instrumentation.Add(model);
|
||||
|
|
@ -82,7 +82,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
return NotFound();
|
||||
}
|
||||
if (id != uid) if (!User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
if (id != uid) if (!User.IsInMsRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
|
||||
if (musicianSettings == null)
|
||||
|
|
@ -98,7 +98,7 @@ namespace Yavsc.Controllers
|
|||
public async Task<IActionResult> Edit(Instrumentation musicianSettings)
|
||||
{
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInMsRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
|
|
@ -124,7 +124,7 @@ namespace Yavsc.Controllers
|
|||
return NotFound();
|
||||
}
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInMsRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
return View(musicianSettings);
|
||||
}
|
||||
|
|
@ -135,12 +135,12 @@ namespace Yavsc.Controllers
|
|||
public async Task<IActionResult> DeleteConfirmed(string id)
|
||||
{
|
||||
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
|
||||
|
||||
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInMsRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
|
||||
|
||||
|
||||
_context.Instrumentation.Remove(musicianSettings);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ public static class HostingExtensions
|
|||
public static IdentityBuilder AddIdentityDBAndStores(this WebApplicationBuilder builder)
|
||||
{
|
||||
IServiceCollection services = builder.Services;
|
||||
var connectionString = builder.Configuration.GetConnectionString(YavscConstants.YavscConnectionStringName);
|
||||
var connectionString = builder.Configuration.GetConnectionString(Constants.YavscConnectionStringName);
|
||||
|
||||
services.AddDbContext<ApplicationDbContext>(options =>
|
||||
{
|
||||
|
|
@ -197,7 +197,7 @@ public static class HostingExtensions
|
|||
options.SignIn.RequireConfirmedAccount = builder.Environment.IsEnvironment(
|
||||
builder.Environment.EnvironmentName);
|
||||
options.ClaimsIdentity.UserNameClaimType = JwtClaimTypes.PreferredUserName;
|
||||
options.ClaimsIdentity.RoleClaimType = YavscConstants.RoleClaimType;
|
||||
options.ClaimsIdentity.RoleClaimType = Constants.RoleClaimType;
|
||||
}
|
||||
)
|
||||
.AddEntityFrameworkStores<ApplicationDbContext>();
|
||||
|
|
@ -239,18 +239,18 @@ public static class HostingExtensions
|
|||
{
|
||||
policy
|
||||
.RequireAuthenticatedUser()
|
||||
.RequireClaim(YavscConstants.RoleClaimType,
|
||||
new string[] { YavscConstants.PerformerGroupName, YavscConstants.AdminGroupName })
|
||||
.RequireClaim(Constants.RoleClaimType,
|
||||
new string[] { Constants.PerformerGroupName, Constants.AdminGroupName })
|
||||
;
|
||||
});
|
||||
options.AddPolicy("AdministratorOnly", policy =>
|
||||
{
|
||||
_ = policy
|
||||
.RequireAuthenticatedUser()
|
||||
.RequireClaim(YavscConstants.RoleClaimType, YavscConstants.AdminGroupName);
|
||||
.RequireClaim(Constants.RoleClaimType, Constants.AdminGroupName);
|
||||
});
|
||||
|
||||
options.AddPolicy("FrontOffice", policy => policy.RequireRole(YavscConstants.FrontOfficeGroupName));
|
||||
options.AddPolicy("FrontOffice", policy => policy.RequireRole(Constants.FrontOfficeGroupName));
|
||||
|
||||
// options.AddPolicy("EmployeeId", policy => policy.RequireClaim("EmployeeId", "123", "456"));
|
||||
// options.AddPolicy("BuildingEntry", policy => policy.Requirements.Add(new OfficeEntryRequirement()));
|
||||
|
|
@ -314,10 +314,10 @@ public static class HostingExtensions
|
|||
{
|
||||
options.ClaimsIdentity.UserIdClaimType = JwtClaimTypes.Subject;
|
||||
options.ClaimsIdentity.UserNameClaimType = JwtClaimTypes.Name;
|
||||
options.ClaimsIdentity.RoleClaimType = YavscConstants.RoleClaimType;
|
||||
options.ClaimsIdentity.RoleClaimType = Constants.RoleClaimType;
|
||||
});
|
||||
var migrationsAssembly = typeof(Program).GetTypeInfo().Assembly.GetName().Name;
|
||||
var connectionString = builder.Configuration.GetConnectionString(YavscConstants.YavscConnectionStringName);
|
||||
var connectionString = builder.Configuration.GetConnectionString(Constants.YavscConnectionStringName);
|
||||
|
||||
string sqliteConnectionString = $"Data Source={Path.Combine(Path.GetTempPath(), "yavsc_test.db")}";
|
||||
|
||||
|
|
@ -1220,7 +1220,7 @@ ADD COLUMN IF NOT EXISTS ""Moderated"" boolean NOT NULL DEFAULT FALSE;");
|
|||
Config.UserFilesOptions = new FileServerOptions()
|
||||
{
|
||||
FileProvider = new PhysicalFileProvider(AbstractFileSystemHelpers.UserFilesDirName),
|
||||
RequestPath = PathString.FromUriComponent(YavscConstants.UserFilesPath),
|
||||
RequestPath = PathString.FromUriComponent(Constants.UserFilesPath),
|
||||
EnableDirectoryBrowsing = enableDirectoryBrowsing,
|
||||
};
|
||||
Config.UserFilesOptions.EnableDefaultFiles = true;
|
||||
|
|
@ -1233,7 +1233,7 @@ ADD COLUMN IF NOT EXISTS ""Moderated"" boolean NOT NULL DEFAULT FALSE;");
|
|||
Config.AvatarsOptions = new FileServerOptions()
|
||||
{
|
||||
FileProvider = new PhysicalFileProvider(Config.AvatarsDirName),
|
||||
RequestPath = PathString.FromUriComponent(YavscConstants.AvatarsPath),
|
||||
RequestPath = PathString.FromUriComponent(Constants.AvatarsPath),
|
||||
EnableDirectoryBrowsing = enableDirectoryBrowsing
|
||||
};
|
||||
|
||||
|
|
@ -1244,7 +1244,7 @@ ADD COLUMN IF NOT EXISTS ""Moderated"" boolean NOT NULL DEFAULT FALSE;");
|
|||
Config.GitOptions = new FileServerOptions()
|
||||
{
|
||||
FileProvider = new PhysicalFileProvider(Config.GitDirName),
|
||||
RequestPath = PathString.FromUriComponent(YavscConstants.GitPath),
|
||||
RequestPath = PathString.FromUriComponent(Constants.GitPath),
|
||||
EnableDirectoryBrowsing = enableDirectoryBrowsing,
|
||||
};
|
||||
Config.GitOptions.DefaultFilesOptions.DefaultFileNames.Add("index.md");
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Yavsc.ViewModels.Manage
|
|||
public class SetUserNameViewModel
|
||||
{
|
||||
[Required]
|
||||
[Display(Name = "User name"),RegularExpression(YavscConstants.UserNameRegExp)]
|
||||
[Display(Name = "User name"),RegularExpression(Constants.UserNameRegExp)]
|
||||
public string UserName { get; set; }
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
} else {
|
||||
<div class="alert alert-warning">
|
||||
<strong>Utilisateur inconnu</strong>
|
||||
<img src="@YavscConstants.DefaultAvatar" class="smalltofhol" alt="Utilisateur inconnu" title="Utilisateur inconnu" />
|
||||
<img src="@Constants.DefaultAvatar" class="smalltofhol" alt="Utilisateur inconnu" title="Utilisateur inconnu" />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
<li><a class="dropdown-item @PageHelpers.ActivePage(ViewContext, "Feature")" asp-controller="Feature" asp-action="Index">Features</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@if (User.IsInMsRole(YavscConstants.AdminGroupName)) {
|
||||
@if (User.IsInMsRole(Constants.AdminGroupName)) {
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle @PageHelpers.ActivePageAny(ViewContext, administrationControllers)" href="#" id="dropdown05" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Administration
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue