mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
Changed all C# control flow block statements to include space between keyword and open paren
This commit is contained in:
@ -44,22 +44,22 @@ namespace Bit.Admin.Controllers
|
||||
{
|
||||
var response = await _httpClient.GetAsync(
|
||||
$"https://hub.docker.com/v2/repositories/bitwarden/{repository}/tags/");
|
||||
if(response.IsSuccessStatusCode)
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var json = await response.Content.ReadAsStringAsync();
|
||||
var data = JObject.Parse(json);
|
||||
var results = data["results"] as JArray;
|
||||
foreach(var result in results)
|
||||
foreach (var result in results)
|
||||
{
|
||||
var name = result["name"].ToString();
|
||||
if(!string.IsNullOrWhiteSpace(name) && name.Length > 0 && char.IsNumber(name[0]))
|
||||
if (!string.IsNullOrWhiteSpace(name) && name.Length > 0 && char.IsNumber(name[0]))
|
||||
{
|
||||
return new JsonResult(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(HttpRequestException) { }
|
||||
catch (HttpRequestException) { }
|
||||
|
||||
return new JsonResult("-");
|
||||
}
|
||||
@ -70,14 +70,14 @@ namespace Bit.Admin.Controllers
|
||||
{
|
||||
var response = await _httpClient.GetAsync(
|
||||
$"{_globalSettings.BaseServiceUri.InternalVault}/version.json");
|
||||
if(response.IsSuccessStatusCode)
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var json = await response.Content.ReadAsStringAsync();
|
||||
var data = JObject.Parse(json);
|
||||
return new JsonResult(data["version"].ToString());
|
||||
}
|
||||
}
|
||||
catch(HttpRequestException) { }
|
||||
catch (HttpRequestException) { }
|
||||
|
||||
return new JsonResult("-");
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ namespace Bit.Admin.Controllers
|
||||
public IActionResult Index(string returnUrl = null, string error = null, string success = null,
|
||||
bool accessDenied = false)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(error) && accessDenied)
|
||||
if (string.IsNullOrWhiteSpace(error) && accessDenied)
|
||||
{
|
||||
error = "Access denied. Please log in.";
|
||||
}
|
||||
@ -36,7 +36,7 @@ namespace Bit.Admin.Controllers
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Index(LoginModel model)
|
||||
{
|
||||
if(ModelState.IsValid)
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
await _signInManager.PasswordlessSignInAsync(model.Email, model.ReturnUrl);
|
||||
return RedirectToAction("Index", new
|
||||
@ -52,7 +52,7 @@ namespace Bit.Admin.Controllers
|
||||
public async Task<IActionResult> Confirm(string email, string token, string returnUrl)
|
||||
{
|
||||
var result = await _signInManager.PasswordlessSignInAsync(email, token, true);
|
||||
if(!result.Succeeded)
|
||||
if (!result.Succeeded)
|
||||
{
|
||||
return RedirectToAction("Index", new
|
||||
{
|
||||
@ -60,7 +60,7 @@ namespace Bit.Admin.Controllers
|
||||
});
|
||||
}
|
||||
|
||||
if(!string.IsNullOrWhiteSpace(returnUrl) && Url.IsLocalUrl(returnUrl))
|
||||
if (!string.IsNullOrWhiteSpace(returnUrl) && Url.IsLocalUrl(returnUrl))
|
||||
{
|
||||
return Redirect(returnUrl);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ namespace Bit.Admin.Controllers
|
||||
LogEventLevel? level = null, string project = null, DateTime? start = null, DateTime? end = null)
|
||||
{
|
||||
var collectionLink = UriFactory.CreateDocumentCollectionUri(Database, Collection);
|
||||
using(var client = new DocumentClient(new Uri(_globalSettings.DocumentDb.Uri),
|
||||
using (var client = new DocumentClient(new Uri(_globalSettings.DocumentDb.Uri),
|
||||
_globalSettings.DocumentDb.Key))
|
||||
{
|
||||
var options = new FeedOptions
|
||||
@ -40,19 +40,19 @@ namespace Bit.Admin.Controllers
|
||||
};
|
||||
|
||||
var query = client.CreateDocumentQuery<LogModel>(collectionLink, options).AsQueryable();
|
||||
if(level.HasValue)
|
||||
if (level.HasValue)
|
||||
{
|
||||
query = query.Where(l => l.Level == level.Value.ToString());
|
||||
}
|
||||
if(!string.IsNullOrWhiteSpace(project))
|
||||
if (!string.IsNullOrWhiteSpace(project))
|
||||
{
|
||||
query = query.Where(l => l.Properties != null && l.Properties["Project"] == (object)project);
|
||||
}
|
||||
if(start.HasValue)
|
||||
if (start.HasValue)
|
||||
{
|
||||
query = query.Where(l => l.Timestamp >= start.Value);
|
||||
}
|
||||
if(end.HasValue)
|
||||
if (end.HasValue)
|
||||
{
|
||||
query = query.Where(l => l.Timestamp <= end.Value);
|
||||
}
|
||||
@ -76,12 +76,12 @@ namespace Bit.Admin.Controllers
|
||||
|
||||
public async Task<IActionResult> View(Guid id)
|
||||
{
|
||||
using(var client = new DocumentClient(new Uri(_globalSettings.DocumentDb.Uri),
|
||||
using (var client = new DocumentClient(new Uri(_globalSettings.DocumentDb.Uri),
|
||||
_globalSettings.DocumentDb.Key))
|
||||
{
|
||||
var uri = UriFactory.CreateDocumentUri(Database, Collection, id.ToString());
|
||||
var response = await client.ReadDocumentAsync<LogDetailsModel>(uri);
|
||||
if(response?.Document == null)
|
||||
if (response?.Document == null)
|
||||
{
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
@ -50,12 +50,12 @@ namespace Bit.Admin.Controllers
|
||||
public async Task<IActionResult> Index(string name = null, string userEmail = null, bool? paid = null,
|
||||
int page = 1, int count = 25)
|
||||
{
|
||||
if(page < 1)
|
||||
if (page < 1)
|
||||
{
|
||||
page = 1;
|
||||
}
|
||||
|
||||
if(count < 1)
|
||||
if (count < 1)
|
||||
{
|
||||
count = 1;
|
||||
}
|
||||
@ -78,7 +78,7 @@ namespace Bit.Admin.Controllers
|
||||
public async Task<IActionResult> View(Guid id)
|
||||
{
|
||||
var organization = await _organizationRepository.GetByIdAsync(id);
|
||||
if(organization == null)
|
||||
if (organization == null)
|
||||
{
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
@ -86,12 +86,12 @@ namespace Bit.Admin.Controllers
|
||||
var ciphers = await _cipherRepository.GetManyByOrganizationIdAsync(id);
|
||||
var collections = await _collectionRepository.GetManyByOrganizationIdAsync(id);
|
||||
IEnumerable<Group> groups = null;
|
||||
if(organization.UseGroups)
|
||||
if (organization.UseGroups)
|
||||
{
|
||||
groups = await _groupRepository.GetManyByOrganizationIdAsync(id);
|
||||
}
|
||||
IEnumerable<Policy> policies = null;
|
||||
if(organization.UsePolicies)
|
||||
if (organization.UsePolicies)
|
||||
{
|
||||
policies = await _policyRepository.GetManyByOrganizationIdAsync(id);
|
||||
}
|
||||
@ -103,7 +103,7 @@ namespace Bit.Admin.Controllers
|
||||
public async Task<IActionResult> Edit(Guid id)
|
||||
{
|
||||
var organization = await _organizationRepository.GetByIdAsync(id);
|
||||
if(organization == null)
|
||||
if (organization == null)
|
||||
{
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
@ -111,12 +111,12 @@ namespace Bit.Admin.Controllers
|
||||
var ciphers = await _cipherRepository.GetManyByOrganizationIdAsync(id);
|
||||
var collections = await _collectionRepository.GetManyByOrganizationIdAsync(id);
|
||||
IEnumerable<Group> groups = null;
|
||||
if(organization.UseGroups)
|
||||
if (organization.UseGroups)
|
||||
{
|
||||
groups = await _groupRepository.GetManyByOrganizationIdAsync(id);
|
||||
}
|
||||
IEnumerable<Policy> policies = null;
|
||||
if(organization.UsePolicies)
|
||||
if (organization.UsePolicies)
|
||||
{
|
||||
policies = await _policyRepository.GetManyByOrganizationIdAsync(id);
|
||||
}
|
||||
@ -132,7 +132,7 @@ namespace Bit.Admin.Controllers
|
||||
public async Task<IActionResult> Edit(Guid id, OrganizationEditModel model)
|
||||
{
|
||||
var organization = await _organizationRepository.GetByIdAsync(id);
|
||||
if(organization == null)
|
||||
if (organization == null)
|
||||
{
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
@ -148,7 +148,7 @@ namespace Bit.Admin.Controllers
|
||||
public async Task<IActionResult> Delete(Guid id)
|
||||
{
|
||||
var organization = await _organizationRepository.GetByIdAsync(id);
|
||||
if(organization != null)
|
||||
if (organization != null)
|
||||
{
|
||||
await _organizationRepository.DeleteAsync(organization);
|
||||
await _applicationCacheService.DeleteOrganizationAbilityAsync(organization.Id);
|
||||
|
@ -37,7 +37,7 @@ namespace Bit.Admin.Controllers
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> ChargeBraintree(ChargeBraintreeModel model)
|
||||
{
|
||||
if(!ModelState.IsValid)
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return View(model);
|
||||
}
|
||||
@ -73,7 +73,7 @@ namespace Bit.Admin.Controllers
|
||||
}
|
||||
});
|
||||
|
||||
if(!transactionResult.IsSuccess())
|
||||
if (!transactionResult.IsSuccess())
|
||||
{
|
||||
ModelState.AddModelError(string.Empty, "Charge failed. " +
|
||||
"Refer to Braintree admin portal for more information.");
|
||||
@ -98,13 +98,13 @@ namespace Bit.Admin.Controllers
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> CreateTransaction(CreateUpdateTransactionModel model)
|
||||
{
|
||||
if(!ModelState.IsValid)
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return View("CreateUpdateTransaction", model);
|
||||
}
|
||||
|
||||
await _transactionRepository.CreateAsync(model.ToTransaction());
|
||||
if(model.UserId.HasValue)
|
||||
if (model.UserId.HasValue)
|
||||
{
|
||||
return RedirectToAction("Edit", "Users", new { id = model.UserId });
|
||||
}
|
||||
@ -117,7 +117,7 @@ namespace Bit.Admin.Controllers
|
||||
public async Task<IActionResult> EditTransaction(Guid id)
|
||||
{
|
||||
var transaction = await _transactionRepository.GetByIdAsync(id);
|
||||
if(transaction == null)
|
||||
if (transaction == null)
|
||||
{
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
@ -127,12 +127,12 @@ namespace Bit.Admin.Controllers
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> EditTransaction(Guid id, CreateUpdateTransactionModel model)
|
||||
{
|
||||
if(!ModelState.IsValid)
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return View("CreateUpdateTransaction", model);
|
||||
}
|
||||
await _transactionRepository.ReplaceAsync(model.ToTransaction(id));
|
||||
if(model.UserId.HasValue)
|
||||
if (model.UserId.HasValue)
|
||||
{
|
||||
return RedirectToAction("Edit", "Users", new { id = model.UserId });
|
||||
}
|
||||
@ -150,7 +150,7 @@ namespace Bit.Admin.Controllers
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> PromoteAdmin(PromoteAdminModel model)
|
||||
{
|
||||
if(!ModelState.IsValid)
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return View("PromoteAdmin", model);
|
||||
}
|
||||
@ -158,16 +158,16 @@ namespace Bit.Admin.Controllers
|
||||
var orgUsers = await _organizationUserRepository.GetManyByOrganizationAsync(
|
||||
model.OrganizationId.Value, null);
|
||||
var user = orgUsers.FirstOrDefault(u => u.UserId == model.UserId.Value);
|
||||
if(user == null)
|
||||
if (user == null)
|
||||
{
|
||||
ModelState.AddModelError(nameof(model.UserId), "User Id not found in this organization.");
|
||||
}
|
||||
else if(user.Type != Core.Enums.OrganizationUserType.Admin)
|
||||
else if (user.Type != Core.Enums.OrganizationUserType.Admin)
|
||||
{
|
||||
ModelState.AddModelError(nameof(model.UserId), "User is not an admin of this organization.");
|
||||
}
|
||||
|
||||
if(!ModelState.IsValid)
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return View("PromoteAdmin", model);
|
||||
}
|
||||
|
@ -34,12 +34,12 @@ namespace Bit.Admin.Controllers
|
||||
|
||||
public async Task<IActionResult> Index(string email, int page = 1, int count = 25)
|
||||
{
|
||||
if(page < 1)
|
||||
if (page < 1)
|
||||
{
|
||||
page = 1;
|
||||
}
|
||||
|
||||
if(count < 1)
|
||||
if (count < 1)
|
||||
{
|
||||
count = 1;
|
||||
}
|
||||
@ -59,7 +59,7 @@ namespace Bit.Admin.Controllers
|
||||
public async Task<IActionResult> View(Guid id)
|
||||
{
|
||||
var user = await _userRepository.GetByIdAsync(id);
|
||||
if(user == null)
|
||||
if (user == null)
|
||||
{
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
@ -72,7 +72,7 @@ namespace Bit.Admin.Controllers
|
||||
public async Task<IActionResult> Edit(Guid id)
|
||||
{
|
||||
var user = await _userRepository.GetByIdAsync(id);
|
||||
if(user == null)
|
||||
if (user == null)
|
||||
{
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
@ -88,7 +88,7 @@ namespace Bit.Admin.Controllers
|
||||
public async Task<IActionResult> Edit(Guid id, UserEditModel model)
|
||||
{
|
||||
var user = await _userRepository.GetByIdAsync(id);
|
||||
if(user == null)
|
||||
if (user == null)
|
||||
{
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
@ -103,7 +103,7 @@ namespace Bit.Admin.Controllers
|
||||
public async Task<IActionResult> Delete(Guid id)
|
||||
{
|
||||
var user = await _userRepository.GetByIdAsync(id);
|
||||
if(user != null)
|
||||
if (user != null)
|
||||
{
|
||||
await _userRepository.DeleteAsync(user);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ namespace Bit.Admin.HostedServices
|
||||
var unblockIpQueue = await _client.GetQueueUrlAsync("unblock-ip", cancellationToken);
|
||||
var unblockIpQueueUrl = unblockIpQueue.QueueUrl;
|
||||
|
||||
while(!cancellationToken.IsCancellationRequested)
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
var blockMessageResponse = await _client.ReceiveMessageAsync(new ReceiveMessageRequest
|
||||
{
|
||||
@ -44,15 +44,15 @@ namespace Bit.Admin.HostedServices
|
||||
MaxNumberOfMessages = 10,
|
||||
WaitTimeSeconds = 15
|
||||
}, cancellationToken);
|
||||
if(blockMessageResponse.Messages.Any())
|
||||
if (blockMessageResponse.Messages.Any())
|
||||
{
|
||||
foreach(var message in blockMessageResponse.Messages)
|
||||
foreach (var message in blockMessageResponse.Messages)
|
||||
{
|
||||
try
|
||||
{
|
||||
await BlockIpAsync(message.Body, cancellationToken);
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Failed to block IP.");
|
||||
}
|
||||
@ -66,15 +66,15 @@ namespace Bit.Admin.HostedServices
|
||||
MaxNumberOfMessages = 10,
|
||||
WaitTimeSeconds = 15
|
||||
}, cancellationToken);
|
||||
if(unblockMessageResponse.Messages.Any())
|
||||
if (unblockMessageResponse.Messages.Any())
|
||||
{
|
||||
foreach(var message in unblockMessageResponse.Messages)
|
||||
foreach (var message in unblockMessageResponse.Messages)
|
||||
{
|
||||
try
|
||||
{
|
||||
await UnblockIpAsync(message.Body, cancellationToken);
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Failed to unblock IP.");
|
||||
}
|
||||
|
@ -26,18 +26,18 @@ namespace Bit.Admin.HostedServices
|
||||
_blockIpQueueClient = new QueueClient(_globalSettings.Storage.ConnectionString, "blockip");
|
||||
_unblockIpQueueClient = new QueueClient(_globalSettings.Storage.ConnectionString, "unblockip");
|
||||
|
||||
while(!cancellationToken.IsCancellationRequested)
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
var blockMessages = await _blockIpQueueClient.ReceiveMessagesAsync(maxMessages: 32);
|
||||
if(blockMessages.Value?.Any() ?? false)
|
||||
if (blockMessages.Value?.Any() ?? false)
|
||||
{
|
||||
foreach(var message in blockMessages.Value)
|
||||
foreach (var message in blockMessages.Value)
|
||||
{
|
||||
try
|
||||
{
|
||||
await BlockIpAsync(message.MessageText, cancellationToken);
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Failed to block IP.");
|
||||
}
|
||||
@ -46,15 +46,15 @@ namespace Bit.Admin.HostedServices
|
||||
}
|
||||
|
||||
var unblockMessages = await _unblockIpQueueClient.ReceiveMessagesAsync(maxMessages: 32);
|
||||
if(unblockMessages.Value?.Any() ?? false)
|
||||
if (unblockMessages.Value?.Any() ?? false)
|
||||
{
|
||||
foreach(var message in unblockMessages.Value)
|
||||
foreach (var message in unblockMessages.Value)
|
||||
{
|
||||
try
|
||||
{
|
||||
await UnblockIpAsync(message.MessageText, cancellationToken);
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Failed to unblock IP.");
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ namespace Bit.Admin.HostedServices
|
||||
|
||||
public async Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
if(_executingTask == null)
|
||||
if (_executingTask == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -78,14 +78,14 @@ namespace Bit.Admin.HostedServices
|
||||
request.Content = new StringContent(bodyContent, Encoding.UTF8, "application/json");
|
||||
|
||||
var response = await _httpClient.SendAsync(request, cancellationToken);
|
||||
if(!response.IsSuccessStatusCode)
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var responseString = await response.Content.ReadAsStringAsync();
|
||||
var accessRuleResponse = JsonConvert.DeserializeObject<AccessRuleResponse>(responseString);
|
||||
if(!accessRuleResponse.Success)
|
||||
if (!accessRuleResponse.Success)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -95,12 +95,12 @@ namespace Bit.Admin.HostedServices
|
||||
|
||||
protected async Task UnblockIpAsync(string message, CancellationToken cancellationToken)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(message))
|
||||
if (string.IsNullOrWhiteSpace(message))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(message.Contains(".") || message.Contains(":"))
|
||||
if (message.Contains(".") || message.Contains(":"))
|
||||
{
|
||||
// IP address messages
|
||||
var request = new HttpRequestMessage();
|
||||
@ -113,19 +113,19 @@ namespace Bit.Admin.HostedServices
|
||||
$"configuration_target=ip&configuration_value={message}");
|
||||
|
||||
var response = await _httpClient.SendAsync(request, cancellationToken);
|
||||
if(!response.IsSuccessStatusCode)
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var responseString = await response.Content.ReadAsStringAsync();
|
||||
var listResponse = JsonConvert.DeserializeObject<ListResponse>(responseString);
|
||||
if(!listResponse.Success)
|
||||
if (!listResponse.Success)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach(var rule in listResponse.Result)
|
||||
foreach (var rule in listResponse.Result)
|
||||
{
|
||||
await DeleteAccessRuleAsync(rule.Id, cancellationToken);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ namespace Bit.Admin.HostedServices
|
||||
await Task.Delay(20000);
|
||||
|
||||
var maxMigrationAttempts = 10;
|
||||
for(var i = 1; i <= maxMigrationAttempts; i++)
|
||||
for (var i = 1; i <= maxMigrationAttempts; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -41,9 +41,9 @@ namespace Bit.Admin.HostedServices
|
||||
// TODO: Maybe flip a flag somewhere to indicate migration is complete??
|
||||
break;
|
||||
}
|
||||
catch(SqlException e)
|
||||
catch (SqlException e)
|
||||
{
|
||||
if(i >= maxMigrationAttempts)
|
||||
if (i >= maxMigrationAttempts)
|
||||
{
|
||||
_logger.LogError(e, "Database failed to migrate.");
|
||||
throw e;
|
||||
|
@ -30,7 +30,7 @@ namespace Bit.Admin.Jobs
|
||||
var timeZone = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ?
|
||||
TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time") :
|
||||
TimeZoneInfo.FindSystemTimeZoneById("America/New_York");
|
||||
if(_globalSettings.SelfHosted)
|
||||
if (_globalSettings.SelfHosted)
|
||||
{
|
||||
timeZone = TimeZoneInfo.Utc;
|
||||
}
|
||||
@ -59,7 +59,7 @@ namespace Bit.Admin.Jobs
|
||||
new Tuple<Type, ITrigger>(typeof(DatabaseRebuildlIndexesJob), everySundayAtMidnightTrigger)
|
||||
};
|
||||
|
||||
if(!_globalSettings.SelfHosted)
|
||||
if (!_globalSettings.SelfHosted)
|
||||
{
|
||||
jobs.Add(new Tuple<Type, ITrigger>(typeof(AliveJob), everyTopOfTheHourTrigger));
|
||||
}
|
||||
@ -70,7 +70,7 @@ namespace Bit.Admin.Jobs
|
||||
|
||||
public static void AddJobsServices(IServiceCollection services, bool selfHosted)
|
||||
{
|
||||
if(!selfHosted)
|
||||
if (!selfHosted)
|
||||
{
|
||||
services.AddTransient<AliveJob>();
|
||||
}
|
||||
|
@ -17,9 +17,9 @@ namespace Bit.Admin.Models
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if(Id != null)
|
||||
if (Id != null)
|
||||
{
|
||||
if(Id.Length != 36 || (Id[0] != 'o' && Id[0] != 'u') ||
|
||||
if (Id.Length != 36 || (Id[0] != 'o' && Id[0] != 'u') ||
|
||||
!Guid.TryParse(Id.Substring(1, 32), out var guid))
|
||||
{
|
||||
yield return new ValidationResult("Customer Id is not a valid format.");
|
||||
|
@ -52,7 +52,7 @@ namespace Bit.Admin.Models
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if((!UserId.HasValue && !OrganizationId.HasValue) || (UserId.HasValue && OrganizationId.HasValue))
|
||||
if ((!UserId.HasValue && !OrganizationId.HasValue) || (UserId.HasValue && OrganizationId.HasValue))
|
||||
{
|
||||
yield return new ValidationResult("Must provide either User Id, or Organization Id.");
|
||||
}
|
||||
|
@ -21,30 +21,30 @@ namespace Bit.Admin.Models
|
||||
|
||||
public string ExceptionToString(JObject e)
|
||||
{
|
||||
if(e == null)
|
||||
if (e == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var val = string.Empty;
|
||||
if(e["Message"] != null && e["Message"].ToObject<string>() != null)
|
||||
if (e["Message"] != null && e["Message"].ToObject<string>() != null)
|
||||
{
|
||||
val += "Message:\n";
|
||||
val += e["Message"] + "\n";
|
||||
}
|
||||
|
||||
if(e["StackTrace"] != null && e["StackTrace"].ToObject<string>() != null)
|
||||
if (e["StackTrace"] != null && e["StackTrace"].ToObject<string>() != null)
|
||||
{
|
||||
val += "\nStack Trace:\n";
|
||||
val += e["StackTrace"];
|
||||
}
|
||||
else if(e["StackTraceString"] != null && e["StackTraceString"].ToObject<string>() != null)
|
||||
else if (e["StackTraceString"] != null && e["StackTraceString"].ToObject<string>() != null)
|
||||
{
|
||||
val += "\nStack Trace String:\n";
|
||||
val += e["StackTraceString"];
|
||||
}
|
||||
|
||||
if(e["InnerException"] != null && e["InnerException"].ToObject<JObject>() != null)
|
||||
if (e["InnerException"] != null && e["InnerException"].ToObject<JObject>() != null)
|
||||
{
|
||||
val += "\n\n=== Inner Exception ===\n\n";
|
||||
val += ExceptionToString(e["InnerException"].ToObject<JObject>());
|
||||
|
@ -22,7 +22,7 @@ namespace Bit.Admin
|
||||
logging.AddSerilog(hostingContext, e =>
|
||||
{
|
||||
var context = e.Properties["SourceContext"].ToString();
|
||||
if(e.Properties.ContainsKey("RequestPath") &&
|
||||
if (e.Properties.ContainsKey("RequestPath") &&
|
||||
!string.IsNullOrWhiteSpace(e.Properties["RequestPath"]?.ToString()) &&
|
||||
(context.Contains(".Server.Kestrel") || context.Contains(".Core.IISHttpServer")))
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ namespace Bit.Admin
|
||||
{
|
||||
options.ValidationInterval = TimeSpan.FromMinutes(5);
|
||||
});
|
||||
if(globalSettings.SelfHosted)
|
||||
if (globalSettings.SelfHosted)
|
||||
{
|
||||
services.ConfigureApplicationCookie(options =>
|
||||
{
|
||||
@ -75,17 +75,17 @@ namespace Bit.Admin
|
||||
// Jobs service
|
||||
Jobs.JobsHostedService.AddJobsServices(services, globalSettings.SelfHosted);
|
||||
services.AddHostedService<Jobs.JobsHostedService>();
|
||||
if(globalSettings.SelfHosted)
|
||||
if (globalSettings.SelfHosted)
|
||||
{
|
||||
services.AddHostedService<HostedServices.DatabaseMigrationHostedService>();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(CoreHelpers.SettingHasValue(globalSettings.Storage.ConnectionString))
|
||||
if (CoreHelpers.SettingHasValue(globalSettings.Storage.ConnectionString))
|
||||
{
|
||||
services.AddHostedService<HostedServices.AzureQueueBlockIpHostedService>();
|
||||
}
|
||||
else if(CoreHelpers.SettingHasValue(globalSettings.Amazon?.AccessKeySecret))
|
||||
else if (CoreHelpers.SettingHasValue(globalSettings.Amazon?.AccessKeySecret))
|
||||
{
|
||||
services.AddHostedService<HostedServices.AmazonSqsBlockIpHostedService>();
|
||||
}
|
||||
@ -100,13 +100,13 @@ namespace Bit.Admin
|
||||
{
|
||||
app.UseSerilog(env, appLifetime, globalSettings);
|
||||
|
||||
if(globalSettings.SelfHosted)
|
||||
if (globalSettings.SelfHosted)
|
||||
{
|
||||
app.UsePathBase("/admin");
|
||||
app.UseForwardedHeaders(globalSettings);
|
||||
}
|
||||
|
||||
if(env.IsDevelopment())
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
@ -31,33 +31,33 @@ namespace Bit.Admin.TagHelpers
|
||||
|
||||
public override void Process(TagHelperContext context, TagHelperOutput output)
|
||||
{
|
||||
if(context == null)
|
||||
if (context == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(context));
|
||||
}
|
||||
|
||||
if(output == null)
|
||||
if (output == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(output));
|
||||
}
|
||||
|
||||
if(ActiveAction == null && ActiveController == null)
|
||||
if (ActiveAction == null && ActiveController == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var descriptor = ViewContext.ActionDescriptor as ControllerActionDescriptor;
|
||||
if(descriptor == null)
|
||||
if (descriptor == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var controllerMatch = ActiveMatch(ActiveController, descriptor.ControllerName);
|
||||
var actionMatch = ActiveMatch(ActiveAction, descriptor.ActionName);
|
||||
if(controllerMatch && actionMatch)
|
||||
if (controllerMatch && actionMatch)
|
||||
{
|
||||
var classValue = "active";
|
||||
if(output.Attributes["class"] != null)
|
||||
if (output.Attributes["class"] != null)
|
||||
{
|
||||
classValue += " " + output.Attributes["class"].Value;
|
||||
output.Attributes.Remove(output.Attributes["class"]);
|
||||
|
@ -21,17 +21,17 @@ namespace Bit.Admin.TagHelpers
|
||||
|
||||
public override void Process(TagHelperContext context, TagHelperOutput output)
|
||||
{
|
||||
if(context == null)
|
||||
if (context == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(context));
|
||||
}
|
||||
|
||||
if(output == null)
|
||||
if (output == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(output));
|
||||
}
|
||||
|
||||
if(Selected)
|
||||
if (Selected)
|
||||
{
|
||||
output.Attributes.Add("selected", "selected");
|
||||
}
|
||||
|
Reference in New Issue
Block a user