|
|
@@ -154,25 +154,25 @@ function plugin_auth_plex($username, $password)
|
|
|
{
|
|
|
try {
|
|
|
$usernameLower = strtolower($username);
|
|
|
- if ((!empty($GLOBALS['plexAdmin']) && strtolower($GLOBALS['plexAdmin']) == $usernameLower) || checkPlexUser($username)) {
|
|
|
- //Login User
|
|
|
- $url = 'https://plex.tv/users/sign_in.json';
|
|
|
- $headers = array(
|
|
|
- 'Accept' => 'application/json',
|
|
|
- 'Content-Type' => 'application/x-www-form-urlencoded',
|
|
|
- 'X-Plex-Product' => 'Organizr',
|
|
|
- 'X-Plex-Version' => '2.0',
|
|
|
- 'X-Plex-Client-Identifier' => $GLOBALS['uuid'],
|
|
|
- );
|
|
|
- $data = array(
|
|
|
- 'user[login]' => $username,
|
|
|
- 'user[password]' => $password,
|
|
|
- );
|
|
|
- $response = Requests::post($url, $headers, $data);
|
|
|
- if ($response->success) {
|
|
|
- $json = json_decode($response->body, true);
|
|
|
- if ((is_array($json) && isset($json['user']) && isset($json['user']['username'])) && strtolower($json['user']['username']) == $usernameLower || strtolower($json['user']['email']) == $usernameLower) {
|
|
|
- //writeLog("success", $json['user']['username']." was logged into organizr using plex credentials");
|
|
|
+ //Login User
|
|
|
+ $url = 'https://plex.tv/users/sign_in.json';
|
|
|
+ $headers = array(
|
|
|
+ 'Accept' => 'application/json',
|
|
|
+ 'Content-Type' => 'application/x-www-form-urlencoded',
|
|
|
+ 'X-Plex-Product' => 'Organizr',
|
|
|
+ 'X-Plex-Version' => '2.0',
|
|
|
+ 'X-Plex-Client-Identifier' => $GLOBALS['uuid'],
|
|
|
+ );
|
|
|
+ $data = array(
|
|
|
+ 'user[login]' => $username,
|
|
|
+ 'user[password]' => $password,
|
|
|
+ );
|
|
|
+ $response = Requests::post($url, $headers, $data);
|
|
|
+ if ($response->success) {
|
|
|
+ $json = json_decode($response->body, true);
|
|
|
+ if ((is_array($json) && isset($json['user']) && isset($json['user']['username'])) && strtolower($json['user']['username']) == $usernameLower || strtolower($json['user']['email']) == $usernameLower) {
|
|
|
+ //writeLog("success", $json['user']['username']." was logged into organizr using plex credentials");
|
|
|
+ if ((!empty($GLOBALS['plexAdmin']) && (strtolower($GLOBALS['plexAdmin']) == strtolower($json['user']['username'])) || (strtolower($GLOBALS['plexAdmin']) == strtolower($json['user']['email']))) || checkPlexUser($json['user']['username'])) {
|
|
|
return array(
|
|
|
'username' => $json['user']['username'],
|
|
|
'email' => $json['user']['email'],
|