Skip to content

Commit

Permalink
analizators/U2U1115
Browse files Browse the repository at this point in the history
  • Loading branch information
SuhorukovAnton committed Jan 17, 2022
1 parent 516cd2f commit 0ee1a35
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 40 deletions.
4 changes: 2 additions & 2 deletions common/ASC.Api.Core/Auth/ConfirmAuthHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected override Task<AuthenticateResult> HandleAuthenticateAsync()
{
return SecurityContext.IsAuthenticated
? Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(Context.User, new AuthenticationProperties(), Scheme.Name)))
: Task.FromResult(AuthenticateResult.Fail(new AuthenticationException(HttpStatusCode.Unauthorized.ToString())));
: Task.FromResult(AuthenticateResult.Fail(new AuthenticationException(nameof(HttpStatusCode.Unauthorized))));
}

EmailValidationKeyProvider.ValidationResult checkKeyResult;
Expand Down Expand Up @@ -105,7 +105,7 @@ protected override Task<AuthenticateResult> HandleAuthenticateAsync()
var result = checkKeyResult switch
{
EmailValidationKeyProvider.ValidationResult.Ok => AuthenticateResult.Success(new AuthenticationTicket(Context.User, new AuthenticationProperties(), Scheme.Name)),
_ => AuthenticateResult.Fail(new AuthenticationException(HttpStatusCode.Unauthorized.ToString()))
_ => AuthenticateResult.Fail(new AuthenticationException(nameof(HttpStatusCode.Unauthorized)))
};

return Task.FromResult(result);
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Api.Core/Auth/CookieAuthHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected override Task<AuthenticateResult> HandleAuthenticateAsync()
return Task.FromResult(
result ?
AuthenticateResult.Success(new AuthenticationTicket(Context.User, new AuthenticationProperties(), Scheme.Name)) :
AuthenticateResult.Fail(new AuthenticationException(HttpStatusCode.Unauthorized.ToString()))
AuthenticateResult.Fail(new AuthenticationException(nameof(HttpStatusCode.Unauthorized)))
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions common/ASC.Data.Backup.Core/BackupAjaxHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ private void DemandPermissionsBackup()
{
PermissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

if (!SetupInfo.IsVisibleSettings(ManagementType.Backup.ToString()))
if (!SetupInfo.IsVisibleSettings(nameof(ManagementType.Backup)))
throw new BillingException(Resource.ErrorNotAllowedOption, "Backup");
}

Expand Down Expand Up @@ -319,7 +319,7 @@ private void DemandPermissionsTransfer()
PermissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

var currentUser = UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
if (!SetupInfo.IsVisibleSettings(ManagementType.Migration.ToString())
if (!SetupInfo.IsVisibleSettings(nameof(ManagementType.Migration))
|| !currentUser.IsOwner(TenantManager.GetCurrentTenant())
|| !SetupInfo.IsSecretEmail(currentUser.Email) && !TenantExtra.GetTenantQuota().HasMigration)
throw new InvalidOperationException(Resource.ErrorNotAllowedOption);
Expand Down
12 changes: 6 additions & 6 deletions common/services/ASC.ApiSystem/Classes/AuthHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected override Task<AuthenticateResult> HandleAuthenticateAsync()
{
Log.Debug("Auth header is NULL");

return Task.FromResult(AuthenticateResult.Fail(new AuthenticationException(HttpStatusCode.Unauthorized.ToString())));
return Task.FromResult(AuthenticateResult.Fail(new AuthenticationException(nameof(HttpStatusCode.Unauthorized))));
}

var substring = "ASC";
Expand All @@ -118,7 +118,7 @@ protected override Task<AuthenticateResult> HandleAuthenticateAsync()
{
Log.DebugFormat("Auth failed: invalid token {0}.", header);

return Task.FromResult(AuthenticateResult.Fail(new AuthenticationException(HttpStatusCode.Unauthorized.ToString())));
return Task.FromResult(AuthenticateResult.Fail(new AuthenticationException(nameof(HttpStatusCode.Unauthorizednameof())));
}

var pkey = splitted[0];
Expand All @@ -137,7 +137,7 @@ protected override Task<AuthenticateResult> HandleAuthenticateAsync()
{
Log.DebugFormat("Auth failed: invalid timesatmp {0}, now {1}.", timestamp, DateTime.UtcNow);

return Task.FromResult(AuthenticateResult.Fail(new AuthenticationException(HttpStatusCode.Forbidden.ToString())));
return Task.FromResult(AuthenticateResult.Fail(new AuthenticationException(nameof(HttpStatusCode.Forbidden))));
}
}

Expand All @@ -150,21 +150,21 @@ protected override Task<AuthenticateResult> HandleAuthenticateAsync()
{
Log.DebugFormat("Auth failed: invalid token {0}, expect {1} or {2}.", orighash, WebEncoders.Base64UrlEncode(hash), Convert.ToBase64String(hash));

return Task.FromResult(AuthenticateResult.Fail(new AuthenticationException(HttpStatusCode.Forbidden.ToString())));
return Task.FromResult(AuthenticateResult.Fail(new AuthenticationException(nameof(HttpStatusCode.Forbidden))));
}
}
else
{
Log.DebugFormat("Auth failed: invalid auth header. Sheme: {0}, parameter: {1}.", Scheme.Name, header);

return Task.FromResult(AuthenticateResult.Fail(new AuthenticationException(HttpStatusCode.Forbidden.ToString())));
return Task.FromResult(AuthenticateResult.Fail(new AuthenticationException(nameof(HttpStatusCode.Forbidden))));
}
}
catch (Exception ex)
{
Log.Error(ex);

return Task.FromResult(AuthenticateResult.Fail(new AuthenticationException(HttpStatusCode.InternalServerError.ToString())));
return Task.FromResult(AuthenticateResult.Fail(new AuthenticationException(nameof(HttpStatusCode.InternalServerError))));
}
var identity = new ClaimsIdentity( Scheme.Name);

