Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c04f802
feat: Add conditional database reset logic based on environment variable
Akith-002 Jul 18, 2025
4e33131
Add MasterFileRefNo to LandMiscellaneousMasterFiles
Akith-002 Jul 21, 2025
4d4949d
Merge pull request #68 from rithakith/main
Akith-002 Jul 21, 2025
7cc279e
Merge branch 'dev-akith' of https://github.com/rithakith/ValuationBac…
Akith-002 Jul 21, 2025
98ff9a8
Decision Field , Rating File Controller
Dulmini07 Jul 21, 2025
fecb260
Merge branch 'dev-dulmini' of https://github.com/rithakith/ValuationB…
Dulmini07 Jul 21, 2025
3803ffb
Add Password Reset functionality with OTP verification
VishwaJaya01 Jul 21, 2025
fdd1ac1
Merge branch 'dev-dulmini' of https://github.com/rithakith/ValuationB…
Dulmini07 Jul 21, 2025
e49a9e9
Decision Field
Dulmini07 Jul 21, 2025
e37b748
Merge branch 'dev-dulmini' of https://github.com/rithakith/ValuationB…
Dulmini07 Jul 21, 2025
cd83781
Decision field changes
Dulmini07 Jul 21, 2025
f33b60e
changes
Dulmini07 Jul 21, 2025
61fbd09
Merge pull request #78 from rithakith/dev-jayasankha
rithakith Jul 21, 2025
8a4e976
Merge branch 'main' into dev-dulmini
rithakith Jul 21, 2025
e9d35b8
Merge pull request #79 from rithakith/dev-dulmini
rithakith Jul 21, 2025
8c6cdb9
Merge branch 'dev-dulmini' of https://github.com/rithakith/ValuationB…
Dulmini07 Jul 22, 2025
97a7674
feat: Add LandMiscellaneousMasterFileId to LMRentalEvidence
Akith-002 Jul 22, 2025
a846bcd
Merge pull request #81 from rithakith/main
JalinaH Jul 22, 2025
8114ca2
Enhance email formatting for password reset OTP notification
VishwaJaya01 Jul 22, 2025
0ec34ed
feat: Add LALots table and related functionality
JalinaH Jul 22, 2025
67c46b3
Add LandMiscellaneousMasterFileId to LM tables and update related DTO…
Akith-002 Jul 22, 2025
c5a5d1a
Add LA Coordinate Models, DTOs, Repositories, and Services
JalinaH Jul 22, 2025
f8cc7b2
Merge pull request #80 from rithakith/dev-dulmini
rithakith Jul 22, 2025
966b69d
Merge pull request #82 from rithakith/dev-jayasankha
rithakith Jul 22, 2025
a6f3819
Refactor foreign key relationships in LACoordinate tables
JalinaH Jul 22, 2025
356364e
feat(migrations): Update PastValuationsLA MasterFileId to int with co…
JalinaH Jul 22, 2025
c4f2335
feat: Convert MasterFileId in BuildingRatesLA from string to int
JalinaH Jul 22, 2025
4b2074f
feat: Convert MasterFileId in RentalEvidencesLA from string to int
JalinaH Jul 22, 2025
9deb5ba
feat: Convert MasterFileId from string to int in SalesEvidencesLA
JalinaH Jul 22, 2025
90f621c
Merge pull request #83 from rithakith/dev-jalina
rithakith Jul 22, 2025
a70bfe9
Add MasterfileId column to multiple LA Coordinates tables with foreig…
JalinaH Jul 22, 2025
820c074
Merge pull request #85 from rithakith/main
JalinaH Jul 23, 2025
d18e0c2
Remove obj folder from Git tracking - should be ignored
JalinaH Jul 23, 2025
2e6a777
feat: Make foreign key properties nullable in LACoordinates model
JalinaH Jul 23, 2025
24fe6a7
feat: Add GetByMasterfileIdAsync methods to repositories and services…
JalinaH Jul 23, 2025
c7fd2c1
Merge pull request #84 from rithakith/dev-akith
rithakith Jul 23, 2025
7d1c9fe
Merge pull request #87 from rithakith/dev-jalina
rithakith Jul 23, 2025
0daa6a5
Merge branch 'dev-rithara' into main
rithakith Jul 23, 2025
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
37 changes: 30 additions & 7 deletions Controllers/AuthController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using ValuationBackend.Models;
using ValuationBackend.Services;
using System.Threading.Tasks;

