Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

528: Deploy landing page #536

Merged
merged 119 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
d8e0c34
Auto apply migrations on API startup
jbytes1027 Mar 28, 2024
a7e9938
Setup API container
jbytes1027 Mar 28, 2024
6a5b0a0
Create mock email service
jbytes1027 Mar 28, 2024
4b4d925
Fall back to mock email service
jbytes1027 Mar 28, 2024
432dccd
Create blob storage container if needed
jbytes1027 Mar 28, 2024
3cea674
Add check that new profile image exists in blob storage
jbytes1027 Mar 28, 2024
b66be74
Setup SPA container
jbytes1027 Mar 28, 2024
796ef86
Add containerized test setup
jbytes1027 Mar 29, 2024
c7bd546
Add npm scripts
jbytes1027 Mar 29, 2024
8803582
Update readmes
jbytes1027 Mar 29, 2024
3ab571c
Add setup-tests env var explination
jbytes1027 Mar 29, 2024
f59f7e4
Remove MockEmailService email type check
jbytes1027 Mar 29, 2024
4e47dbd
Fix formatting
jbytes1027 Mar 29, 2024
8de113e
Move avatar url check to controller
jbytes1027 Mar 29, 2024
d738fa0
453: Fix highlighting tags on social
evan-scales Apr 6, 2024
968cc35
467: Fix blank pages
evan-scales Apr 6, 2024
4c46b22
466: Wrong username on chat
evan-scales Apr 6, 2024
40eaf79
fix linter
evan-scales Apr 6, 2024
6964a88
fix linter
evan-scales Apr 6, 2024
f738322
Splash page draft
jbytes1027 Apr 6, 2024
4faf722
Tweak wording
jbytes1027 Apr 7, 2024
76241e5
Fix spacing
jbytes1027 Apr 7, 2024
7ed7204
Merge pull request #476 from SCCapstone/453
jbytes1027 Apr 7, 2024
0b6ed1c
Merge pull request #478 from SCCapstone/466
jbytes1027 Apr 7, 2024
0a95cda
Merge pull request #477 from SCCapstone/467
jbytes1027 Apr 7, 2024
b455da4
detects a new request, and shows badge on pfp in the navbar
Jackson-Williams-15 Apr 7, 2024
da29ca2
Add draft discover screenshot
jbytes1027 Apr 7, 2024
9950348
fixed problem with null/empty times.
AaronKeys Apr 7, 2024
ff5d06a
config
AaronKeys Apr 7, 2024
3d876e3
lint and format
AaronKeys Apr 7, 2024
46b6e44
fixing description length to be 1500 or less for post creation error.
AaronKeys Apr 7, 2024
75b456d
disabling button if the values aren't appropriate
AaronKeys Apr 7, 2024
a395ab7
making sure that game isn't null
AaronKeys Apr 7, 2024
d1a850f
making sure game isn't ''
AaronKeys Apr 7, 2024
cc0bfb2
Merge pull request #480 from SCCapstone/LandingPage
epadams Apr 7, 2024
02e481e
fixed bug with entering correct game value then deleting not disablin…
AaronKeys Apr 7, 2024
70966c6
Update CreatePost.jsx
AaronKeys Apr 7, 2024
d330a0c
Update CreatePost.jsx
AaronKeys Apr 7, 2024
32d2f80
Update CreatePost.jsx
AaronKeys Apr 7, 2024
59491b6
Merge pull request #482 from SCCapstone/emptyTimeWorks
epadams Apr 7, 2024
1e852e8
Merge branch 'main' into ErrorPostCreation
AaronKeys Apr 7, 2024
90b2009
Convert relevant alerts to react notifications
epadams Apr 7, 2024
3efabf1
Load previous DOB value
epadams Apr 8, 2024
24864c6
added friend request button with badge, the badge disappears after ne…
Jackson-Williams-15 Apr 8, 2024
6d3a8e5
added counter to the badge avatar and some styling. i have an idea fo…
Jackson-Williams-15 Apr 8, 2024
2d49626
fixed issue with refresh after viewing the new friend requests
Jackson-Williams-15 Apr 8, 2024
d975ad3
removed the local storage stuff, it caused new friend request to be i…
Jackson-Williams-15 Apr 8, 2024
2a43044
Ignore env files in API container
jbytes1027 Apr 8, 2024
9e1aade
Add db health check to container startup
jbytes1027 Apr 8, 2024
20c7986
Added condition checks
epadams Apr 8, 2024
c9b529e
Remove restarting of API container
epadams Apr 8, 2024
c881d49
Merge main
jbytes1027 Apr 8, 2024
a05385b
fixed small error from editing directly on website.
AaronKeys Apr 8, 2024
3e120db
added decline button
Jackson-Williams-15 Apr 8, 2024
675651b
Merge remote-tracking branch 'origin/main' into FriendRequestNotifica…
Jackson-Williams-15 Apr 8, 2024
715cbac
Merge pull request #450 from SCCapstone/IsolatedTesting
evan-scales Apr 8, 2024
40a87c3
fixed the decline and accept friend request button being connected
Jackson-Williams-15 Apr 8, 2024
f8ca6f4
fixed decline button
Jackson-Williams-15 Apr 8, 2024
f043e50
format
Jackson-Williams-15 Apr 8, 2024
977d82e
Merge pull request #483 from SCCapstone/ErrorPostCreation
evan-scales Apr 8, 2024
2836eb4
Merge remote-tracking branch 'origin/main' into FriendRequestNotifica…
Jackson-Williams-15 Apr 8, 2024
a595b5e
Extract create post form
jbytes1027 Apr 9, 2024
ae713dc
Tweak post form style
jbytes1027 Apr 9, 2024
917b813
Fix #462
jbytes1027 Apr 10, 2024
b3b3159
Add null value handling to post card
jbytes1027 Apr 10, 2024
029fb91
Fix fake form requirements
jbytes1027 Apr 10, 2024
62db981
Add initial value support to PostForm
jbytes1027 Apr 10, 2024
84e1aa4
Chagne edit post to use PostForm
jbytes1027 Apr 10, 2024
b71aad2
Remove console log
jbytes1027 Apr 11, 2024
b091654
Change post search query date range to date and time range
jbytes1027 Apr 11, 2024
8d1e944
Fix formatting
jbytes1027 Apr 11, 2024
e54d274
Merge pull request #503 from SCCapstone/FixBetweenFilter
jbytes1027 Apr 11, 2024
9352e31
Merge pull request #487 from SCCapstone/FriendRequestNotification
evan-scales Apr 11, 2024
9bf7fcf
474: Change size of chat locked text & button
evan-scales Apr 11, 2024
b57dfd4
Merge pull request #504 from SCCapstone/474
jbytes1027 Apr 11, 2024
8de57dd
491: Restrict passwords
evan-scales Apr 11, 2024
d7b1d2c
495: Wrap long words (#505)
evan-scales Apr 11, 2024
13ef641
Fix formatting
jbytes1027 Apr 11, 2024
1272434
Merge pull request #501 from SCCapstone/CombineCreateAndEditPostUi
jbytes1027 Apr 11, 2024
ff35d87
491: Change pw min length to 8
evan-scales Apr 13, 2024
d4e0941
Merge pull request #511 from SCCapstone/prod
evan-scales Apr 13, 2024
7e7201e
508: Change default sort options
evan-scales Apr 13, 2024
e9efbdb
changed query limit to 12 for a more even post/user card layout
Jackson-Williams-15 Apr 14, 2024
4346fb8
Merge from main and fix conflicts
epadams Apr 14, 2024
95846a5
Format and comments
epadams Apr 14, 2024
acadef3
Remove Edit.jsx
epadams Apr 14, 2024
37db806
Updated AccountSettings.jsx
epadams Apr 14, 2024
5ce8ed4
Format
epadams Apr 14, 2024
0ad98b2
Remove nonfunctioning external library
epadams Apr 14, 2024
f000da1
Merge from main
epadams Apr 14, 2024
fada61a
Allow clearing DOB and simplified logic
epadams Apr 14, 2024
6b228ff
Add clear button to DOB picker
epadams Apr 14, 2024
28bb962
Merge pull request #512 from SCCapstone/508
epadams Apr 14, 2024
5186db2
updated query limit to 12
Jackson-Williams-15 Apr 14, 2024
7e21acb
set page to 1 on new search text
Jackson-Williams-15 Apr 14, 2024
328deac
got rid of unnecessary check
Jackson-Williams-15 Apr 14, 2024
da19722
placeholders are a little more descriptive. Added helper text to the …
Jackson-Williams-15 Apr 14, 2024
44c0a4c
Merge pull request #514 from SCCapstone/UserPagination
Jackson-Williams-15 Apr 14, 2024
e250818
517: Convert new tags to lowercase
evan-scales Apr 14, 2024
fa5efd6
517: check for existing lowercase tags
evan-scales Apr 14, 2024
46c75e5
491: Update borken tests
evan-scales Apr 14, 2024
72545cc
set page to 1 after updating search text in social
Jackson-Williams-15 Apr 14, 2024
cd5fdab
Merge remote-tracking branch 'origin/main' into 493
Jackson-Williams-15 Apr 14, 2024
96f5a90
Merge pull request #520 from SCCapstone/493
Jackson-Williams-15 Apr 14, 2024
a75881d
Merge pull request #521 from SCCapstone/518
Jackson-Williams-15 Apr 14, 2024
4a9bdb6
Merge pull request #506 from SCCapstone/491
evan-scales Apr 14, 2024
ca8faaf
ran format
Jackson-Williams-15 Apr 14, 2024
afa4313
Merge pull request #484 from SCCapstone/469
epadams Apr 15, 2024
230b250
Merge pull request #519 from SCCapstone/402
epadams Apr 15, 2024
8a389a9
508: Change dropdown to picker
evan-scales Apr 16, 2024
b782d16
Merge pull request #522 from SCCapstone/517
evan-scales Apr 16, 2024
dff287e
Use MUI variants to distinguish social buttons
jbytes1027 Apr 16, 2024
8fd84c8
Merge pull request #533 from SCCapstone/580-tweak
evan-scales Apr 16, 2024
8acdb14
Merge pull request #531 from SCCapstone/508
jbytes1027 Apr 16, 2024
8b42028
Update screenshots
jbytes1027 Apr 17, 2024
0457b5b
Fix typos
jbytes1027 Apr 17, 2024
763d178
use evans linkedin
evan-scales Apr 17, 2024
559cfed
ran formatter
evan-scales Apr 17, 2024
3572a1e
Merge pull request #535 from SCCapstone/UpdatedScreenshots
evan-scales Apr 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions FU.API/FU.API.Tests/AccountServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void Dispose()
public async void CreateUser_WithValidCredentials_ReturnsUser()
{
// Arange
Credentials credentials = new() { Username = "Test", Password = "Test" };
Credentials credentials = new() { Username = "Test", Password = "Test12345" };

// Act
ApplicationUser user = await _accountsService.Register(credentials);
Expand All @@ -62,7 +62,7 @@ public async void CreateUser_WithValidCredentials_ReturnsUser()
public async void ChangeUsername_WithValidUsername_ChangesUsername()
{
// Arange
Credentials credentials = new() { Username = "Username1", Password = "Test" };
Credentials credentials = new() { Username = "Username1", Password = "Test12345" };
string newUsername = "Username2";
ApplicationUser user = await _accountsService.Register(credentials);

Expand Down
6 changes: 3 additions & 3 deletions FU.API/FU.API.Tests/PostServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public async void GetPostUsers_WithMultipleUsers_ReturnsCorrectUserCount()
// Arrange
// Note: CreateTestPostAsync creates one user as part of creating a post
Post post = await TestsHelper.CreateTestPostAsync(_dbContext);
var user2 = await TestsHelper.CreateUserAsync(_dbContext, new Credentials() { Username = "user2", Password = "pass2", Email = "[email protected]" });
var user2 = await TestsHelper.CreateUserAsync(_dbContext, new Credentials() { Username = "user2", Password = "Test12345", Email = "[email protected]" });
await _postService.JoinPost(post.Id, user2);

// Act
Expand Down Expand Up @@ -166,7 +166,7 @@ public async void JoinPost_WhenAlreadyMember_ThrowsConflictException()
{
// Arrange
Post post = await TestsHelper.CreateTestPostAsync(_dbContext);
var user2 = await TestsHelper.CreateUserAsync(_dbContext, new Credentials() { Username = "user2", Password = "pass2", Email = "[email protected]" });
var user2 = await TestsHelper.CreateUserAsync(_dbContext, new Credentials() { Username = "user2", Password = "Test12345", Email = "[email protected]" });
await _postService.JoinPost(post.Id, user2);

// Act & Assert
Expand All @@ -180,7 +180,7 @@ public async void LeavePost_WhenMember_LeavesPost()
{
// Arrange
Post post = await TestsHelper.CreateTestPostAsync(_dbContext);
var user2 = await TestsHelper.CreateUserAsync(_dbContext, new Credentials() { Username = "user2", Password = "pass2", Email = "[email protected]" });
var user2 = await TestsHelper.CreateUserAsync(_dbContext, new Credentials() { Username = "user2", Password = "Test12345", Email = "[email protected]" });
await _postService.JoinPost(post.Id, user2);

// Act
Expand Down
6 changes: 3 additions & 3 deletions FU.API/FU.API.Tests/SearchServiceSearchPostsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public async Task Search_WithSearchStartDate_FiltersOne()
// Act
(List<Post> posts, var totalResults) = await _searchService.SearchPosts(new PostQuery()
{
StartOnOrAfterDate = searchDate,
StartOnOrAfterDateTime = searchDate.ToDateTime(new TimeOnly(1, 1, 1)),
});

// Assert
Expand Down Expand Up @@ -196,7 +196,7 @@ public async Task Search_WithSearchEndDateDate_FiltersOne()
// Act
(List<Post> posts, var totalResults) = await _searchService.SearchPosts(new PostQuery()
{
EndOnOrBeforeDate = searchDate,
EndOnOrBeforeDateTime = searchDate.ToDateTime(new TimeOnly(1, 1, 1)),
});

// Assert
Expand Down Expand Up @@ -232,7 +232,7 @@ public async Task Search_WithSearchDateAsToday_SearchesAfterNow()
// Act
(List<Post> posts, var totalResults) = await _searchService.SearchPosts(new PostQuery()
{
StartOnOrAfterDate = DateOnly.FromDateTime(DateTime.UtcNow),
StartOnOrAfterDateTime = DateTime.UtcNow,
});

// Assert
Expand Down
6 changes: 3 additions & 3 deletions FU.API/FU.API.Tests/SearchServiceSearchUsersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@ public async Task Search_WithKeyword_SearchesTitleAndBio()
{
Username = "User1",
Email = "[email protected]",
Password = "Pass1"
Password = "Test12345"
});
var user2 = await TestsHelper.CreateUserAsync(_dbContext, new Credentials()
{
Username = "User2",
Email = "[email protected]",
Password = "Pass2"
Password = "Test12345"
});
var user3 = await TestsHelper.CreateUserAsync(_dbContext, new Credentials()
{
Username = "User3",
Email = "[email protected]",
Password = "Pass3"
Password = "Test12345"
});
await _userService.UpdateUserProfile(new UserProfile() { Bio = "Bio3", Id = user3.UserId });

Expand Down
2 changes: 1 addition & 1 deletion FU.API/FU.API.Tests/TestsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static async Task<Game> CreateTestGameAsync(AppDbContext dbContext)

public static async Task<ApplicationUser> CreateUserAsync(AppDbContext context)
{
Credentials credentials = new() { Username = "Test", Password = "Test", Email = "[email protected]" };
Credentials credentials = new() { Username = "Test", Password = "Test12345", Email = "[email protected]" };
return await CreateUserAsync(context, credentials);
}

Expand Down
6 changes: 6 additions & 0 deletions FU.API/FU.API/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
bin/
obj/
Dockerfile
docker-compose.yml
README.md
.env
27 changes: 25 additions & 2 deletions FU.API/FU.API/Controllers/UsersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ public class UsersController : ControllerBase
{
private readonly IUserService _userService;
private readonly ISearchService _searchService;
private readonly IStorageService _storageService;

public UsersController(IUserService userService, ISearchService searchService)
public UsersController(IUserService userService, ISearchService searchService, IStorageService storageService)
{
_userService = userService;
_searchService = searchService;
_storageService = storageService;
}

[HttpGet]
Expand Down Expand Up @@ -74,7 +76,28 @@ public async Task<IActionResult> UpdateProfile([FromBody] UserProfile profileCha
// Overrides any client given id that may differ from userId.
profileChanges.Id = userId;

var newProfile = await _userService.UpdateUserProfile(profileChanges);
// Make sure its an image already in our blob storage
// Otherwise we are unure if the image is cropped, resized, and in the right format
if (profileChanges?.PfpUrl is not null)
{
Uri avatarUri;

try
{
avatarUri = new(profileChanges.PfpUrl);
}
catch (UriFormatException)
{
throw new UnprocessableException("Invalid avatar url format.");
}

if (!(await _storageService.IsInStorageAsync(avatarUri)))
{
throw new UnprocessableException("Invalid profile picture. The image must be uploaded to our storage system");
}
}

var newProfile = await _userService.UpdateUserProfile(profileChanges!);

return Ok(newProfile);
}
Expand Down
4 changes: 2 additions & 2 deletions FU.API/FU.API/DTOs/Search/PostSearchRequestDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ public record PostSearchRequestDTO
public string? Games { get; set; }

[FromQuery]
public DateOnly? StartOnOrAfterDate { get; set; }
public DateTime? StartOnOrAfterDateTime { get; set; }

[FromQuery]
public DateOnly? EndOnOrBeforeDate { get; set; }
public DateTime? EndOnOrBeforeDateTime { get; set; }

[FromQuery]
public TimeOnly? StartOnOrAfterTime { get; set; }
Expand Down
15 changes: 15 additions & 0 deletions FU.API/FU.API/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# https://hub.docker.com/_/microsoft-dotnet
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build

# copy everything and build app
WORKDIR /source
COPY . .
RUN mkdir /app
RUN dotnet publish -o /app

# final stage/image
FROM mcr.microsoft.com/dotnet/aspnet:7.0
WORKDIR /app
COPY --from=build /app ./
ENTRYPOINT ["dotnet", "FU.API.dll"]

2 changes: 1 addition & 1 deletion FU.API/FU.API/FU.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.7" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.7" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
1 change: 0 additions & 1 deletion FU.API/FU.API/Helpers/AuthHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ private static string GetJwtSecretFromConfig(this IConfiguration configuration)
{
return configuration[ConfigKey.JwtSecret] ?? string.Empty;
}

}
4 changes: 2 additions & 2 deletions FU.API/FU.API/Helpers/Mapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ public static PostQuery ToPostQuery(this PostSearchRequestDTO dto)
{
var query = new PostQuery()
{
StartOnOrAfterDate = dto.StartOnOrAfterDate,
EndOnOrBeforeDate = dto.EndOnOrBeforeDate,
StartOnOrAfterDateTime = dto.StartOnOrAfterDateTime,
EndOnOrBeforeDateTime = dto.EndOnOrBeforeDateTime,
StartOnOrAfterTime = dto.StartOnOrAfterTime,
EndOnOrBeforeTime = dto.EndOnOrBeforeTime,
MinimumRequiredPlayers = dto.MinPlayers ?? 0,
Expand Down
2 changes: 2 additions & 0 deletions FU.API/FU.API/Interfaces/IStorageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ public interface IStorageService
public Task<Uri> UploadAsync(Stream stream, string fileName);

public Task DeleteOldUnusedFilesAsync();

public Task<bool> IsInStorageAsync(Uri uri);
}
8 changes: 4 additions & 4 deletions FU.API/FU.API/Migrations/20240317012258_ConfirmAccount.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable
#nullable disable

namespace FU.API.Migrations
{
using Microsoft.EntityFrameworkCore.Migrations;

/// <inheritdoc />
public partial class ConfirmAccount : Migration
{
Expand All @@ -22,7 +22,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
table: "Users",
type: "text",
nullable: false,
defaultValue: "");
defaultValue: string.Empty);
}

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable
#nullable disable

namespace FU.API.Migrations
{
using Microsoft.EntityFrameworkCore.Migrations;

/// <inheritdoc />
public partial class AddChatToUserRelation : Migration
{
Expand Down
4 changes: 2 additions & 2 deletions FU.API/FU.API/Models/PostQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ public record PostQuery
{
public List<int> GameIds { get; set; } = new();
public List<int> TagIds { get; set; } = new();
public DateOnly? StartOnOrAfterDate { get; set; } = null;
public DateOnly? EndOnOrBeforeDate { get; set; } = null;
public DateTime? StartOnOrAfterDateTime { get; set; } = null;
public DateTime? EndOnOrBeforeDateTime { get; set; } = null;
public TimeOnly? StartOnOrAfterTime { get; set; } = null;
public TimeOnly? EndOnOrBeforeTime { get; set; } = null;
public int MinimumRequiredPlayers { get; set; } = 0;
Expand Down
42 changes: 31 additions & 11 deletions FU.API/FU.API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ private static void Main(string[] args)
{
WebApplication app = BuildApp(args);
ConfigureApp(app);
ApplyDbMigrations(app.Configuration);
app.Run();
}

Expand Down Expand Up @@ -56,6 +57,17 @@ private static void ConfigureApp(in WebApplication app)
app.MapHub<ChatHub>("/chathub");
}

private static void ApplyDbMigrations(IConfiguration config)
{
// Create a DbContext
var optionsBuilder = new DbContextOptionsBuilder<AppDbContext>();
optionsBuilder.UseNpgsql(config[ConfigKey.ConnectionString]);
using AppDbContext dbContext = new(optionsBuilder.Options);

// Dangerous. See https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations/applying?tabs=dotnet-core-cli#apply-migrations-at-runtime
dbContext.Database.Migrate();
}

private static WebApplication BuildApp(string[] args)
{
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
Expand Down Expand Up @@ -115,7 +127,25 @@ private static WebApplication BuildApp(string[] args)
builder.Services.AddScoped<IRelationService, RelationService>();
builder.Services.AddScoped<ICommonService, CommonService>();
builder.Services.AddScoped<IStorageService, AzureBlobStorageService>();
builder.Services.AddSingleton<IEmailService, EmailService>();

if (builder.Configuration[ConfigKey.BaseSpaUrl] is null || builder.Configuration[ConfigKey.EmailConnectionString] is null)
{
if (builder.Configuration[ConfigKey.EmailConnectionString] is null)
{
Console.WriteLine($"Email service connection string is not configured. Missing {ConfigKey.EmailConnectionString}. See README for adding. Will use mock email service.");
}

if (builder.Configuration[ConfigKey.BaseSpaUrl] is null)
{
Console.WriteLine($"The base SPA Url is not configured. Missing {ConfigKey.BaseSpaUrl}. See README for adding. Will use mock email service.");
}

builder.Services.AddSingleton<IEmailService, MockEmailService>();
}
else
{
builder.Services.AddSingleton<IEmailService, EmailService>();
}

builder.Services.AddSignalR(options =>
{
Expand Down Expand Up @@ -200,15 +230,5 @@ private static void AssertCriticalConfigValuesExist(in ConfigurationManager conf
{
throw new Exception($"Storage connection string is not configured. Missing {ConfigKey.StorageConnectionString}. See README for adding.");
}

if (config[ConfigKey.EmailConnectionString] is null)
{
throw new Exception($"Email service connection string is not configured. Missing {ConfigKey.EmailConnectionString}. See README for adding.");
}

if (config[ConfigKey.BaseSpaUrl] is null)
{
throw new Exception($"The base SPA Url is not configured. Missing {ConfigKey.BaseSpaUrl}. See README for adding.");
}
}
}
7 changes: 7 additions & 0 deletions FU.API/FU.API/Services/AccountsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ public async Task<ApplicationUser> Register(Credentials credentials)
throw new ConflictException("User with email already exists");
}

// Make sure the password is valid
// Must be 5 characters or longer, and contain at least one special character or number
if (credentials.Password.Length < 8 || !credentials.Password.Any(c => char.IsDigit(c) || char.IsPunctuation(c)))
{
throw new BadRequestException("Password must be at least 8 characters long and contain at least one special character or number");
}

_dbContext.Users.Add(new ApplicationUser()
{
Username = credentials.Username,
Expand Down
Loading
Loading