Removed symbol requirement for password, fix formatting.
This commit is contained in:
@@ -2,7 +2,6 @@ using GameList.Data;
|
||||
using GameList.Contracts;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using GameList.Infrastructure;
|
||||
using Microsoft.AspNetCore.RateLimiting;
|
||||
|
||||
namespace GameList.Endpoints;
|
||||
|
||||
|
||||
@@ -22,12 +22,8 @@ internal sealed class AdminWorkflowService(AppDbContext db)
|
||||
}
|
||||
else
|
||||
{
|
||||
await db.Players
|
||||
.Where(p => p.Suggestions.Any())
|
||||
.ExecuteUpdateAsync(p => p.SetProperty(x => x.CurrentPhase, Phase.Vote).SetProperty(x => x.VotesFinal, false));
|
||||
await db.Players
|
||||
.Where(p => !p.Suggestions.Any())
|
||||
.ExecuteUpdateAsync(p => p.SetProperty(x => x.CurrentPhase, Phase.Suggest).SetProperty(x => x.VotesFinal, false));
|
||||
await db.Players.Where(p => p.Suggestions.Any()).ExecuteUpdateAsync(p => p.SetProperty(x => x.CurrentPhase, Phase.Vote).SetProperty(x => x.VotesFinal, false));
|
||||
await db.Players.Where(p => !p.Suggestions.Any()).ExecuteUpdateAsync(p => p.SetProperty(x => x.CurrentPhase, Phase.Suggest).SetProperty(x => x.VotesFinal, false));
|
||||
}
|
||||
|
||||
await db.SaveChangesAsync();
|
||||
@@ -38,22 +34,7 @@ internal sealed class AdminWorkflowService(AppDbContext db)
|
||||
|
||||
public async Task<IResult> GetVoteStatusAsync()
|
||||
{
|
||||
var voters = await db.Players
|
||||
.AsNoTracking()
|
||||
.Include(p => p.Suggestions)
|
||||
.OrderBy(p => p.DisplayName ?? p.Username)
|
||||
.Select(p => new VoteStatusDto(
|
||||
p.Id,
|
||||
p.DisplayName ?? p.Username,
|
||||
p.Username,
|
||||
p.CurrentPhase,
|
||||
p.VotesFinal,
|
||||
p.HasJoker,
|
||||
p.IsAdmin,
|
||||
p.IsOwner,
|
||||
p.Suggestions.Count,
|
||||
p.Suggestions.Select(s => s.Name).ToList()))
|
||||
.ToListAsync();
|
||||
var voters = await db.Players.AsNoTracking().Include(p => p.Suggestions).OrderBy(p => p.DisplayName ?? p.Username).Select(p => new VoteStatusDto(p.Id, p.DisplayName ?? p.Username, p.Username, p.CurrentPhase, p.VotesFinal, p.HasJoker, p.IsAdmin, p.IsOwner, p.Suggestions.Count, p.Suggestions.Select(s => s.Name).ToList())).ToListAsync();
|
||||
|
||||
var waiting = voters.Where(v => !v.Finalized).Select(v => v.Name).ToList();
|
||||
var ready = waiting.Count == 0;
|
||||
@@ -131,9 +112,7 @@ internal sealed class AdminWorkflowService(AppDbContext db)
|
||||
var suggestionIds = player.Suggestions.Select(s => s.Id).ToList();
|
||||
if (suggestionIds.Count > 0)
|
||||
{
|
||||
await db.Suggestions
|
||||
.Where(s => s.ParentSuggestionId != null && suggestionIds.Contains(s.ParentSuggestionId.Value))
|
||||
.ExecuteUpdateAsync(s => s.SetProperty(x => x.ParentSuggestionId, (int?)null));
|
||||
await db.Suggestions.Where(s => s.ParentSuggestionId != null && suggestionIds.Contains(s.ParentSuggestionId.Value)).ExecuteUpdateAsync(s => s.SetProperty(x => x.ParentSuggestionId, (int?)null));
|
||||
|
||||
await db.Votes.Where(v => suggestionIds.Contains(v.SuggestionId)).ExecuteDeleteAsync();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ using GameList.Data;
|
||||
using GameList.Domain;
|
||||
using GameList.Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.RateLimiting;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace GameList.Endpoints;
|
||||
@@ -24,7 +23,7 @@ public static class AuthEndpoints
|
||||
{
|
||||
if (!AuthValidator.TryValidateRegistration(request, out var validated, out var registrationError))
|
||||
{
|
||||
authAttemptMonitor.RecordFailure(ctx, "auth-register", request.Username?.Trim() ?? "unknown", "validation-failed");
|
||||
authAttemptMonitor.RecordFailure(ctx, "auth-register", request.Username.Trim(), "validation-failed");
|
||||
return EndpointHelpers.BadRequestError(registrationError);
|
||||
}
|
||||
|
||||
@@ -88,7 +87,7 @@ public static class AuthEndpoints
|
||||
{
|
||||
if (!AuthValidator.TryValidateLogin(request, out _, out var normalizedUsername, out var loginError))
|
||||
{
|
||||
authAttemptMonitor.RecordFailure(ctx, "auth-login", request.Username?.Trim() ?? "unknown", "validation-failed");
|
||||
authAttemptMonitor.RecordFailure(ctx, "auth-login", request.Username.Trim(), "validation-failed");
|
||||
return EndpointHelpers.BadRequestError(loginError);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,11 +38,10 @@ internal static class AuthValidator
|
||||
var hasUpper = password.Any(char.IsUpper);
|
||||
var hasLower = password.Any(char.IsLower);
|
||||
var hasDigit = password.Any(char.IsDigit);
|
||||
var hasSymbol = password.Any(ch => !char.IsLetterOrDigit(ch));
|
||||
if (!hasUpper || !hasLower || !hasDigit || !hasSymbol)
|
||||
if (!hasUpper || !hasLower || !hasDigit)
|
||||
{
|
||||
validated = default;
|
||||
error = "Password must include uppercase, lowercase, number, and symbol.";
|
||||
error = "Password must include at least one uppercase and one lowercase characters and and digit.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -95,10 +94,5 @@ internal static class AuthValidator
|
||||
return true;
|
||||
}
|
||||
|
||||
public readonly record struct ValidatedRegistration(
|
||||
string Username,
|
||||
string NormalizedUsername,
|
||||
string DisplayName,
|
||||
string? AdminKey
|
||||
);
|
||||
public readonly record struct ValidatedRegistration(string Username, string NormalizedUsername, string DisplayName, string? AdminKey);
|
||||
}
|
||||
|
||||
@@ -11,16 +11,7 @@ internal sealed class StateWorkflowService(AppDbContext db)
|
||||
{
|
||||
var state = await db.AppState.AsNoTracking().SingleAsync();
|
||||
var phase = EndpointHelpers.GetCurrentPhase(player.CurrentPhase, state.ResultsOpen);
|
||||
var summary = new StateSummaryResponse(
|
||||
phase,
|
||||
player.VotesFinal,
|
||||
player.HasJoker,
|
||||
state.ResultsOpen,
|
||||
state.UpdatedAt,
|
||||
await db.Players.CountAsync(),
|
||||
await db.Suggestions.CountAsync(),
|
||||
await db.Votes.CountAsync()
|
||||
);
|
||||
var summary = new StateSummaryResponse(phase, player.VotesFinal, player.HasJoker, state.ResultsOpen, state.UpdatedAt, await db.Players.CountAsync(), await db.Suggestions.CountAsync(), await db.Votes.CountAsync());
|
||||
return Results.Ok(summary);
|
||||
}
|
||||
|
||||
@@ -28,16 +19,7 @@ internal sealed class StateWorkflowService(AppDbContext db)
|
||||
{
|
||||
var state = await db.AppState.AsNoTracking().SingleAsync();
|
||||
var phase = EndpointHelpers.GetCurrentPhase(player.CurrentPhase, state.ResultsOpen);
|
||||
return Results.Ok(new MeResponse(
|
||||
player.Id,
|
||||
player.Username,
|
||||
player.DisplayName,
|
||||
player.IsAdmin,
|
||||
player.IsOwner,
|
||||
phase,
|
||||
player.VotesFinal,
|
||||
player.HasJoker
|
||||
));
|
||||
return Results.Ok(new MeResponse(player.Id, player.Username, player.DisplayName, player.IsAdmin, player.IsOwner, phase, player.VotesFinal, player.HasJoker));
|
||||
}
|
||||
|
||||
public async Task<IResult> NextPhaseAsync(Player player)
|
||||
|
||||
Reference in New Issue
Block a user