From 0ee1a354248cf0abcf250116dc7332e85488a337 Mon Sep 17 00:00:00 2001 From: SuhorukovAnton Date: Mon, 17 Jan 2022 11:22:52 +0300 Subject: [PATCH] analizators/U2U1115 --- common/ASC.Api.Core/Auth/ConfirmAuthHandler.cs | 4 ++-- common/ASC.Api.Core/Auth/CookieAuthHandler.cs | 2 +- common/ASC.Data.Backup.Core/BackupAjaxHandler.cs | 4 ++-- .../services/ASC.ApiSystem/Classes/AuthHandler.cs | 12 ++++++------ .../ASC.ElasticSearch/Engine/BaseIndexer.cs | 14 +++++++------- products/ASC.CRM/Server/Api/UtilsController.cs | 2 +- products/ASC.CRM/Server/Api/VoipController.cs | 2 +- .../Server/Controllers/CalendarController.cs | 4 ++-- products/ASC.Files/Core/Helpers/DocuSignHelper.cs | 6 +++--- .../Controllers/CapabilitiesController.cs | 4 ++-- web/ASC.Web.Api/Controllers/SecurityController.cs | 12 ++++++------ web/ASC.Web.Api/Controllers/SettingsController.cs | 10 +++++----- .../Controllers/SmtpSettingsController.cs | 2 +- web/ASC.Web.Core/PrivacyRoomSettings.cs | 2 +- 14 files changed, 40 insertions(+), 40 deletions(-) diff --git a/common/ASC.Api.Core/Auth/ConfirmAuthHandler.cs b/common/ASC.Api.Core/Auth/ConfirmAuthHandler.cs index 9b4d611e27..4b3bf08b28 100644 --- a/common/ASC.Api.Core/Auth/ConfirmAuthHandler.cs +++ b/common/ASC.Api.Core/Auth/ConfirmAuthHandler.cs @@ -53,7 +53,7 @@ namespace ASC.Api.Core.Auth { 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; @@ -105,7 +105,7 @@ namespace ASC.Api.Core.Auth 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); diff --git a/common/ASC.Api.Core/Auth/CookieAuthHandler.cs b/common/ASC.Api.Core/Auth/CookieAuthHandler.cs index 1316ab3185..13590079a6 100644 --- a/common/ASC.Api.Core/Auth/CookieAuthHandler.cs +++ b/common/ASC.Api.Core/Auth/CookieAuthHandler.cs @@ -50,7 +50,7 @@ namespace ASC.Api.Core.Auth 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))) ); } } diff --git a/common/ASC.Data.Backup.Core/BackupAjaxHandler.cs b/common/ASC.Data.Backup.Core/BackupAjaxHandler.cs index 694fd05bf9..831849fcb5 100644 --- a/common/ASC.Data.Backup.Core/BackupAjaxHandler.cs +++ b/common/ASC.Data.Backup.Core/BackupAjaxHandler.cs @@ -233,7 +233,7 @@ namespace ASC.Data.Backup { PermissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings); - if (!SetupInfo.IsVisibleSettings(ManagementType.Backup.ToString())) + if (!SetupInfo.IsVisibleSettings(nameof(ManagementType.Backup))) throw new BillingException(Resource.ErrorNotAllowedOption, "Backup"); } @@ -319,7 +319,7 @@ namespace ASC.Data.Backup 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); diff --git a/common/services/ASC.ApiSystem/Classes/AuthHandler.cs b/common/services/ASC.ApiSystem/Classes/AuthHandler.cs index d3119f2701..607ea5d446 100644 --- a/common/services/ASC.ApiSystem/Classes/AuthHandler.cs +++ b/common/services/ASC.ApiSystem/Classes/AuthHandler.cs @@ -105,7 +105,7 @@ namespace ASC.ApiSystem.Classes { 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"; @@ -118,7 +118,7 @@ namespace ASC.ApiSystem.Classes { 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]; @@ -137,7 +137,7 @@ namespace ASC.ApiSystem.Classes { 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)))); } } @@ -150,21 +150,21 @@ namespace ASC.ApiSystem.Classes { 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); diff --git a/common/services/ASC.ElasticSearch/Engine/BaseIndexer.cs b/common/services/ASC.ElasticSearch/Engine/BaseIndexer.cs index c5df10a50f..59ce729c99 100644 --- a/common/services/ASC.ElasticSearch/Engine/BaseIndexer.cs +++ b/common/services/ASC.ElasticSearch/Engine/BaseIndexer.cs @@ -426,21 +426,21 @@ namespace ASC.ElasticSearch 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() { CharFilter.io.ToString(), c }; + var charFilters = new List() { 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; @@ -451,8 +451,8 @@ namespace ASC.ElasticSearch c.Map(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; } diff --git a/products/ASC.CRM/Server/Api/UtilsController.cs b/products/ASC.CRM/Server/Api/UtilsController.cs index cb8a780de1..63027453bd 100644 --- a/products/ASC.CRM/Server/Api/UtilsController.cs +++ b/products/ASC.CRM/Server/Api/UtilsController.cs @@ -304,7 +304,7 @@ namespace ASC.CRM.Api var companyAddress = JsonSerializer.Serialize(new { - type = AddressCategory.Billing.ToString(), + type = nameof(AddressCategory.Billing), street, city, state, diff --git a/products/ASC.CRM/Server/Api/VoipController.cs b/products/ASC.CRM/Server/Api/VoipController.cs index 0e2dd31590..8272fb092f 100644 --- a/products/ASC.CRM/Server/Api/VoipController.cs +++ b/products/ASC.CRM/Server/Api/VoipController.cs @@ -390,7 +390,7 @@ namespace ASC.CRM.Api 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 }; } diff --git a/products/ASC.Calendar/Server/Controllers/CalendarController.cs b/products/ASC.Calendar/Server/Controllers/CalendarController.cs index 6cae096572..cc16401996 100644 --- a/products/ASC.Calendar/Server/Controllers/CalendarController.cs +++ b/products/ASC.Calendar/Server/Controllers/CalendarController.cs @@ -926,7 +926,7 @@ namespace ASC.Calendar.Controllers { evt.End = new CalDateTime(evt.End.AddDays(1)); } - evt.Status = EventStatus.Confirmed.ToString(); + evt.Status = nameof(EventStatus.Confirmed); if (alert > 0) { evt.Alarms.Add( @@ -3958,7 +3958,7 @@ namespace ASC.Calendar.Controllers else if (calendarId == "crm_calendar" || calendarId.Contains("Project_")) { e.Created = null; - e.Status = EventStatus.Confirmed.ToString(); + e.Status = nameof(EventStatus.Confirmed); } calendar.Events.Clear(); diff --git a/products/ASC.Files/Core/Helpers/DocuSignHelper.cs b/products/ASC.Files/Core/Helpers/DocuSignHelper.cs index 2246221241..13f24d05a9 100644 --- a/products/ASC.Files/Core/Helpers/DocuSignHelper.cs +++ b/products/ASC.Files/Core/Helpers/DocuSignHelper.cs @@ -302,9 +302,9 @@ namespace ASC.Web.Files.Helpers { //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 diff --git a/web/ASC.Web.Api/Controllers/CapabilitiesController.cs b/web/ASC.Web.Api/Controllers/CapabilitiesController.cs index 20550e58e1..9a4f50d326 100644 --- a/web/ASC.Web.Api/Controllers/CapabilitiesController.cs +++ b/web/ASC.Web.Api/Controllers/CapabilitiesController.cs @@ -77,7 +77,7 @@ namespace ASC.Web.Api.Controllers try { - if (SetupInfo.IsVisibleSettings(ManagementType.LdapSettings.ToString()) + if (SetupInfo.IsVisibleSettings(nameof(ManagementType.LdapSettings)) && (!CoreBaseSettings.Standalone || TenantManager.GetTenantQuota(TenantManager.GetCurrentTenant().TenantId).Ldap)) { @@ -108,7 +108,7 @@ namespace ASC.Web.Api.Controllers try { - if (SetupInfo.IsVisibleSettings(ManagementType.SingleSignOnSettings.ToString()) + if (SetupInfo.IsVisibleSettings(nameof(ManagementType.SingleSignOnSettings)) && TenantManager.GetTenantQuota(TenantManager.GetCurrentTenant().TenantId).Sso) { //var settings = SettingsManager.Load(); diff --git a/web/ASC.Web.Api/Controllers/SecurityController.cs b/web/ASC.Web.Api/Controllers/SecurityController.cs index 0b9a81ca5c..b8d0f40bd5 100644 --- a/web/ASC.Web.Api/Controllers/SecurityController.cs +++ b/web/ASC.Web.Api/Controllers/SecurityController.cs @@ -60,7 +60,7 @@ namespace ASC.Web.Api.Controllers [Read("audit/login/last")] public IEnumerable GetLastLoginEvents() { - if (!SetupInfo.IsVisibleSettings(ManagementType.LoginHistory.ToString())) + if (!SetupInfo.IsVisibleSettings(nameof(ManagementType.LoginHistory))) { throw new BillingException(Resource.ErrorNotAllowedOption, "Audit"); } @@ -73,7 +73,7 @@ namespace ASC.Web.Api.Controllers [Read("audit/events/last")] public IEnumerable GetLastAuditEvents() { - if (!SetupInfo.IsVisibleSettings(ManagementType.AuditTrail.ToString())) + if (!SetupInfo.IsVisibleSettings(nameof(ManagementType.AuditTrail))) { throw new BillingException(Resource.ErrorNotAllowedOption, "Audit"); } @@ -90,7 +90,7 @@ namespace ASC.Web.Api.Controllers 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(TenantManager.GetCurrentTenant().TenantId); @@ -113,7 +113,7 @@ namespace ASC.Web.Api.Controllers 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(TenantManager.GetCurrentTenant().TenantId); @@ -133,7 +133,7 @@ namespace ASC.Web.Api.Controllers [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"); } @@ -158,7 +158,7 @@ namespace ASC.Web.Api.Controllers 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); diff --git a/web/ASC.Web.Api/Controllers/SettingsController.cs b/web/ASC.Web.Api/Controllers/SettingsController.cs index f563dd5e99..a1c50594de 100644 --- a/web/ASC.Web.Api/Controllers/SettingsController.cs +++ b/web/ASC.Web.Api/Controllers/SettingsController.cs @@ -1188,10 +1188,10 @@ namespace ASC.Api.Settings 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} }; } @@ -2838,7 +2838,7 @@ namespace ASC.Api.Settings 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"); diff --git a/web/ASC.Web.Api/Controllers/SmtpSettingsController.cs b/web/ASC.Web.Api/Controllers/SmtpSettingsController.cs index 6b040484b6..1476025ca0 100644 --- a/web/ASC.Web.Api/Controllers/SmtpSettingsController.cs +++ b/web/ASC.Web.Api/Controllers/SmtpSettingsController.cs @@ -231,7 +231,7 @@ namespace ASC.Api.Settings private static void CheckSmtpPermissions() { - if (!SetupInfo.IsVisibleSettings(ManagementType.SmtpSettings.ToString())) + if (!SetupInfo.IsVisibleSettings(nameof(ManagementType.SmtpSettings))) { throw new BillingException(Resource.ErrorNotAllowedOption, "Smtp"); } diff --git a/web/ASC.Web.Core/PrivacyRoomSettings.cs b/web/ASC.Web.Core/PrivacyRoomSettings.cs index eb5537bc97..e1cea08d23 100644 --- a/web/ASC.Web.Core/PrivacyRoomSettings.cs +++ b/web/ASC.Web.Core/PrivacyRoomSettings.cs @@ -67,7 +67,7 @@ namespace ASC.Web.Studio.Core public static bool IsAvailable(TenantManager tenantManager) { - return SetupInfo.IsVisibleSettings(ManagementType.PrivacyRoom.ToString()) + return SetupInfo.IsVisibleSettings(nameof(ManagementType.PrivacyRoom)) && tenantManager.GetTenantQuota(tenantManager.GetCurrentTenant().TenantId).PrivacyRoom; } }