< Summary - Jellyfin

Information
Class: Jellyfin.Server.Implementations.Events.Consumers.Security.AuthenticationSucceededLogger
Assembly: Jellyfin.Server.Implementations
File(s): /srv/git/jellyfin/Jellyfin.Server.Implementations/Events/Consumers/Security/AuthenticationSucceededLogger.cs
Line coverage
100%
Covered lines: 3
Uncovered lines: 0
Coverable lines: 3
Total lines: 48
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%

File(s)

/srv/git/jellyfin/Jellyfin.Server.Implementations/Events/Consumers/Security/AuthenticationSucceededLogger.cs

#LineLine coverage
 1using System.Globalization;
 2using System.Threading.Tasks;
 3using Jellyfin.Data.Entities;
 4using MediaBrowser.Controller.Events;
 5using MediaBrowser.Controller.Events.Authentication;
 6using MediaBrowser.Model.Activity;
 7using MediaBrowser.Model.Globalization;
 8
 9namespace Jellyfin.Server.Implementations.Events.Consumers.Security
 10{
 11    /// <summary>
 12    /// Creates an entry in the activity log when there is a successful login attempt.
 13    /// </summary>
 14    public class AuthenticationSucceededLogger : IEventConsumer<AuthenticationResultEventArgs>
 15    {
 16        private readonly ILocalizationManager _localizationManager;
 17        private readonly IActivityManager _activityManager;
 18
 19        /// <summary>
 20        /// Initializes a new instance of the <see cref="AuthenticationSucceededLogger"/> class.
 21        /// </summary>
 22        /// <param name="localizationManager">The localization manager.</param>
 23        /// <param name="activityManager">The activity manager.</param>
 24        public AuthenticationSucceededLogger(ILocalizationManager localizationManager, IActivityManager activityManager)
 25        {
 1626            _localizationManager = localizationManager;
 1627            _activityManager = activityManager;
 1628        }
 29
 30        /// <inheritdoc />
 31        public async Task OnEvent(AuthenticationResultEventArgs eventArgs)
 32        {
 33            await _activityManager.CreateAsync(new ActivityLog(
 34                string.Format(
 35                    CultureInfo.InvariantCulture,
 36                    _localizationManager.GetLocalizedString("AuthenticationSucceededWithUserName"),
 37                    eventArgs.User.Name),
 38                "AuthenticationSucceeded",
 39                eventArgs.User.Id)
 40            {
 41                ShortOverview = string.Format(
 42                    CultureInfo.InvariantCulture,
 43                    _localizationManager.GetLocalizedString("LabelIpAddressValue"),
 44                    eventArgs.SessionInfo?.RemoteEndPoint),
 45            }).ConfigureAwait(false);
 46        }
 47    }
 48}