1
0
mirror of https://github.com/misterunknown/ifm.git synced 2025-08-11 10:34:00 +02:00

fixed use of undefined index when checking for authentication

This commit is contained in:
Marco Dickert
2017-03-05 22:26:50 +01:00
parent 83087ed928
commit b5a0bb1d0f
2 changed files with 28 additions and 24 deletions

22
ifm.php
View File

@@ -1757,7 +1757,7 @@ ifm.init();
*/
public function checkAuth() {
if(IFMConfig::auth == 1 && $_SESSION['auth'] !== true) {
if( IFMConfig::auth == 1 && ( ! isset( $_SESSION['auth'] ) || $_SESSION['auth'] !== true ) ) {
$login_failed = false;
if( isset( $_POST["user"] ) && isset( $_POST["pass"] ) ) {
if( $this->checkCredentials( $_POST["user"], $_POST["pass"] ) ) {
@@ -1769,16 +1769,18 @@ ifm.init();
}
}
if($_SESSION['auth'] !== true) {
if(isset($_POST["api"]) && $login_failed === true)
echo json_encode(array("status"=>"ERROR", "message"=>"authentication failed"));
elseif(isset($_POST["api"]) && $login_failed !== true)
echo json_encode(array("status"=>"ERROR", "message"=>"not authenticated"));
else
$this->loginForm($login_failed);
return false;
} else {
if( isset( $_SESSION['auth'] ) && $_SESSION['auth'] === true ) {
return true;
} else {
if( isset( $_POST["api"] ) ) {
if( $login_failed === true )
echo json_encode( array( "status"=>"ERROR", "message"=>"authentication failed" ) );
else
echo json_encode( array( "status"=>"ERROR", "message"=>"not authenticated" ) );
} else {
$this->loginForm($login_failed);
}
return false;
}
} else {
return true;

View File

@@ -596,7 +596,7 @@ class IFM {
*/
public function checkAuth() {
if(IFMConfig::auth == 1 && $_SESSION['auth'] !== true) {
if( IFMConfig::auth == 1 && ( ! isset( $_SESSION['auth'] ) || $_SESSION['auth'] !== true ) ) {
$login_failed = false;
if( isset( $_POST["user"] ) && isset( $_POST["pass"] ) ) {
if( $this->checkCredentials( $_POST["user"], $_POST["pass"] ) ) {
@@ -608,16 +608,18 @@ class IFM {
}
}
if($_SESSION['auth'] !== true) {
if(isset($_POST["api"]) && $login_failed === true)
echo json_encode(array("status"=>"ERROR", "message"=>"authentication failed"));
elseif(isset($_POST["api"]) && $login_failed !== true)
echo json_encode(array("status"=>"ERROR", "message"=>"not authenticated"));
else
$this->loginForm($login_failed);
return false;
} else {
if( isset( $_SESSION['auth'] ) && $_SESSION['auth'] === true ) {
return true;
} else {
if( isset( $_POST["api"] ) ) {
if( $login_failed === true )
echo json_encode( array( "status"=>"ERROR", "message"=>"authentication failed" ) );
else
echo json_encode( array( "status"=>"ERROR", "message"=>"not authenticated" ) );
} else {
$this->loginForm($login_failed);
}
return false;
}
} else {
return true;