Expand Down
14 changes: 7 additions & 7 deletions common/services/ASC.ElasticSearch/Engine/BaseIndexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -426,21 +426,21 @@ IPromise<IAnalyzers> analyzers(AnalyzersDescriptor b)
foreach (var c in Enum.GetNames(typeof(Analyzer)))
{
var c1 = c;
b.Custom(c1 + "custom", ca => ca.Tokenizer(c1).Filters(Filter.lowercase.ToString()).CharFilters(CharFilter.io.ToString()));
b.Custom(c1 + "custom", ca => ca.Tokenizer(c1).Filters(nameof(Filter.lowercase)).CharFilters(nameof(CharFilter.io)));
}

foreach (var c in Enum.GetNames(typeof(CharFilter)))
{
if (c == CharFilter.io.ToString()) continue;
if (c == nameof(CharFilter.io)) continue;

var charFilters = new List<string>() { CharFilter.io.ToString(), c };
var charFilters = new List<string>() { nameof(CharFilter.io), c };
var c1 = c;
b.Custom(c1 + "custom", ca => ca.Tokenizer(Analyzer.whitespace.ToString()).Filters(Filter.lowercase.ToString()).CharFilters(charFilters));
b.Custom(c1 + "custom", ca => ca.Tokenizer(nameof(Analyzer.whitespace)).Filters(nameof(Filter.lowercase)).CharFilters(charFilters));
}

if (data is ISearchItemDocument)
{
b.Custom("document", ca => ca.Tokenizer(Analyzer.whitespace.ToString()).Filters(Filter.lowercase.ToString()).CharFilters(CharFilter.io.ToString()));
b.Custom("document", ca => ca.Tokenizer(nameof(Analyzer.whitespace)).Filters(nameof(Filter.lowercase)).CharFilters(nameof(CharFilter.io)));
}

return b;
Expand All @@ -451,8 +451,8 @@ IPromise<IAnalyzers> analyzers(AnalyzersDescriptor b)
c.Map<T>(m => m.AutoMap())
.Settings(r => r.Analysis(a =>
a.Analyzers(analyzers)
.CharFilters(d => d.HtmlStrip(CharFilter.html.ToString())
.Mapping(CharFilter.io.ToString(), m => m.Mappings("ё => е", "Ё => Е"))))));
.CharFilters(d => d.HtmlStrip(nameof(CharFilter.html))
.Mapping(nameof(CharFilter.io), m => m.Mappings("ё => е", "Ё => Е"))))));

