Implement username change functionality and enhance Telegram bot registration flow
CI / Backend (build + test) (push) Successful in 1m22s
CI / Frontend (lint + typecheck + build) (push) Successful in 32s

- Added a new endpoint for changing usernames, allowing users to update their login credentials via the API.
- Integrated username change functionality into the settings page, providing a user-friendly interface for this action.
- Enhanced the Telegram bot to support user registration directly through the bot, including username generation and password delivery.
- Updated documentation to reflect the new username change endpoint and registration flow through the Telegram bot.
This commit is contained in:
Leonid Pershin
2026-07-02 18:57:36 +03:00
parent 1452e5c4af
commit cf3d8fcad8
19 changed files with 346 additions and 22 deletions
@@ -77,6 +77,23 @@ internal sealed class IdentityService(UserManager<AppUser> userManager, SignInMa
string.Join("; ", result.Errors.Select(e => e.Description))));
}
public async Task<Result> ChangeUserNameAsync(Guid userId, string newUserName, CancellationToken cancellationToken)
{
var user = await userManager.FindByIdAsync(userId.ToString());
if (user is null)
return Result.Failure(AuthErrors.Unauthorized);
var result = await userManager.SetUserNameAsync(user, newUserName);
if (result.Succeeded)
return Result.Success();
return result.Errors.Any(e => e.Code == nameof(IdentityErrorDescriber.DuplicateUserName))
? Result.Failure(AuthErrors.DuplicateUserName)
: Result.Failure(Error.Validation(
"Auth.UserNameChangeFailed",
string.Join("; ", result.Errors.Select(e => e.Description))));
}
public async Task<Result> ActivateUserAsync(Guid userId, Guid activatedBy, CancellationToken cancellationToken)
{
var user = await userManager.FindByIdAsync(userId.ToString());