mirror of
https://github.com/RedWizardsLab/EchoHub.git
synced 2026-09-04 08:36:11 +02:00
feat: Refactor authentication and token management
- Updated EchoHubConnection to use ApiClient for token retrieval. - Introduced ValidationConstants for common validation patterns and limits. - Enhanced AuthDtos with refresh token support and expiration details. - Added new ChatDtos for channel creation and topic updates. - Created CommonDtos for error and paginated responses. - Implemented RefreshToken model for managing refresh tokens. - Modified JwtTokenService to generate and hash refresh tokens. - Updated AuthController to handle registration, login, token refresh, and logout with improved error handling. - Enhanced ChannelsController with channel creation, topic updates, and pagination for channel retrieval. - Added FilesController for file management with rate limiting. - Improved UsersController for profile updates and avatar uploads with validation. - Integrated rate limiting across controllers to manage request load. - Introduced FileValidationHelper for validating uploaded image files. - Updated database context to include RefreshToken and enforce unique constraints. - Enhanced ChatHub for improved channel and message handling with validation. - Updated Program.cs to configure rate limiting and CORS policies.
This commit is contained in:
@@ -243,15 +243,24 @@ public static class Program
|
||||
|
||||
_commandHandler.OnSetTopic += async (topic) =>
|
||||
{
|
||||
// Topic setting would go through an API endpoint if available.
|
||||
// For now, show as a system message.
|
||||
await Task.CompletedTask;
|
||||
_app.Invoke(() =>
|
||||
if (_apiClient is null)
|
||||
return;
|
||||
|
||||
var channel = _mainWindow!.CurrentChannel;
|
||||
if (string.IsNullOrEmpty(channel))
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
var channel = _mainWindow!.CurrentChannel;
|
||||
if (!string.IsNullOrEmpty(channel))
|
||||
_mainWindow.AddSystemMessage(channel, $"Topic set to: {topic}");
|
||||
});
|
||||
await _apiClient.UpdateChannelTopicAsync(channel, topic);
|
||||
_app.Invoke(() =>
|
||||
_mainWindow!.AddSystemMessage(channel, $"Topic set to: {topic}"));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_app.Invoke(() =>
|
||||
_mainWindow!.ShowError($"Failed to set topic: {ex.Message}"));
|
||||
}
|
||||
};
|
||||
|
||||
_commandHandler.OnListUsers += async () =>
|
||||
@@ -340,7 +349,7 @@ public static class Program
|
||||
await _connection.DisposeAsync();
|
||||
}
|
||||
|
||||
_connection = new EchoHubConnection(result.ServerUrl, _apiClient.Token!);
|
||||
_connection = new EchoHubConnection(result.ServerUrl, _apiClient);
|
||||
WireConnectionEvents(_connection);
|
||||
|
||||
await _connection.ConnectAsync();
|
||||
|
||||
Reference in New Issue
Block a user