refact
This commit is contained in:
parent
1aafb7cc7d
commit
e24208e77b
32 changed files with 96 additions and 94 deletions
|
|
@ -198,7 +198,7 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
/// <summary>
|
||||
/// Entry point into the login workflow
|
||||
/// </summary>
|
||||
[HttpGet(Constants.SigninPath)]
|
||||
[HttpGet(YavscConstants.SigninPath)]
|
||||
public async Task<IActionResult> Signin(SignInModel model)
|
||||
{
|
||||
// build a model so we know what to show on the login page
|
||||
|
|
@ -217,7 +217,7 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
/// Handle postback from username/password login
|
||||
/// </summary>
|
||||
///
|
||||
[HttpPost(Constants.SigninPath)]
|
||||
[HttpPost(YavscConstants.SigninPath)]
|
||||
[ValidateAntiForgeryToken]
|
||||
[AllowAnonymous]
|
||||
|
||||
|
|
@ -659,7 +659,7 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
}
|
||||
//
|
||||
// POST: /Account/LogOff
|
||||
[HttpPost(Constants.LogoutPath)]
|
||||
[HttpPost(YavscConstants.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, Constants.DefaultFactor, code);
|
||||
result = await _userManager.VerifyTwoFactorTokenAsync(user, YavscConstants.DefaultFactor, code);
|
||||
_dbContext.SaveChanges(userId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -1024,12 +1024,12 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
}
|
||||
|
||||
// Generate the token and send it
|
||||
if (model.SelectedProvider == Constants.MobileAppFactor)
|
||||
if (model.SelectedProvider == YavscConstants.MobileAppFactor)
|
||||
{
|
||||
return View("Error", new Exception("No mobile app service was activated"));
|
||||
}
|
||||
else
|
||||
if (model.SelectedProvider == Constants.SMSFactor)
|
||||
if (model.SelectedProvider == YavscConstants.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[] {
|
||||
Constants.AdminGroupName,
|
||||
Constants.StarGroupName,
|
||||
Constants.PerformerGroupName,
|
||||
Constants.FrontOfficeGroupName,
|
||||
Constants.StarHunterGroupName,
|
||||
Constants.BlogModeratorGroupName
|
||||
YavscConstants.AdminGroupName,
|
||||
YavscConstants.StarGroupName,
|
||||
YavscConstants.PerformerGroupName,
|
||||
YavscConstants.FrontOfficeGroupName,
|
||||
YavscConstants.StarHunterGroupName,
|
||||
YavscConstants.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(Constants.AdminGroupName);
|
||||
var admins = await _userManager.GetUsersInRoleAsync(YavscConstants.AdminGroupName);
|
||||
if (admins != null && admins.Count > 0)
|
||||
{
|
||||
// All is ok, nothing to do here.
|
||||
if (User.IsInMsRole(Constants.AdminGroupName))
|
||||
if (User.IsInMsRole(YavscConstants.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, Constants.AdminGroupName);
|
||||
var addToRoleResult = await _userManager.AddToRoleAsync(user, YavscConstants.AdminGroupName);
|
||||
if (!addToRoleResult.Succeeded)
|
||||
{
|
||||
AddErrors(addToRoleResult);
|
||||
|
|
@ -114,11 +114,11 @@ namespace Yavsc.Controllers
|
|||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var adminCount = await _userManager.GetUsersInRoleAsync(
|
||||
Constants.AdminGroupName);
|
||||
YavscConstants.AdminGroupName);
|
||||
var userCount = await _dbContext.Users.CountAsync();
|
||||
var youAreAdmin = await _userManager.IsInRoleAsync(
|
||||
await _userManager.FindByIdAsync(User.GetUserId()),
|
||||
Constants.AdminGroupName);
|
||||
YavscConstants.AdminGroupName);
|
||||
|
||||
var roles = await _roleManager.Roles.Select(x => new RoleInfo
|
||||
{
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
private async Task SetupView(Announce announce)
|
||||
{
|
||||
ViewBag.IsAdmin = User.IsInMsRole(Constants.AdminGroupName);
|
||||
ViewBag.IsPerformer = User.IsInMsRole(Constants.PerformerGroupName);
|
||||
ViewBag.IsAdmin = User.IsInMsRole(YavscConstants.AdminGroupName);
|
||||
ViewBag.IsPerformer = User.IsInMsRole(YavscConstants.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));
|
||||
|
|
@ -82,14 +82,14 @@ namespace Yavsc.Controllers
|
|||
if (ModelState.IsValid)
|
||||
{
|
||||
// Only allow admin to create corporate annonces
|
||||
if (announce.For == Reason.Corporate && ! User.IsInMsRole(Constants.AdminGroupName))
|
||||
if (announce.For == Reason.Corporate && ! User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
{
|
||||
ModelState.AddModelError("For", _localizer["YourNotAdmin"]);
|
||||
return View(announce);
|
||||
}
|
||||
|
||||
// Only allow performers to create ServiceProposal
|
||||
if (announce.For == Reason.ServiceProposal && ! User.IsInMsRole(Constants.PerformerGroupName))
|
||||
if (announce.For == Reason.ServiceProposal && ! User.IsInMsRole(YavscConstants.PerformerGroupName))
|
||||
{
|
||||
ModelState.AddModelError("For", _localizer["YourNotAPerformer"]);
|
||||
return View(announce);
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
var blog = await blogSpotService.Details(User, id.Value);
|
||||
ViewData["apicmtctlr"] = "/api/blogcomments";
|
||||
ViewData["moderatoFlag"] = User.IsInMsRole(Constants.BlogModeratorGroupName);
|
||||
ViewData["moderatoFlag"] = User.IsInMsRole(YavscConstants.BlogModeratorGroupName);
|
||||
|
||||
return View(blog);
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ namespace Yavsc.Controllers
|
|||
Value = pt.FullName,
|
||||
Selected = currentCode == pt.FullName
|
||||
}).ToList();
|
||||
items.Add(new SelectListItem { Text = SR[Constants.NoneCode], Value = Constants.NoneCode, Selected = currentCode == null});
|
||||
items.Add(new SelectListItem { Text = SR[YavscConstants.NoneCode], Value = YavscConstants.NoneCode, Selected = currentCode == null});
|
||||
ViewBag.SettingsClassName = items;
|
||||
}
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ namespace Yavsc.Controllers
|
|||
Text = a.Name,
|
||||
Value = a.Code
|
||||
}).ToList();
|
||||
var nullItem = new SelectListItem { Text = SR[Constants.NoneCode], Value = Constants.NoneCode };
|
||||
var nullItem = new SelectListItem { Text = SR[YavscConstants.NoneCode], Value = YavscConstants.NoneCode };
|
||||
acts.Add(nullItem);
|
||||
if (code == null) return acts;
|
||||
var existing = _context.Activities.Include(a => a.Children).FirstOrDefault(a => a.Code == code);
|
||||
|
|
@ -124,9 +124,9 @@ namespace Yavsc.Controllers
|
|||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Create(Activity activity)
|
||||
{
|
||||
if (activity.ParentCode==Constants.NoneCode)
|
||||
if (activity.ParentCode==YavscConstants.NoneCode)
|
||||
activity.ParentCode=null;
|
||||
if (activity.SettingsClassName==Constants.NoneCode)
|
||||
if (activity.SettingsClassName==YavscConstants.NoneCode)
|
||||
activity.SettingsClassName=null;
|
||||
|
||||
if (ModelState.IsValid)
|
||||
|
|
@ -162,9 +162,9 @@ namespace Yavsc.Controllers
|
|||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Edit(Activity activity)
|
||||
{
|
||||
if (activity.ParentCode==Constants.NoneCode)
|
||||
if (activity.ParentCode==YavscConstants.NoneCode)
|
||||
activity.ParentCode=null;
|
||||
if (activity.SettingsClassName==Constants.NoneCode)
|
||||
if (activity.SettingsClassName==YavscConstants.NoneCode)
|
||||
activity.SettingsClassName=null;
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -31,9 +31,9 @@ namespace Yavsc.Controllers
|
|||
|
||||
public async Task<IActionResult> Index(string id)
|
||||
{
|
||||
ViewBag.IsFromSecureProx = Request.Headers.ContainsKey(Constants.SshHeaderKey) && Request.Headers[Constants.SshHeaderKey] == "on";
|
||||
ViewBag.IsFromSecureProx = Request.Headers.ContainsKey(YavscConstants.SshHeaderKey) && Request.Headers[YavscConstants.SshHeaderKey] == "on";
|
||||
ViewBag.SecureHomeUrl = "https://" + Request.Headers["X-Forwarded-Host"];
|
||||
ViewBag.SshHeaderKey = Request.Headers[Constants.SshHeaderKey];
|
||||
ViewBag.SshHeaderKey = Request.Headers[YavscConstants.SshHeaderKey];
|
||||
var uid = User.GetUserId();
|
||||
long[] clicked = null;
|
||||
if (uid == null)
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ namespace Yavsc.Controllers
|
|||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
if (model.UserId != uid) if (!User.IsInMsRole(Constants.AdminGroupName))
|
||||
if (model.UserId != uid) if (!User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
|
||||
_context.Instrumentation.Add(model);
|
||||
|
|
@ -82,7 +82,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
return NotFound();
|
||||
}
|
||||
if (id != uid) if (!User.IsInMsRole(Constants.AdminGroupName))
|
||||
if (id != uid) if (!User.IsInMsRole(YavscConstants.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(Constants.AdminGroupName))
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInMsRole(YavscConstants.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(Constants.AdminGroupName))
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
return View(musicianSettings);
|
||||
}
|
||||
|
|
@ -137,7 +137,7 @@ namespace Yavsc.Controllers
|
|||
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
|
||||
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInMsRole(Constants.AdminGroupName))
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue