mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-04-24 05:57:20 -04:00
Use IsInRole
This commit is contained in:
parent
5f3dbd8294
commit
f9d26ea1bc
2 changed files with 1 additions and 13 deletions
|
@ -282,7 +282,7 @@ namespace Jellyfin.Api.Controllers
|
|||
}
|
||||
else
|
||||
{
|
||||
if (await RequestHelpers.IsUserAdministrator(_authContext, HttpContext.Request).ConfigureAwait(false))
|
||||
if (HttpContext.User.IsInRole(UserRoles.Administrator))
|
||||
{
|
||||
var success = await _userManager.AuthenticateUser(
|
||||
user.Username,
|
||||
|
|
|
@ -76,18 +76,6 @@ namespace Jellyfin.Api.Helpers
|
|||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the user is administrator.
|
||||
/// </summary>
|
||||
/// <param name="authContext">Instance of the <see cref="IAuthorizationContext"/> interface.</param>
|
||||
/// <param name="requestContext">The <see cref="HttpRequest"/>.</param>
|
||||
/// <returns>A <see cref="bool"/> whether the user can update the entry.</returns>
|
||||
internal static async Task<bool> IsUserAdministrator(IAuthorizationContext authContext, HttpRequest requestContext)
|
||||
{
|
||||
var auth = await authContext.GetAuthorizationInfo(requestContext).ConfigureAwait(false);
|
||||
return auth.User.HasPermission(PermissionKind.IsAdministrator);
|
||||
}
|
||||
|
||||
internal static async Task<SessionInfo> GetSession(ISessionManager sessionManager, IAuthorizationContext authContext, HttpRequest request)
|
||||
{
|
||||
var authorization = await authContext.GetAuthorizationInfo(request).ConfigureAwait(false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue