Sfoglia il codice sorgente

Fixed issue with using wrong combo of username/email/password for SSO functions

mark 5 anni fa
parent
commit
ed0b5b2605
2 ha cambiato i file con 15 aggiunte e 8 eliminazioni
  1. 1 2
      api/classes/organizr.class.php
  2. 14 6
      api/functions/sso-functions.php

+ 1 - 2
api/classes/organizr.class.php

@@ -2964,8 +2964,7 @@ class Organizr
 				if ($createToken) {
 					$this->writeLoginLog($username, 'success');
 					$this->writeLog('success', 'Login Function - A User has logged in', $username);
-					$ssoUser = ((empty($result['email'])) ? $result['username'] : (strpos($result['email'], 'placeholder') !== false)) ? $result['username'] : $result['email'];
-					$this->ssoCheck($ssoUser, $password, $token); //need to work on this
+					$this->ssoCheck($result, $password, $token); //need to work on this
 					return ($output) ? array('name' => $this->cookieName, 'token' => (string)$createToken) : true;
 				} else {
 					$this->setAPIResponse('error', 'Token creation error', 500);

+ 14 - 6
api/functions/sso-functions.php

@@ -2,21 +2,30 @@
 
 trait SSOFunctions
 {
-	
-	public function ssoCheck($username, $password, $token = null)
+	public function getSSOUserFor($app, $userobj)
+	{
+		$map = array(
+			'jellyfin' => 'username',
+			'ombi' => 'username',
+			'tautulli' => 'username'
+		);
+		return $userobj[$map[$app]];
+	}
+
+	public function ssoCheck($userobj, $password, $token = null)
 	{
 		if ($this->config['ssoPlex'] && $token) {
 			$this->coookie('set', 'mpt', $token, $this->config['rememberMeDays'], false);
 		}
 		if ($this->config['ssoOmbi']) {
 			$fallback = ($this->config['ombiFallbackUser'] !== '' && $this->config['ombiFallbackPassword'] !== '');
-			$ombiToken = $this->getOmbiToken($username, $password, $token, $fallback);
+			$ombiToken = $this->getOmbiToken($this->getSSOUserFor('ombi', $userobj), $password, $token, $fallback);
 			if ($ombiToken) {
 				$this->coookie('set', 'Auth', $ombiToken, $this->config['rememberMeDays'], false);
 			}
 		}
 		if ($this->config['ssoTautulli']) {
-			$tautulliToken = $this->getTautulliToken($username, $password, $token);
+			$tautulliToken = $this->getTautulliToken($this->getSSOUserFor('tautulli', $userobj), $password, $token);
 			if ($tautulliToken) {
 				foreach ($tautulliToken as $key => $value) {
 					$this->coookie('set', 'tautulli_token_' . $value['uuid'], $value['token'], $this->config['rememberMeDays'], true, $value['path']);
@@ -24,10 +33,9 @@ trait SSOFunctions
 			}
 		}
 		if ($this->config['ssoJellyfin']) {
-			$jellyfinToken = $this->getJellyfinToken($username, $password);
+			$jellyfinToken = $this->getJellyfinToken($this->getSSOUserFor('jellyfin', $userobj), $password);
 			if ($jellyfinToken) {
 				$this->coookie('set', 'jellyfin_credentials', $jellyfinToken, $this->config['rememberMeDays'], false);
-				$this->writeLog('success', 'ITTATOKEN: ' . $jellyfinToken);
 			}
 		}
 		return true;