mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 22:10:45 +02:00
[ticket/12352] Add legacy passwords driver for sha1 smf type passwords
PHPBB3-12352
This commit is contained in:
@@ -43,4 +43,12 @@ abstract class base implements driver_interface
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function is_legacy()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,13 @@ interface driver_interface
|
||||
*/
|
||||
public function is_supported();
|
||||
|
||||
/**
|
||||
* Check if hash type is a legacy hash type
|
||||
*
|
||||
* @return bool True if it's a legacy hash type, false if not
|
||||
*/
|
||||
public function is_legacy();
|
||||
|
||||
/**
|
||||
* Returns the hash prefix
|
||||
*
|
||||
|
58
phpBB/phpbb/passwords/driver/sha1_smf.php
Normal file
58
phpBB/phpbb/passwords/driver/sha1_smf.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package phpBB3
|
||||
* @copyright (c) 2014 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\passwords\driver;
|
||||
|
||||
/**
|
||||
* @package passwords
|
||||
*/
|
||||
class sha1_smf extends base
|
||||
{
|
||||
const PREFIX = '$smf$';
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_prefix()
|
||||
{
|
||||
return self::PREFIX;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function is_legacy()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function hash($password, $user_row = '')
|
||||
{
|
||||
return (isset($user_row['login_name'])) ? sha1(strtolower($user_row['login_name']) . $password) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function check($password, $hash, $user_row = array())
|
||||
{
|
||||
return $hash === $this->hash($password, $user_row);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_settings_only($hash, $full = false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user