Jelajahi Sumber

edited api v1 login endpoint function

CauseFX 5 tahun lalu
induk
melakukan
2fdbd4198b
1 mengubah file dengan 8 tambahan dan 30 penghapusan
  1. 8 30
      api/functions/api-functions.php

+ 8 - 30
api/functions/api-functions.php

@@ -41,44 +41,22 @@ function apiLogin()
 			),
 		)
 	);
-	foreach ($array['data'] as $items) {
-		foreach ($items as $key => $value) {
-			if ($key == 'name') {
-				$newKey = $value;
-			}
-			if ($key == 'value') {
-				$newValue = $value;
-			}
-			if (isset($newKey) && isset($newValue)) {
-				$$newKey = $newValue;
-			}
-		}
-	}
 	return login($array);
 }
 
 function login($array)
 {
 	// Grab username and Password from login form
-	$username = $password = $oAuth = $oAuthType = '';
-	foreach ($array['data'] as $items) {
-		foreach ($items as $key => $value) {
-			if ($key == 'name') {
-				$newKey = $value;
-			}
-			if ($key == 'value') {
-				$newValue = $value;
-			}
-			if (isset($newKey) && isset($newValue)) {
-				$$newKey = $newValue;
-			}
-		}
-	}
+	$username = $array['data']['username'] ?? null;
+	$password = $array['data']['password'] ?? null;
+	$oAuth = $array['data']['oAuth'] ?? null;
+	$oAuthType = $array['data']['oAuthType'] ?? null;
+	$remember = $array['data']['remember'] ?? null;
+	$tfaCode = $array['data']['tfaCode'] ?? null;
+	$loginAttempts = $array['data']['loginAttempts'] ?? null;
+	$output = $array['data']['output'] ?? null;
 	$username = (strpos($GLOBALS['authBackend'], 'emby') !== false) ? $username : strtolower($username);
 	$days = (isset($remember)) ? $GLOBALS['rememberMeDays'] : 1;
-	$oAuth = (isset($oAuth)) ? $oAuth : false;
-	$output = (isset($output)) ? $output : false;
-	$loginAttempts = (isset($loginAttempts)) ? $loginAttempts : false;
 	if ($loginAttempts > $GLOBALS['loginAttempts'] || isset($_COOKIE['lockout'])) {
 		coookieSeconds('set', 'lockout', $GLOBALS['loginLockout'], $GLOBALS['loginLockout']);
 		return 'lockout';