Implimented the password part and authentication with Plex

pull/13/head
tidusjar 9 years ago
parent 5b0a78894e
commit 8b3f35edbb

@ -41,7 +41,7 @@ namespace PlexRequests.Api
} }
private static string Version { get; set; } private static string Version { get; set; }
public PlexAuthentication GetToken(string username, string password) public PlexAuthentication SignIn(string username, string password)
{ {
var userModel = new PlexUserRequest var userModel = new PlexUserRequest
{ {

@ -127,7 +127,7 @@ namespace PlexRequests.UI.Modules
} }
var plex = new PlexApi(); var plex = new PlexApi();
var model = plex.GetToken(user.username, user.password); var model = plex.SignIn(user.username, user.password);
if (model.user == null) if (model.user == null)
{ {

@ -30,6 +30,7 @@ using Nancy;
using Nancy.Responses.Negotiation; using Nancy.Responses.Negotiation;
using PlexRequests.Api; using PlexRequests.Api;
using PlexRequests.Api.Models;
using PlexRequests.Core; using PlexRequests.Core;
using PlexRequests.Core.SettingModels; using PlexRequests.Core.SettingModels;
using PlexRequests.UI.Models; using PlexRequests.UI.Models;
@ -72,6 +73,15 @@ namespace PlexRequests.UI.Modules
if (settings.UserAuthentication && settings.UsePassword) // Authenticate with Plex if (settings.UserAuthentication && settings.UsePassword) // Authenticate with Plex
{ {
var signedIn = (PlexAuthentication)api.SignIn(username, password);
if (signedIn.user?.authentication_token != null)
{
var users = api.GetUsers(settings.PlexAuthToken);
if (users.User.Any(x => x.Username == username))
{
authenticated = true;
}
}
} }
else if(settings.UserAuthentication) // Check against the users in Plex else if(settings.UserAuthentication) // Check against the users in Plex
{ {

Loading…
Cancel
Save