Fix : Added Password_hash() #31

This commit is contained in:
Prasath Mani 2018-10-16 13:53:16 +05:30
parent 484faad1d1
commit 2331ce3d0f
2 changed files with 4 additions and 4 deletions

View file

@ -5,7 +5,7 @@ It is a simple, fast and small file manager with single php file. It is also a w
## Requirements ## Requirements
- PHP 5.2 or higher. - PHP 5.5.0 or higher.
- [Zip extension](http://php.net/manual/en/book.zip.php) for zip and unzip actions. - [Zip extension](http://php.net/manual/en/book.zip.php) for zip and unzip actions.
- Fileinfo, iconv and mbstring extensions are strongly recommended. - Fileinfo, iconv and mbstring extensions are strongly recommended.

View file

@ -14,8 +14,8 @@ $use_auth = true;
// Users: array('Username' => 'Password', 'Username2' => 'Password2', ...) // Users: array('Username' => 'Password', 'Username2' => 'Password2', ...)
$auth_users = array( $auth_users = array(
'admin' => 'admin', 'admin' => password_hash('admin', PASSWORD_DEFAULT),
'user' => '12345', 'user' => password_hash('12345', PASSWORD_DEFAULT)
); );
// Readonly users (usernames array) // Readonly users (usernames array)
@ -124,7 +124,7 @@ if ($use_auth) {
} elseif (isset($_POST['fm_usr'], $_POST['fm_pwd'])) { } elseif (isset($_POST['fm_usr'], $_POST['fm_pwd'])) {
// Logging In // Logging In
sleep(1); sleep(1);
if (isset($auth_users[$_POST['fm_usr']]) && $_POST['fm_pwd'] === $auth_users[$_POST['fm_usr']]) { if (isset($auth_users[$_POST['fm_usr']]) && password_verify($_POST['fm_pwd'], $auth_users[$_POST['fm_usr']])) {
$_SESSION['logged'] = $_POST['fm_usr']; $_SESSION['logged'] = $_POST['fm_usr'];
fm_set_msg('You are logged in'); fm_set_msg('You are logged in');
fm_redirect(FM_SELF_URL . '?p='); fm_redirect(FM_SELF_URL . '?p=');