mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
Add username validation and initial friends feature
Introduced a UsernameValidator with Cyrillic and length checks, integrated into AuthService and registration flow. Added InvalidUsernameException and related interface. Updated User model to support friend requests, added FriendsController (stub), and configured Friendship entity in EF Core. Adjusted UserValidator max name length and removed navigation properties from PrivateChat.
This commit is contained in:
@@ -35,7 +35,8 @@ public class AuthController : Controller
|
||||
|
||||
var invite = _invitesService.Validate(registrationRequest.InviteLink);
|
||||
|
||||
var token = await _accountService.RegistrationAsync(registrationRequest.Name, registrationRequest.Password, invite);
|
||||
var token = await _accountService.RegistrationAsync(registrationRequest.Name, registrationRequest.Password,
|
||||
invite);
|
||||
_logger.LogInformation($"Register request for {registrationRequest.Name}");
|
||||
return Ok(new { token });
|
||||
}
|
||||
@@ -49,6 +50,11 @@ public class AuthController : Controller
|
||||
_logger.LogWarning(ex, $"Invite link invalid: {registrationRequest.InviteLink}");
|
||||
return BadRequest("Invite link invalid.");
|
||||
}
|
||||
catch (InvalidUsernameException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, $"Invalid username: {registrationRequest.Name}");
|
||||
return BadRequest($"Invalid username: {ex.Message}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Unexpected error during registration for user {Name}", registrationRequest.Name);
|
||||
|
||||
Reference in New Issue
Block a user