IsExist = true;
}
Expand Down
2 changes: 1 addition & 1 deletion products/ASC.CRM/Server/Api/UtilsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public String UpdateOrganisationSettingsCompanyAddress(String street, String cit

var companyAddress = JsonSerializer.Serialize(new
{
type = AddressCategory.Billing.ToString(),
type = nameof(AddressCategory.Billing),
street,
city,
state,
Expand Down
2 changes: 1 addition & 1 deletion products/ASC.CRM/Server/Api/VoipController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public object GetVoipSettings()
return new { queue = number.Settings.Queue, pause = number.Settings.Pause };
}

var files = _storageFactory.GetStorage("", "crm").ListFiles("voip", "default/" + AudioType.Queue.ToString().ToLower(), "*.*", true);
var files = _storageFactory.GetStorage("", "crm").ListFiles("voip", "default/" + nameof(AudioType.Queue).ToLower(), "*.*", true);
var file = files.FirstOrDefault();
return new { queue = new Queue(null, "Default", 5, file != null ? _commonLinkUtility.GetFullAbsolutePath(file.ToString()) : "", 5), pause = false };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ private Ical.Net.Calendar getEventIcs(int alert, CalendarWrapper calendar, Calen
{
evt.End = new CalDateTime(evt.End.AddDays(1));
}
evt.Status = EventStatus.Confirmed.ToString();
evt.Status = nameof(EventStatus.Confirmed);
if (alert > 0)
{
evt.Alarms.Add(
Expand Down Expand Up @@ -3958,7 +3958,7 @@ int tenantId
else if (calendarId == "crm_calendar" || calendarId.Contains("Project_"))
{
e.Created = null;
e.Status = EventStatus.Confirmed.ToString();
e.Status = nameof(EventStatus.Confirmed);
}

calendar.Events.Clear();
Expand Down
6 changes: 3 additions & 3 deletions products/ASC.Files/Core/Helpers/DocuSignHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ private string CreateEnvelope(string accountId, Document document, DocuSignData
{
//new EnvelopeEvent {EnvelopeEventStatusCode = DocuSignStatus.Sent.ToString()},
//new EnvelopeEvent {EnvelopeEventStatusCode = DocuSignStatus.Delivered.ToString()},
new EnvelopeEvent {EnvelopeEventStatusCode = DocuSignStatus.Completed.ToString()},
new EnvelopeEvent {EnvelopeEventStatusCode = DocuSignStatus.Declined.ToString()},
new EnvelopeEvent {EnvelopeEventStatusCode = DocuSignStatus.Voided.ToString()},
new EnvelopeEvent {EnvelopeEventStatusCode = nameof(DocuSignStatus.Completed)},
new EnvelopeEvent {EnvelopeEventStatusCode = nameof(DocuSignStatus.Declined)},
new EnvelopeEvent {EnvelopeEventStatusCode = nameof(DocuSignStatus.Voided)},
},
IncludeDocumentFields = "true",
//RecipientEvents = new List<RecipientEvent>
Expand Down
4 changes: 2 additions & 2 deletions web/ASC.Web.Api/Controllers/CapabilitiesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public CapabilitiesData GetPortalCapabilities()

try
{
if (SetupInfo.IsVisibleSettings(ManagementType.LdapSettings.ToString())
if (SetupInfo.IsVisibleSettings(nameof(ManagementType.LdapSettings))
&& (!CoreBaseSettings.Standalone
|| TenantManager.GetTenantQuota(TenantManager.GetCurrentTenant().TenantId).Ldap))
{
Expand Down Expand Up @@ -108,7 +108,7 @@ public CapabilitiesData GetPortalCapabilities()

try
{
if (SetupInfo.IsVisibleSettings(ManagementType.SingleSignOnSettings.ToString())
if (SetupInfo.IsVisibleSettings(nameof(ManagementType.SingleSignOnSettings))
&& TenantManager.GetTenantQuota(TenantManager.GetCurrentTenant().TenantId).Sso)
{
//var settings = SettingsManager.Load<SsoSettingsV2>();
Expand Down
12 changes: 6 additions & 6 deletions web/ASC.Web.Api/Controllers/SecurityController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class SecurityController : ControllerBase
[Read("audit/login/last")]
public IEnumerable<EventWrapper> GetLastLoginEvents()
{
if (!SetupInfo.IsVisibleSettings(ManagementType.LoginHistory.ToString()))
if (!SetupInfo.IsVisibleSettings(nameof(ManagementType.LoginHistory)))
{
throw new BillingException(Resource.ErrorNotAllowedOption, "Audit");
}
Expand All @@ -73,7 +73,7 @@ public IEnumerable<EventWrapper> GetLastLoginEvents()
[Read("audit/events/last")]
public IEnumerable<EventWrapper> GetLastAuditEvents()
{
if (!SetupInfo.IsVisibleSettings(ManagementType.AuditTrail.ToString()))
if (!SetupInfo.IsVisibleSettings(nameof(ManagementType.AuditTrail)))
{
throw new BillingException(Resource.ErrorNotAllowedOption, "Audit");
}
Expand All @@ -90,7 +90,7 @@ public object CreateLoginHistoryReport()

var tenantId = TenantManager.GetCurrentTenant().TenantId;

if (!TenantExtra.GetTenantQuota().Audit || !SetupInfo.IsVisibleSettings(ManagementType.LoginHistory.ToString()))
if (!TenantExtra.GetTenantQuota().Audit || !SetupInfo.IsVisibleSettings(nameof(ManagementType.LoginHistory)))
throw new BillingException(Resource.ErrorNotAllowedOption, "Audit");

var settings = SettingsManager.LoadForTenant<TenantAuditSettings>(TenantManager.GetCurrentTenant().TenantId);
Expand All @@ -113,7 +113,7 @@ public object CreateAuditTrailReport()

var tenantId = TenantManager.GetCurrentTenant().TenantId;

if (!TenantExtra.GetTenantQuota().Audit || !SetupInfo.IsVisibleSettings(ManagementType.AuditTrail.ToString()))
if (!TenantExtra.GetTenantQuota().Audit || !SetupInfo.IsVisibleSettings(nameof(ManagementType.AuditTrail)))
throw new BillingException(Resource.ErrorNotAllowedOption, "Audit");

var settings = SettingsManager.LoadForTenant<TenantAuditSettings>(TenantManager.GetCurrentTenant().TenantId);
Expand All @@ -133,7 +133,7 @@ public object CreateAuditTrailReport()
[Read("audit/settings/lifetime")]
public TenantAuditSettings GetAuditSettings()
{
if (!SetupInfo.IsVisibleSettings(ManagementType.LoginHistory.ToString()))
if (!SetupInfo.IsVisibleSettings(nameof(ManagementType.LoginHistory)))
{
throw new BillingException(Resource.ErrorNotAllowedOption, "Audit");
}
Expand All @@ -158,7 +158,7 @@ public TenantAuditSettings SetAuditSettingsFromForm([FromForm] TenantAuditSettin

private TenantAuditSettings SetAuditSettings(TenantAuditSettingsWrapper wrapper)
{
if (!TenantExtra.GetTenantQuota().Audit || !SetupInfo.IsVisibleSettings(ManagementType.LoginHistory.ToString()))
if (!TenantExtra.GetTenantQuota().Audit || !SetupInfo.IsVisibleSettings(nameof(ManagementType.LoginHistory)))
throw new BillingException(Resource.ErrorNotAllowedOption, "Audit");

PermissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
Expand Down
10 changes: 5 additions & 5 deletions web/ASC.Web.Api/Controllers/SettingsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1188,10 +1188,10 @@ public object GetWhiteLabelSizes()
return
new[]
{
new {type = (int)WhiteLabelLogoTypeEnum.LightSmall, name = WhiteLabelLogoTypeEnum.LightSmall.ToString(), height = TenantWhiteLabelSettings.logoLightSmallSize.Height, width = TenantWhiteLabelSettings.logoLightSmallSize.Width},
new {type = (int)WhiteLabelLogoTypeEnum.Dark, name = WhiteLabelLogoTypeEnum.Dark.ToString(), height = TenantWhiteLabelSettings.logoDarkSize.Height, width = TenantWhiteLabelSettings.logoDarkSize.Width},
new {type = (int)WhiteLabelLogoTypeEnum.Favicon, name = WhiteLabelLogoTypeEnum.Favicon.ToString(), height = TenantWhiteLabelSettings.logoFaviconSize.Height, width = TenantWhiteLabelSettings.logoFaviconSize.Width},
new {type = (int)WhiteLabelLogoTypeEnum.DocsEditor, name = WhiteLabelLogoTypeEnum.DocsEditor.ToString(), height = TenantWhiteLabelSettings.logoDocsEditorSize.Height, width = TenantWhiteLabelSettings.logoDocsEditorSize.Width}
new {type = (int)WhiteLabelLogoTypeEnum.LightSmall, name = nameof(WhiteLabelLogoTypeEnum.LightSmall), height = TenantWhiteLabelSettings.logoLightSmallSize.Height, width = TenantWhiteLabelSettings.logoLightSmallSize.Width},
new {type = (int)WhiteLabelLogoTypeEnum.Dark, name = nameof(WhiteLabelLogoTypeEnum.Dark), height = TenantWhiteLabelSettings.logoDarkSize.Height, width = TenantWhiteLabelSettings.logoDarkSize.Width},
new {type = (int)WhiteLabelLogoTypeEnum.Favicon, name = nameof(WhiteLabelLogoTypeEnum.Favicon), height = TenantWhiteLabelSettings.logoFaviconSize.Height, width = TenantWhiteLabelSettings.logoFaviconSize.Width},
new {type = (int)WhiteLabelLogoTypeEnum.DocsEditor, name = nameof(WhiteLabelLogoTypeEnum.DocsEditor), height = TenantWhiteLabelSettings.logoDocsEditorSize.Height, width = TenantWhiteLabelSettings.logoDocsEditorSize.Width}
};
}

Expand Down Expand Up @@ -2838,7 +2838,7 @@ private bool SaveAuthKeys(AuthServiceModel model)
PermissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

var saveAvailable = CoreBaseSettings.Standalone || TenantManager.GetTenantQuota(TenantManager.GetCurrentTenant().TenantId).ThirdParty;
if (!SetupInfo.IsVisibleSettings(ManagementType.ThirdPartyAuthorization.ToString())
if (!SetupInfo.IsVisibleSettings(nameof(ManagementType.ThirdPartyAuthorization))
|| !saveAvailable)
throw new BillingException(Resource.ErrorNotAllowedOption, "ThirdPartyAuthorization");

Expand Down
2 changes: 1 addition & 1 deletion web/ASC.Web.Api/Controllers/SmtpSettingsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private static SmtpSettingsWrapper ToSmtpSettings(SmtpSettings settingsConfig, b

private static void CheckSmtpPermissions()
{
if (!SetupInfo.IsVisibleSettings(ManagementType.SmtpSettings.ToString()))
if (!SetupInfo.IsVisibleSettings(nameof(ManagementType.SmtpSettings)))
{
throw new BillingException(Resource.ErrorNotAllowedOption, "Smtp");
}
Expand Down
2 changes: 1 addition & 1 deletion web/ASC.Web.Core/PrivacyRoomSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static void SetEnabled(TenantManager tenantManager, SettingsManager setti

public static bool IsAvailable(TenantManager tenantManager)
{
return SetupInfo.IsVisibleSettings(ManagementType.PrivacyRoom.ToString())
return SetupInfo.IsVisibleSettings(nameof(ManagementType.PrivacyRoom))
&& tenantManager.GetTenantQuota(tenantManager.GetCurrentTenant().TenantId).PrivacyRoom;
}
}
Expand Down

0 comments on commit 0ee1a35

Please sign in to comment.