Skip to content

Commit b454437

Browse files
committed
chore: tidy up
1 parent d625547 commit b454437

File tree

151 files changed

+239
-264
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+239
-264
lines changed

src/GZCTF.Test/AccountTest.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Net.Http.Json;
44
using System.Threading.Tasks;
55
using Xunit;
6-
using Xunit.Abstractions;
76

87
namespace GZCTF.Test;
98

@@ -29,4 +28,4 @@ public async Task TestCreateUser()
2928
await client.PostAsJsonAsync("/api/account/login", new { userName = "foo", password = "foo12345##Foo" });
3029
Assert.True(loginResult.IsSuccessStatusCode);
3130
}
32-
}
31+
}

src/GZCTF.Test/ConfigServiceTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ public class TestConfig
2626
public AccountPolicy AccoutPolicy { get; set; } = new();
2727
public DockerConfig DockerConfig { get; set; } = new();
2828
public EmailConfig EmailConfig { get; set; } = new();
29-
}
29+
}

src/GZCTF.Test/SignatureTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,4 @@ public void SHA512WithRSATest()
166166
output.WriteLine(verified ? "Signature verified" : "Signature not verified");
167167
Assert.True(verified);
168168
}
169-
}
169+
}

src/GZCTF.Test/TestWebAppFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ static TestWebAppFactory()
88
{
99
Program.IsTesting = true;
1010
}
11-
}
11+
}

src/GZCTF/Controllers/AccountController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ public async Task<IActionResult> Update([FromBody] ProfileUpdateModel model)
346346
{
347347
var oldName = user.UserName;
348348

349-
var unameRes = await userManager.SetUserNameAsync(user, model.UserName);
349+
IdentityResult unameRes = await userManager.SetUserNameAsync(user, model.UserName);
350350

351351
if (!unameRes.Succeeded)
352352
return HandleIdentityError(unameRes.Errors);
@@ -356,7 +356,7 @@ public async Task<IActionResult> Update([FromBody] ProfileUpdateModel model)
356356
}
357357

358358
user!.UpdateUserInfo(model);
359-
var result = await userManager.UpdateAsync(user);
359+
IdentityResult result = await userManager.UpdateAsync(user);
360360

361361
if (!result.Succeeded)
362362
return HandleIdentityError(result.Errors);
@@ -544,4 +544,4 @@ string GetEmailLink(string action, string token, string? email)
544544
BadRequestObjectResult HandleIdentityError(IEnumerable<IdentityError> errors) =>
545545
BadRequest(new RequestResponse(errors.FirstOrDefault()?.Description ??
546546
localizer[nameof(Resources.Program.Identity_UnknownError)]));
547-
}
547+
}

src/GZCTF/Controllers/AdminController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public async Task<IActionResult> AddUsers([FromBody] UserCreateModel[] model, Ca
206206
public async Task<IActionResult> SearchUsers([FromQuery] string hint, CancellationToken token = default)
207207
{
208208
var loweredHint = hint.ToLower();
209-
var data = await userManager.Users.Where(item =>
209+
UserInfo[] data = await userManager.Users.Where(item =>
210210
item.UserName!.ToLower().Contains(loweredHint) ||
211211
item.StdNumber.ToLower().Contains(loweredHint) ||
212212
item.Email!.ToLower().Contains(loweredHint) ||
@@ -301,15 +301,15 @@ public async Task<IActionResult> UpdateUserInfo(string userid, [FromBody] AdminU
301301

302302
if (model.UserName is not null && model.UserName != user.UserName)
303303
{
304-
var result = await userManager.SetUserNameAsync(user, model.UserName);
304+
IdentityResult result = await userManager.SetUserNameAsync(user, model.UserName);
305305

306306
if (!result.Succeeded)
307307
return HandleIdentityError(result.Errors);
308308
}
309309

310310
if (model.Email is not null && model.Email != user.Email)
311311
{
312-
var result = await userManager.SetEmailAsync(user, model.Email);
312+
IdentityResult result = await userManager.SetEmailAsync(user, model.Email);
313313

314314
if (!result.Succeeded)
315315
return HandleIdentityError(result.Errors);
@@ -591,4 +591,4 @@ public async Task<IActionResult> Files([FromQuery] int count = 50, [FromQuery] i
591591
IActionResult HandleIdentityError(IEnumerable<IdentityError> errors) =>
592592
BadRequest(new RequestResponse(errors.FirstOrDefault()?.Description ??
593593
localizer[nameof(Resources.Program.Identity_UnknownError)]));
594-
}
594+
}

src/GZCTF/Controllers/AssetsController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,4 @@ public async Task<IActionResult> Delete(string hash, CancellationToken token)
130130
_ => BadRequest(new RequestResponse(localizer[nameof(Resources.Program.File_DeletionFailed)]))
131131
};
132132
}
133-
}
133+
}

src/GZCTF/Controllers/ErrorController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ public Task<IActionResult> InternalServerError(CancellationToken cancellationTok
1414
Task.FromResult<IActionResult>(StatusCode(500,
1515
new RequestResponse(localizer[nameof(Resources.Program.Error_InternalServerError)],
1616
StatusCodes.Status500InternalServerError)));
17-
}
17+
}

src/GZCTF/Controllers/ExerciseController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace GZCTF.Controllers;
1111
[Route("api/[controller]")]
1212
[ProducesResponseType(typeof(RequestResponse), StatusCodes.Status401Unauthorized)]
1313
[ProducesResponseType(typeof(RequestResponse), StatusCodes.Status403Forbidden)]
14-
public class ExerciseController() : ControllerBase
14+
public class ExerciseController : ControllerBase
1515
{
1616
// TODO: exercise mode support
17-
}
17+
}

src/GZCTF/Controllers/InfoController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public async Task<IActionResult> GetPost(string id, CancellationToken token)
8686
[ProducesResponseType(typeof(ClientConfig), StatusCodes.Status200OK)]
8787
public async Task<IActionResult> GetClientConfig(CancellationToken token = default)
8888
{
89-
var data = await cache.GetOrCreateAsync(logger, CacheKey.ClientConfig,
89+
ClientConfig data = await cache.GetOrCreateAsync(logger, CacheKey.ClientConfig,
9090
entry =>
9191
{
9292
entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromDays(7);
@@ -107,7 +107,7 @@ public async Task<IActionResult> GetClientConfig(CancellationToken token = defau
107107
[ProducesResponseType(typeof(ClientCaptchaInfoModel), StatusCodes.Status200OK)]
108108
public async Task<IActionResult> GetClientCaptchaInfo(CancellationToken token = default)
109109
{
110-
var data = await cache.GetOrCreateAsync(logger, CacheKey.CaptchaConfig,
110+
ClientCaptchaInfoModel data = await cache.GetOrCreateAsync(logger, CacheKey.CaptchaConfig,
111111
entry =>
112112
{
113113
entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromDays(7);
@@ -118,4 +118,4 @@ public async Task<IActionResult> GetClientCaptchaInfo(CancellationToken token =
118118

119119
return Ok(data);
120120
}
121-
}
121+
}

0 commit comments

Comments
 (0)