Skip to content

Commit

Permalink
fix Bug 66027
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelbannov committed Jan 24, 2024
1 parent 73fd5e8 commit 16977d2
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions common/ASC.Data.Backup.Core/BackupAjaxHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ public async Task CheckAccessToFolderAsync<T>(T folderId)
public async Task CreateScheduleAsync(BackupStorageType storageType, Dictionary<string, string> storageParams, int backupsStored, CronParams cronParams)
{
await DemandPermissionsBackupAsync();

await DemandPermissionsAutoBackupAsync();

if (!SetupInfo.IsVisibleSettings("AutoBackup"))
{
throw new InvalidOperationException(Resource.ErrorNotAllowedOption);
Expand Down Expand Up @@ -238,7 +239,7 @@ public async Task<Schedule> GetScheduleAsync()
schedule.StorageParams = consumer.AdditionalKeys.ToDictionary(r => r, r => consumer[r]);
schedule.StorageParams.Add("module", "S3");

var Schedule = new CreateScheduleRequest
var scheduleRequest = new CreateScheduleRequest
{
TenantId = await _tenantManager.GetCurrentTenantIdAsync(),
Cron = schedule.CronParams.ToString(),
Expand All @@ -247,7 +248,7 @@ public async Task<Schedule> GetScheduleAsync()
StorageParams = schedule.StorageParams
};

await _backupService.CreateScheduleAsync(Schedule);
await _backupService.CreateScheduleAsync(scheduleRequest);

}
else if (response.StorageType != BackupStorageType.ThirdPartyConsumer)
Expand Down Expand Up @@ -314,37 +315,31 @@ public async Task StartRestoreAsync(string backupId, BackupStorageType storageTy
public async Task<BackupProgress> GetRestoreProgressAsync()
{
var tenant = await _tenantManager.GetCurrentTenantAsync();
var result = _backupService.GetRestoreProgress(tenant.Id);

return result;

return _backupService.GetRestoreProgress(tenant.Id);
}

public async Task DemandPermissionsRestoreAsync()
private async Task DemandPermissionsRestoreAsync()
{
await _permissionContext.DemandPermissionsAsync(SecurityConstants.EditPortalSettings);

var quota = await _tenantManager.GetTenantQuotaAsync(await _tenantManager.GetCurrentTenantIdAsync());
if (!SetupInfo.IsVisibleSettings("Restore") ||
(!_coreBaseSettings.Standalone && !quota.AutoBackupRestore))
if (!SetupInfo.IsVisibleSettings("Restore") || (!_coreBaseSettings.Standalone && !quota.AutoBackupRestore))
{
throw new BillingException(Resource.ErrorNotAllowedOption, "Restore");
}


if (!_coreBaseSettings.Standalone
&& (!SetupInfo.IsVisibleSettings("Restore")
|| !quota.AutoBackupRestore))
if (!_coreBaseSettings.Standalone && (!SetupInfo.IsVisibleSettings("Restore") || !quota.AutoBackupRestore))
{
throw new BillingException(Resource.ErrorNotAllowedOption, "Restore");
}
}

public async Task DemandPermissionsAutoBackupAsync()
private async Task DemandPermissionsAutoBackupAsync()
{
await _permissionContext.DemandPermissionsAsync(SecurityConstants.EditPortalSettings);

if (!SetupInfo.IsVisibleSettings("AutoBackup") ||
(!_coreBaseSettings.Standalone && !(await _tenantManager.GetTenantQuotaAsync(await _tenantManager.GetCurrentTenantIdAsync())).AutoBackupRestore))
if (!SetupInfo.IsVisibleSettings("AutoBackup") || !(await _tenantManager.GetTenantQuotaAsync(await _tenantManager.GetCurrentTenantIdAsync())).AutoBackupRestore)
{
throw new BillingException(Resource.ErrorNotAllowedOption, "AutoBackup");
}
Expand Down

0 comments on commit 16977d2

Please sign in to comment.