mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
Added the ability to get the ombi user via a Plex Token #2591
This commit is contained in:
parent
e7a776640b
commit
07f3f4162a
3 changed files with 42 additions and 3 deletions
|
@ -29,6 +29,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Ombi.Api.Emby;
|
||||
|
@ -101,6 +102,22 @@ namespace Ombi.Core.Authentication
|
|||
return true;
|
||||
}
|
||||
|
||||
public async Task<OmbiUser> GetOmbiUserFromPlexToken(string plexToken)
|
||||
{
|
||||
var plexAccount = await _plexApi.GetAccount(plexToken);
|
||||
|
||||
// Check for a ombi user
|
||||
if (plexAccount?.user != null)
|
||||
{
|
||||
var potentialOmbiUser = await Users.FirstOrDefaultAsync(x =>
|
||||
x.ProviderUserId.Equals(plexAccount.user.id, StringComparison.InvariantCultureIgnoreCase));
|
||||
return potentialOmbiUser;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sign the user into plex and make sure we can get the authentication token.
|
||||
/// <remarks>We do not check if the user is in the owners "friends" since they must have a local user account to get this far</remarks>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue