1
0
mirror of https://github.com/bitwarden/server synced 2025-12-25 04:33:26 +00:00

Changed all C# control flow block statements to include space between keyword and open paren

This commit is contained in:
Chad Scharf
2020-03-27 14:36:37 -04:00
parent 943aea9a12
commit 9800b752c0
243 changed files with 2258 additions and 2258 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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