Apply review suggestions

pull/9875/head
Shadowghost 10 months ago
parent 368f9202ce
commit 4bb17039d7

@ -1463,7 +1463,7 @@ namespace Emby.Server.Implementations.Session
if (user is null) if (user is null)
{ {
await _eventManager.PublishAsync(new GenericEventArgs<AuthenticationRequestEventArgs>(new AuthenticationRequestEventArgs(request))).ConfigureAwait(false); await _eventManager.PublishAsync(new AuthenticationRequestEventArgs(request)).ConfigureAwait(false);
throw new AuthenticationException("Invalid username or password entered."); throw new AuthenticationException("Invalid username or password entered.");
} }
@ -1499,7 +1499,7 @@ namespace Emby.Server.Implementations.Session
ServerId = _appHost.SystemId ServerId = _appHost.SystemId
}; };
await _eventManager.PublishAsync(new GenericEventArgs<AuthenticationResultEventArgs>(new AuthenticationResultEventArgs(returnResult))).ConfigureAwait(false); await _eventManager.PublishAsync(new AuthenticationResultEventArgs(returnResult)).ConfigureAwait(false);
return returnResult; return returnResult;
} }

@ -2,7 +2,6 @@
using System.Globalization; using System.Globalization;
using System.Threading.Tasks; using System.Threading.Tasks;
using Jellyfin.Data.Entities; using Jellyfin.Data.Entities;
using Jellyfin.Data.Events;
using MediaBrowser.Controller.Events; using MediaBrowser.Controller.Events;
using MediaBrowser.Controller.Events.Authentication; using MediaBrowser.Controller.Events.Authentication;
using MediaBrowser.Model.Activity; using MediaBrowser.Model.Activity;
@ -14,7 +13,7 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Security
/// <summary> /// <summary>
/// Creates an entry in the activity log when there is a failed login attempt. /// Creates an entry in the activity log when there is a failed login attempt.
/// </summary> /// </summary>
public class AuthenticationFailedLogger : IEventConsumer<GenericEventArgs<AuthenticationRequestEventArgs>> public class AuthenticationFailedLogger : IEventConsumer<AuthenticationRequestEventArgs>
{ {
private readonly ILocalizationManager _localizationManager; private readonly ILocalizationManager _localizationManager;
private readonly IActivityManager _activityManager; private readonly IActivityManager _activityManager;
@ -31,13 +30,13 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Security
} }
/// <inheritdoc /> /// <inheritdoc />
public async Task OnEvent(GenericEventArgs<AuthenticationRequestEventArgs> eventArgs) public async Task OnEvent(AuthenticationRequestEventArgs eventArgs)
{ {
await _activityManager.CreateAsync(new ActivityLog( await _activityManager.CreateAsync(new ActivityLog(
string.Format( string.Format(
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
_localizationManager.GetLocalizedString("FailedLoginAttemptWithUserName"), _localizationManager.GetLocalizedString("FailedLoginAttemptWithUserName"),
eventArgs.Argument.Username), eventArgs.Username),
"AuthenticationFailed", "AuthenticationFailed",
Guid.Empty) Guid.Empty)
{ {
@ -45,7 +44,7 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Security
ShortOverview = string.Format( ShortOverview = string.Format(
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
_localizationManager.GetLocalizedString("LabelIpAddressValue"), _localizationManager.GetLocalizedString("LabelIpAddressValue"),
eventArgs.Argument.RemoteEndPoint), eventArgs.RemoteEndPoint),
}).ConfigureAwait(false); }).ConfigureAwait(false);
} }
} }