namespace ValuationBackend.Controllers
{
Expand All @@ -9,10 +10,12 @@ namespace ValuationBackend.Controllers
public class AuthController : ControllerBase
{
private readonly IAuthService _authService;
private readonly PasswordResetService _passwordResetService;

public AuthController(IAuthService authService)
public AuthController(IAuthService authService, PasswordResetService passwordResetService)
{
_authService = authService;
_passwordResetService = passwordResetService;
}

[HttpPost("login")]
Expand Down Expand Up @@ -46,14 +49,34 @@ public async Task<IActionResult> Logout([FromBody] LogoutRequest request)
return Ok(new { msg = "success" });
}

[HttpPost("forgot-password")]
public async Task<IActionResult> ForgotPassword([FromBody] ForgotPasswordRequest request)
// --- New Password Reset Endpoints ---

[HttpPost("request-password-reset")]
public async Task<IActionResult> RequestPasswordReset([FromBody] EmailDto dto)
{
var result = await _authService.ForgotPasswordAsync(request.Username);
if (!result)
return NotFound(new { msg = "User not found" });
await _passwordResetService.RequestPasswordResetAsync(dto.Email);
return Ok(new { message = "If the email exists, an OTP has been sent." });
}

return Ok(new { msg = "success" });
[HttpPost("verify-otp")]
public async Task<IActionResult> VerifyOtp([FromBody] OtpDto dto)
{
var valid = await _passwordResetService.VerifyOtpAsync(dto.Email, dto.Otp);
if (!valid) return BadRequest(new { message = "Invalid or expired OTP." });
return Ok(new { message = "OTP verified." });
}

[HttpPost("reset-password")]
public async Task<IActionResult> ResetPassword([FromBody] ResetPasswordDto dto)
{
var success = await _passwordResetService.ResetPasswordAsync(dto.Email, dto.Otp, dto.NewPassword);
if (!success) return BadRequest(new { message = "Invalid OTP or email." });
return Ok(new { message = "Password reset successful." });
}

// --- DTOs for password reset ---
public class EmailDto { public string Email { get; set; } }
public class OtpDto { public string Email { get; set; } public string Otp { get; set; } }
public class ResetPasswordDto { public string Email { get; set; } public string Otp { get; set; } public string NewPassword { get; set; } }
}
}
69 changes: 69 additions & 0 deletions Controllers/DataMigrationController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using Microsoft.AspNetCore.Mvc;
using ValuationBackend.Data;

namespace ValuationBackend.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class DataMigrationController : ControllerBase
{
private readonly AppDbContext _context;

public DataMigrationController(AppDbContext context)
{
_context = context;
}

/// <summary>
/// Populates foreign keys for LM Rental Evidence records based on existing string references
/// </summary>
[HttpPost("populate-lm-rental-evidence-foreign-keys")]
public async Task<IActionResult> PopulateLMRentalEvidenceForeignKeys()
{
try
{
await PopulateForeignKeysMigration.PopulateLMRentalEvidenceForeignKeys(_context);
return Ok(new { message = "Foreign keys populated successfully for LM Rental Evidence." });
}
catch (Exception ex)
{
return StatusCode(500, new { error = "Failed to populate foreign keys", details = ex.Message });
}
}

/// <summary>
/// Validates foreign key relationships for LM Rental Evidence
/// </summary>
[HttpGet("validate-lm-rental-evidence-foreign-keys")]
public async Task<IActionResult> ValidateLMRentalEvidenceForeignKeys()
{
try
{
await PopulateForeignKeysMigration.ValidateForeignKeyRelationships(_context);
return Ok(new { message = "Foreign key validation completed. Check console output for details." });
}
catch (Exception ex)
{
return StatusCode(500, new { error = "Failed to validate foreign keys", details = ex.Message });
}
}

/// <summary>
/// Runs both population and validation in sequence
/// </summary>
[HttpPost("migrate-lm-rental-evidence")]
public async Task<IActionResult> MigrateLMRentalEvidence()
{
try
{
await PopulateForeignKeysMigration.PopulateLMRentalEvidenceForeignKeys(_context);
await PopulateForeignKeysMigration.ValidateForeignKeyRelationships(_context);
return Ok(new { message = "LM Rental Evidence migration completed successfully." });
}
catch (Exception ex)
{
return StatusCode(500, new { error = "Failed to migrate LM Rental Evidence", details = ex.Message });
}
}
}
}
Loading