Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/ClinicalScheduler/EmailNotificationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ private async Task AddTestWeekGradYearAsync(int weekId, int gradYear = 2025, int
await _context.Weeks.AddAsync(new Week
{
WeekId = weekId,
DateStart = DateTime.UtcNow.AddDays(-7 * (10 - weekId)),
DateEnd = DateTime.UtcNow.AddDays(-7 * (10 - weekId) + 6),
DateStart = DateTime.UtcNow.AddDays(-7.0 * (10 - weekId)),
DateEnd = DateTime.UtcNow.AddDays(-7.0 * (10 - weekId) + 6),
TermCode = 202501
});
}
Expand Down
2 changes: 1 addition & 1 deletion test/ClinicalScheduler/TestDataBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public static Viper.Models.ClinicalScheduler.Person CreatePerson(string mothraId
/// </summary>
public static Week CreateWeek(int weekId, DateTime? startDate = null)
{
var start = startDate ?? DateTime.UtcNow.AddDays(-7 * (10 - weekId));
var start = startDate ?? DateTime.UtcNow.AddDays(-7.0 * (10 - weekId));
return new Week
{
WeekId = weekId,
Expand Down
11 changes: 3 additions & 8 deletions web/Areas/CMS/Controllers/CMSController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,9 @@ public IActionResult Files(string id = "", string fn = "", string oldURL = "", s
{
Data.CMS cms = new(_viperContext, _rapsContext, _sanitizerService, _cmsLogger);

if (ids.Length > 0)
{
return cms.DownloadZip(this, ids.Split(','), fileName);
}
else
{
return cms.ProvideFile(this, id, fn, oldURL);
}
return ids.Length > 0
? cms.DownloadZip(this, ids.Split(','), fileName)
: cms.ProvideFile(this, id, fn, oldURL);

}
}
Expand Down
2 changes: 1 addition & 1 deletion web/Areas/Curriculum/Services/TermCodeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static public string GetTermCodeDescription(int termCode)
default: desc = "Unknown Term"; break;
}

return string.Format("{0} {1}", desc, year.ToString());
return string.Format("{0} {1}", desc, year);
}

public async Task<List<Term>> GetTerms(string? TermType = null, bool? current = null, bool? currentMulti = null)
Expand Down
2 changes: 1 addition & 1 deletion web/Areas/Directory/Models/LdapUserContact.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public LdapUserContact(SearchResultEntry entry)
foreach (DirectoryAttribute attr in entry.Attributes.Values)
{
var v = attr[0];
or.Add(attr.Name + "=" + v.ToString());
or.Add(attr.Name + "=" + v);
switch (attr.Name)
{
case "uid": Uid = v.ToString(); break;
Expand Down
12 changes: 3 additions & 9 deletions web/Areas/Effort/Services/VerificationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -769,15 +769,9 @@ private VerificationReminderViewModel BuildVerificationEmailViewModel(
var useWeeksForClinical = termCode >= EffortConstants.ClinicalAsWeeksStartTermCode;

// Due date: ExpectedCloseDate - 7 days if set, otherwise fallback to Now + 7
DateTime dueDate;
if (expectedCloseDate.HasValue)
{
dueDate = expectedCloseDate.Value.AddDays(-_settings.VerificationReplyDays);
}
else
{
dueDate = DateTime.Now.AddDays(_settings.VerificationReplyDays);
}
DateTime dueDate = expectedCloseDate.HasValue
? expectedCloseDate.Value.AddDays(-_settings.VerificationReplyDays)
: DateTime.Now.AddDays(_settings.VerificationReplyDays);

var isPastDue = DateTime.Now.Date > dueDate.Date;
var replyByDate = dueDate.ToString("M/d/yy");
Expand Down
24 changes: 7 additions & 17 deletions web/Areas/RAPS/Controllers/RAPSController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,10 @@ public async Task<IActionResult> RoleMembers(string instance, int RoleId)
{
return NotFound();
}
if (_securityService.IsAllowedTo("EditRoleMembership", instance, Role))
{
return View("~/Areas/RAPS/Views/Roles/Members.cshtml");
}
else
{
//TODO: Should probably have a deny access helper function that writes logs and sets view
return View("~/Views/Home/403.cshtml");
}
//TODO: Should probably have a deny access helper function that writes logs and sets view
Comment thread
rlorenzo marked this conversation as resolved.
return _securityService.IsAllowedTo("EditRoleMembership", instance, Role)
? View("~/Areas/RAPS/Views/Roles/Members.cshtml")
: View("~/Views/Home/403.cshtml");
}

/// <summary>
Expand Down Expand Up @@ -356,14 +351,9 @@ public async Task<IActionResult> RolePermissions(int roleId)
[Route("/[area]/{Instance}/[action]")]
public async Task<IActionResult> RolePermissionsComparison(string instance)
{
if (_securityService.IsAllowedTo("EditRoleMembership", instance))
{
return await Task.Run(() => View("~/Areas/RAPS/Views/Roles/PermissionComparison.cshtml"));
}
else
{
return await Task.Run(() => View("~/Views/Home/403.cshtml"));
}
return _securityService.IsAllowedTo("EditRoleMembership", instance)
? await Task.Run(() => View("~/Areas/RAPS/Views/Roles/PermissionComparison.cshtml"))
: await Task.Run(() => View("~/Views/Home/403.cshtml"));
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion web/Areas/RAPS/Services/UinformService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ private static string GetAuthSignature(HttpMethod method, string publicKey, int
//take "{METHOD}:{epochTime}:{publicKey}" and sign it with the privateKey, then convert to base64
if (!string.IsNullOrEmpty(publicKey) && !string.IsNullOrEmpty(privateKey))
{
string toSign = method.Method.ToUpper() + ":" + epochTime.ToString() + ":" + publicKey;
string toSign = method.Method.ToUpper() + ":" + epochTime + ":" + publicKey;
// Legacy API requires HMACSHA1 - third-party system constraint
#pragma warning disable CA5350 // Do Not Use Weak Cryptographic Algorithms
using var sha1 = new HMACSHA1(Encoding.ASCII.GetBytes(privateKey));
Expand Down
6 changes: 3 additions & 3 deletions web/Areas/Students/Services/GradYearClassLevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ static public Tuple<int, string> GetTermCodeAndClassLevelForGradYear(int gradYea
switch (termPart)
{
case 2:
termAndClassLevel = Tuple.Create(currentTerm, "V" + (4 - (gradYear - termYear)).ToString());
termAndClassLevel = Tuple.Create(currentTerm, "V" + (4 - (gradYear - termYear)));
break;
case 9:
termAndClassLevel = Tuple.Create(currentTerm, "V" + (5 - (gradYear - termYear)).ToString());
termAndClassLevel = Tuple.Create(currentTerm, "V" + (5 - (gradYear - termYear)));
break;
case 4:
if (gradYear - termYear == 1)
Expand All @@ -66,7 +66,7 @@ static public Tuple<int, string> GetTermCodeAndClassLevelForGradYear(int gradYea
}
else
{
termAndClassLevel = Tuple.Create((termYear * 100) + 9, "V" + (5 - (gradYear - termYear)).ToString());
termAndClassLevel = Tuple.Create((termYear * 100) + 9, "V" + (5 - (gradYear - termYear)));
}
break;
}
Expand Down
26 changes: 6 additions & 20 deletions web/Classes/HttpHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@ public static class HttpHelper
private static IDataProtectionProvider? dataProtectionProvider;

/// <summary>
/// Helper functions constructor (gets injected with the memeory cache object)
/// Helper functions constructor (gets injected with the memory cache object)
/// </summary>
/// <param name="memoryCache"></param>
public static void Configure(IMemoryCache? memoryCache, IConfiguration? configurationSettings, IWebHostEnvironment env, IHttpContextAccessor? httpContextAccessor, IAuthorizationService? authorizationService, IDataProtectionProvider? dataProtectionProvider)
public static void Configure(IMemoryCache? memoryCache, IConfiguration? configurationSettings, IWebHostEnvironment env, IHttpContextAccessor? contextAccessor, IAuthorizationService? authzService, IDataProtectionProvider? dataProtection)
{
Cache = memoryCache;
Settings = configurationSettings;
Environment = env;
HttpHelper.httpContextAccessor = httpContextAccessor;
HttpHelper.authorizationService = authorizationService;
HttpHelper.dataProtectionProvider = dataProtectionProvider;
httpContextAccessor = contextAccessor;
authorizationService = authzService;
dataProtectionProvider = dataProtection;
}

/// <summary>
Expand All @@ -44,20 +43,7 @@ public static void Configure(IMemoryCache? memoryCache, IConfiguration? configur
/// <summary>
/// Get the current HttpContext
/// </summary>
public static HttpContext? HttpContext
{
get
{
if (httpContextAccessor != null)
{
return httpContextAccessor.HttpContext;
}
else
{
return null;
}
}
}
public static HttpContext? HttpContext => httpContextAccessor?.HttpContext;

/// <summary>
/// Get the current memory cache
Expand Down
40 changes: 5 additions & 35 deletions web/Classes/UserHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,7 @@ on role.RoleId equals memberRoles.RoleId
select role).ToList();
});

if (result != null)
{
return result;
}
else
{
return new List<TblRole>();
}

return result ?? new List<TblRole>();
}
else
{
Expand Down Expand Up @@ -149,15 +141,7 @@ on permission.PermissionId equals memberPermissions.PermissionId
select permission).ToList();
});

if (result != null)
{
return result;
}
else
{
return new List<TblPermission>();
}

return result ?? new List<TblPermission>();
}
else
{
Expand Down Expand Up @@ -274,18 +258,11 @@ public bool HasPermission(RAPSContext? rapsContext, AaudUser? user, string permi
}
else if (HttpHelper.Cache != null && aaudContext != null)
{
var fallbackUser = user;
user = HttpHelper.Cache.GetOrCreate("AaudUser-" + userLoginId, entry =>
{
AaudUser? aaudUser = aaudContext.AaudUsers.FirstOrDefault(m => m.LoginId == loginId);
if (aaudUser != null)
{
return aaudUser;
}
else
{
return user;
}

return aaudUser ?? fallbackUser;
});

return user;
Expand Down Expand Up @@ -342,14 +319,7 @@ public bool HasPermission(RAPSContext? rapsContext, AaudUser? user, string permi
?? (AAUDContext?)HttpHelper.HttpContext?.RequestServices.GetService(typeof(AAUDContext));
AaudUser? trueUser = GetByLoginId(aaudContext, claims?.FirstOrDefault(claim => claim.Type == ClaimTypes.NameIdentifier)?.Value);

if (trueUser != null)
{
return trueUser;
}
else
{
return GetCurrentUser();
}
return trueUser ?? GetCurrentUser();


}
Expand Down
2 changes: 1 addition & 1 deletion web/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ private async Task<IActionResult> AuthenticateCasLogin(string? ticket, string? r
// uncommenting this line will log what CAS is sending. When the user in question logs in while trying to access our site
if (string.IsNullOrEmpty(validatedUserName))
{
HttpHelper.Logger.Log(NLog.LogLevel.Warn, "No username. CAS response: " + doc.ToString());
HttpHelper.Logger.Log(NLog.LogLevel.Warn, "No username. CAS response: " + LogSanitizer.SanitizeString(doc.ToString()));
}

if (!string.IsNullOrEmpty(validatedUserName))
Expand Down
Loading