File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
jjodel-persistence/jjodel-persistence/Controllers/API Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -300,7 +300,8 @@ public async Task<IActionResult> Login([FromBody] LoginRequest loginRequest) {
300300 [ HttpPost ( "register" ) ]
301301 public async Task < IActionResult > Register ( [ FromBody ] RegisterRequest request ) {
302302 try {
303- if ( ModelState . IsValid && await this . _userManager . FindByEmailAsync ( request . Email ) == null ) {
303+ ApplicationUser existingUser = await this . _userManager . FindByEmailAsync ( request . Email ) ;
304+ if ( ModelState . IsValid && existingUser == null ) {
304305 var user = new ApplicationUser {
305306 Id = Guid . NewGuid ( ) . ToString ( ) ,
306307 _Id = request . _Id ,
@@ -348,7 +349,11 @@ await _mailService.SendEmail(
348349 return Ok ( result ) ;
349350 }
350351 else {
351-
352+ if ( existingUser != null ) {
353+ _logger . LogWarning ( "Registration process failed: user " + request . Email + " already exists." ) ;
354+ return BadRequest ( "Registration process failed: user " + request . Email + " already exists." ) ;
355+
356+ }
352357 return BadRequest ( ) ;
353358 }
354359 }
You can’t perform that action at this time.
0 commit comments