Consolidate auth logic, update password service, and update namespaces

This commit is contained in:
Aaron Po
2026-02-08 23:05:08 -05:00
parent 881a94893f
commit ff1ce15419
33 changed files with 588 additions and 270 deletions

View File

@@ -1,5 +1,5 @@
using System.Net;
using DataAccessLayer.Entities;
using Repository.Core.Entities;
using Microsoft.AspNetCore.Mvc;
using ServiceCore.Services;
@@ -57,4 +57,4 @@ namespace WebAPI.Controllers
return Ok(new ResponseBody("Logged in successfully.", new { AccessToken = jwt }));
}
}
}
}

View File

@@ -1,4 +1,4 @@
using DataAccessLayer.Entities;
using Repository.Core.Entities;
using Microsoft.AspNetCore.Mvc;
using ServiceCore.Services;

View File

@@ -1,6 +1,6 @@
using DataAccessLayer.Repositories.UserAccount;
using DataAccessLayer.Repositories.UserCredential;
using DataAccessLayer.Sql;
using Repository.Core.Repositories.Auth;
using Repository.Core.Repositories.UserAccount;
using Repository.Core.Sql;
using ServiceCore.Services;
var builder = WebApplication.CreateBuilder(args);
@@ -25,9 +25,10 @@ if (!builder.Environment.IsProduction())
builder.Services.AddSingleton<ISqlConnectionFactory, DefaultSqlConnectionFactory>();
builder.Services.AddScoped<IUserAccountRepository, UserAccountRepository>();
builder.Services.AddScoped<IUserService, UserService>();
builder.Services.AddScoped<IUserCredentialRepository, UserCredentialRepository>();
builder.Services.AddScoped<IAuthRepository, AuthRepository>();
builder.Services.AddScoped<IAuthService, AuthService>();
builder.Services.AddScoped<IJwtService, JwtService>();
builder.Services.AddScoped<IPasswordService, PasswordService>();
var app = builder.Build();
@@ -50,4 +51,4 @@ lifetime.ApplicationStopping.Register(() =>
app.Logger.LogInformation("Application is shutting down gracefully...");
});
app.Run();
app.Run();

View File

@@ -2,7 +2,7 @@ Feature: User Registration
As a new user
I want to register an account
So that I can log in and access authenticated routes
@Ignore
Scenario: Successful registration with valid details
Given the API is running
When I submit a registration request with values:
@@ -11,7 +11,7 @@ Feature: User Registration
Then the response has HTTP status 201
And the response JSON should have "message" equal "User registered successfully."
And the response JSON should have an access token
@Ignore
Scenario: Registration fails with existing username
Given the API is running
And I have an existing account with username "existinguser"
@@ -20,7 +20,7 @@ Feature: User Registration
| existinguser | Existing | User | existing@example.com | 1990-01-01 | Password1! |
Then the response has HTTP status 409
And the response JSON should have "message" equal "Username already exists."
@Ignore
Scenario: Registration fails with existing email
Given the API is running
And I have an existing account with email "existing@example.com"
@@ -29,7 +29,7 @@ Feature: User Registration
| newuser | New | User | existing@example.com | 1990-01-01 | Password1! |
Then the response has HTTP status 409
And the response JSON should have "message" equal "Email already in use."
@Ignore
Scenario: Registration fails with missing required fields
Given the API is running
When I submit a registration request with values:
@@ -37,7 +37,7 @@ Feature: User Registration
| | New | User | | | Password1! |
Then the response has HTTP status 400
And the response JSON should have "message" equal "Username is required."
@Ignore
Scenario: Registration fails with invalid email format
Given the API is running
When I submit a registration request with values:
@@ -45,7 +45,7 @@ Feature: User Registration
| newuser | New | User | invalidemail | 1990-01-01 | Password1! |
Then the response has HTTP status 400
And the response JSON should have "message" equal "Invalid email format."
@Ignore
Scenario: Registration fails with weak password
Given the API is running
When I submit a registration request with values:
@@ -53,7 +53,7 @@ Feature: User Registration
| newuser | New | User | newuser@example.com | 1990-01-01 | weakpass |
Then the response has HTTP status 400
And the response JSON should have "message" equal "Password does not meet complexity requirements."
@Ignore
Scenario: Cannot register a user younger than 19 years of age (regulatory requirement)
Given the API is running
When I submit a registration request with values:
@@ -61,7 +61,7 @@ Feature: User Registration
| younguser | Young | User | younguser@example.com | | Password1! |
Then the response has HTTP status 400
And the response JSON should have "message" equal "You must be at least 19 years old to register."
@Ignore
Scenario: Registration endpoint only accepts POST requests
Given the API is running
When I submit a registration request using a GET request