Skip to content

Commit

Permalink
Moved password hashing to separate function
Browse files Browse the repository at this point in the history
Conflicts:
	application/libraries/Aauth.php
  • Loading branch information
jacobtomlinson committed Jun 4, 2014
1 parent 8f69f7d commit b5a723e
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions application/libraries/Aauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,17 @@ public function __construct() {
$this->config_vars = & $this->CI->config->item('aauth');
}

/**
* Hash password
* Hash the password for storage in the database
* @param string $pass Password to hash
* @return string Hashed password
*/
function hash_password($pass) {

return md5($pass);
}

// open sessions
public function login($email, $pass, $remember = FALSE) {

// remove cookies first
Expand Down Expand Up @@ -74,8 +83,8 @@ public function login($email, $pass, $remember = FALSE) {
$query = null;
$query = $this->CI->db->where('email', $email);

// database stores pasword md5 cripted
$query = $this->CI->db->where('pass', md5($pass));
// Database stores pasword hashed password
$query = $this->CI->db->where('pass', hash_password($pass));
$query = $this->CI->db->where('banned', 0);
$query = $this->CI->db->get($this->config_vars['users']);

Expand Down Expand Up @@ -306,7 +315,7 @@ public function create_user($email, $pass, $name='') {

$data = array(
'email' => $email,
'pass' => md5($pass),
'pass' => hash_password($pass),
'name' => $name,
//'banned' => 1
);
Expand Down Expand Up @@ -344,7 +353,7 @@ public function update_user($user_id, $email = FALSE, $pass = FALSE, $name = FAL
}

if ($pass != FALSE) {
$data['pass'] = md5($pass);
$data['pass'] = hash_password($pass);
}

if ($name != FALSE) {
Expand Down Expand Up @@ -506,7 +515,7 @@ public function reset_password($user_id, $ver_code){

$data = array(
'verification_code' => '',
'pass' => md5($pass)
'pass' => hash_password($pass)
);

$row = $query->row();
Expand Down

0 comments on commit b5a723e

Please sign in to comment.