@ -12,7 +12,7 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Security
/// <summary> /// <summary>
/// Creates an entry in the activity log when there is a successful login attempt. /// Creates an entry in the activity log when there is a successful login attempt.
/// </summary> /// </summary>
public class AuthenticationSucceededLogger : IEventConsumer<GenericEventArgs<AuthenticationResultEventArgs>> public class AuthenticationSucceededLogger : IEventConsumer<AuthenticationResultEventArgs>
{ {
private readonly ILocalizationManager _localizationManager; private readonly ILocalizationManager _localizationManager;
private readonly IActivityManager _activityManager; private readonly IActivityManager _activityManager;
@ -29,20 +29,20 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Security
} }
/// <inheritdoc /> /// <inheritdoc />
public async Task OnEvent(GenericEventArgs<AuthenticationResultEventArgs> eventArgs) public async Task OnEvent(AuthenticationResultEventArgs eventArgs)
{ {
await _activityManager.CreateAsync(new ActivityLog( await _activityManager.CreateAsync(new ActivityLog(
string.Format( string.Format(
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
_localizationManager.GetLocalizedString("AuthenticationSucceededWithUserName"), _localizationManager.GetLocalizedString("AuthenticationSucceededWithUserName"),
eventArgs.Argument.User.Name), eventArgs.User.Name),
"AuthenticationSucceeded", "AuthenticationSucceeded",
eventArgs.Argument.User.Id) eventArgs.User.Id)
{ {
ShortOverview = string.Format( ShortOverview = string.Format(
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
_localizationManager.GetLocalizedString("LabelIpAddressValue"), _localizationManager.GetLocalizedString("LabelIpAddressValue"),
eventArgs.Argument.SessionInfo?.RemoteEndPoint), eventArgs.SessionInfo?.RemoteEndPoint),
}).ConfigureAwait(false); }).ConfigureAwait(false);
} }
} }

@ -34,8 +34,8 @@ namespace Jellyfin.Server.Implementations.Events
collection.AddScoped<IEventConsumer<SubtitleDownloadFailureEventArgs>, SubtitleDownloadFailureLogger>(); collection.AddScoped<IEventConsumer<SubtitleDownloadFailureEventArgs>, SubtitleDownloadFailureLogger>();
// Security consumers // Security consumers
collection.AddScoped<IEventConsumer<GenericEventArgs<AuthenticationRequestEventArgs>>, AuthenticationFailedLogger>(); collection.AddScoped<IEventConsumer<AuthenticationRequestEventArgs>, AuthenticationFailedLogger>();
collection.AddScoped<IEventConsumer<GenericEventArgs<AuthenticationResultEventArgs>>, AuthenticationSucceededLogger>(); collection.AddScoped<IEventConsumer<AuthenticationResultEventArgs>, AuthenticationSucceededLogger>();
// Session consumers // Session consumers
collection.AddScoped<IEventConsumer<PlaybackStartEventArgs>, PlaybackStartLogger>(); collection.AddScoped<IEventConsumer<PlaybackStartEventArgs>, PlaybackStartLogger>();

@ -6,7 +6,7 @@ namespace MediaBrowser.Controller.Events.Authentication;
/// <summary> /// <summary>
/// A class representing an authentication result event. /// A class representing an authentication result event.
/// </summary> /// </summary>
public class AuthenticationRequestEventArgs public class AuthenticationRequestEventArgs : EventArgs
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="AuthenticationRequestEventArgs"/> class. /// Initializes a new instance of the <see cref="AuthenticationRequestEventArgs"/> class.

@ -1,3 +1,4 @@
using System;
using MediaBrowser.Controller.Authentication; using MediaBrowser.Controller.Authentication;
using MediaBrowser.Controller.Session; using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Dto; using MediaBrowser.Model.Dto;
@ -7,7 +8,7 @@ namespace MediaBrowser.Controller.Events.Authentication;
/// <summary> /// <summary>
/// A class representing an authentication result event. /// A class representing an authentication result event.
/// </summary> /// </summary>
public class AuthenticationResultEventArgs public class AuthenticationResultEventArgs : EventArgs
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="AuthenticationResultEventArgs"/> class. /// Initializes a new instance of the <see cref="AuthenticationResultEventArgs"/> class.

Loading…
Cancel
Save