Procházet zdrojové kódy

Add ombi userimport on auth backend registration - #865
fix mailer center bug

causefx před 8 roky
rodič
revize
02e125912e

+ 3 - 0
api/functions/auth-functions.php

@@ -1,6 +1,9 @@
 <?php
 function authRegister($username, $password, $defaults, $email)
 {
+	if ($GLOBALS['authBackend'] !== '') {
+		ombiImport($GLOBALS['authBackend']);
+	}
 	if (createUser($username, $password, $defaults, $email)) {
 		writeLog('success', 'Registration Function - A User has registered', $username);
 		if ($GLOBALS['PHPMAILER-enabled']) {

+ 32 - 0
api/functions/homepage-connect-functions.php

@@ -1465,6 +1465,38 @@ function ombiAPI($array)
 	return ombiAction($array['data']['id'], $array['data']['action'], $array['data']['type']);
 }
 
+function ombiImport($type = null)
+{
+	if (!empty($GLOBALS['ombiURL']) && !empty($GLOBALS['ombiToken']) && !empty($type)) {
+		try {
+			$url = qualifyURL($GLOBALS['ombiURL']);
+			$headers = array(
+				"Accept" => "application/json",
+				"Content-Type" => "application/json",
+				"Apikey" => $GLOBALS['ombiToken']
+			);
+			$options = (localURL($url)) ? array('verify' => false) : array();
+			switch ($type) {
+				case 'emby':
+					$response = Requests::get($url . "/api/v1/Job/embyuserimporter", $headers, $options);
+					break;
+				case 'plex':
+					$response = Requests::get($url . "/api/v1/Job/plexuserimporter", $headers, $options);
+					break;
+				default:
+					break;
+			}
+			if ($response->success) {
+				writeLog('success', 'OMBI Connect Function - Ran User Import', 'SYSTEM');
+				return true;
+			}
+		} catch (Requests_Exception $e) {
+			writeLog('error', 'OMBI Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+		};
+	}
+	return false;
+}
+
 function ombiAction($id, $action, $type)
 {
 	if ($GLOBALS['homepageOmbiEnabled'] && !empty($GLOBALS['ombiURL']) && !empty($GLOBALS['ombiToken']) && qualifyRequest($GLOBALS['homepageOmbiAuth'])) {

+ 1 - 1
api/plugins/php-mailer.php

@@ -167,10 +167,10 @@ function phpmSendEmail($emailInfo)
 		//$mail->SMTPDebug = 3;
 		$mail->Host = $GLOBALS['PHPMAILER-smtpHost'];
 		$mail->Port = $GLOBALS['PHPMAILER-smtpHostPort'];
-		$mail->SMTPSecure = $GLOBALS['PHPMAILER-smtpHostType'];
 		if ($GLOBALS['PHPMAILER-smtpHostType'] !== 'n/a') {
 			$mail->SMTPSecure = $GLOBALS['PHPMAILER-smtpHostType'];
 		}
+		$mail->SMTPAuth = $GLOBALS['PHPMAILER-smtpHostAuth'];
 		$mail->Username = $GLOBALS['PHPMAILER-smtpHostUsername'];
 		$mail->Password = decrypt($GLOBALS['PHPMAILER-smtpHostPassword']);
 		$mail->SMTPOptions = array(