mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 11:53:12 +00:00
Fix login null check order and strengthen password reset code
- Reorder null check: check user != null before accessing user.IsDeleted - Increase password reset code from 4 digits to 6 digits (10K to 1M combinations)
This commit is contained in:
parent
486233076c
commit
128ae44a0d
1 changed files with 2 additions and 2 deletions
|
|
@ -35,7 +35,7 @@ namespace Api.SeaHavenIndustries.Controllers
|
|||
public async Task<IActionResult> Login([FromBody] LoginModel model)
|
||||
{
|
||||
var user = await _userManager.FindByNameAsync(model.Username ?? "");
|
||||
if (user.IsDeleted != true && user != null && await _userManager.CheckPasswordAsync(user, model.Password ?? ""))
|
||||
if (user != null && user.IsDeleted != true && await _userManager.CheckPasswordAsync(user, model.Password ?? ""))
|
||||
{
|
||||
// Standard login without 2FA
|
||||
var userRoles = await _userManager.GetRolesAsync(user);
|
||||
|
|
@ -214,7 +214,7 @@ namespace Api.SeaHavenIndustries.Controllers
|
|||
private Random _random = new Random();
|
||||
private string GenerateRandomNo()
|
||||
{
|
||||
return _random.Next(0, 9999).ToString("D4");
|
||||
return _random.Next(0, 999999).ToString("D6");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue