28 lines
1.0 KiB
C#
28 lines
1.0 KiB
C#
// ***********************************************************************
|
|
// <copyright file="Helper.cs">
|
|
// Heath
|
|
// </copyright>
|
|
// ***********************************************************************
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
using System.Security.Claims;
|
|
|
|
namespace Core.Cerberos.Provider.Providers
|
|
{
|
|
/// <summary>
|
|
/// Provides helper methods for common operations.
|
|
/// </summary>
|
|
public static class Helper
|
|
{
|
|
/// <summary>
|
|
/// Retrieves the email address of the authenticated user from the HTTP context.
|
|
/// </summary>
|
|
/// <param name="httpContextAccessor">The IHttpContextAccessor instance to access the current HTTP context.</param>
|
|
/// <returns>The email address of the authenticated user, or an empty string if not available.</returns>
|
|
public static string GetEmail(IHttpContextAccessor httpContextAccessor)
|
|
{
|
|
return httpContextAccessor.HttpContext?.User?.FindFirst(ClaimTypes.Email)?.Value ?? "";
|
|
}
|
|
}
|
|
}
|