analizators/U2U1115

This commit is contained in:
Anton Suhorukov 2022-01-17 11:22:52 +03:00
parent 516cd2fd80
commit 0ee1a35424
14 changed files with 40 additions and 40 deletions

View File

@ -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);

View File

@ -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)))
);
}
}

View File

@ -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);

View File

@ -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);

View File

@ -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<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;
@ -451,8 +451,8 @@ namespace ASC.ElasticSearch
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;
}

View File

@ -304,7 +304,7 @@ namespace ASC.CRM.Api
var companyAddress = JsonSerializer.Serialize(new
{
type = AddressCategory.Billing.ToString(),
type = nameof(AddressCategory.Billing),
street,
city,
state,

View File

@ -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 };
}

View File

@ -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();

View File

@ -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<RecipientEvent>

View File

@ -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<SsoSettingsV2>();

View File

@ -60,7 +60,7 @@ namespace ASC.Web.Api.Controllers
[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");
}
@ -73,7 +73,7 @@ namespace ASC.Web.Api.Controllers
[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");
}
@ -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<TenantAuditSettings>(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<TenantAuditSettings>(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);

View File

@ -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");

View File

@ -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");
}

View File

@ -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;
}
}