Skip to content

Commit

Permalink
Module/Register: cleanup email activation model
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightprince committed May 1, 2024
1 parent 73c9479 commit 030ad66
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions application/modules/register/models/Activation_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function add($username, $password, $email): string

$data = [
'username' => $username,
'password' => $this->encrypt($username, $password, $_key, $_iv),
'password' => $this->encrypt($password, $_key, $_iv),
'secret_key' => $_key,
'secret_iv' => $_iv,
'email' => $email,
Expand All @@ -36,7 +36,7 @@ public function getAccount($key)
$row = $query->getResultArray();

if(isset($row[0]['password']))
$row[0]['password'] = $this->decrypt($row[0]['username'], $row[0]['password'], $row[0]['secret_key'], $row[0]['secret_iv']);
$row[0]['password'] = $this->decrypt($row[0]['password'], $row[0]['secret_key'], $row[0]['secret_iv']);

return $row[0];
}
Expand All @@ -59,12 +59,11 @@ public function remove($id, $username, $email)
* Basic two-way encryption
* @param string $string
* @param string $action
* @param string $username
* @param string $secret_key
* @param string $secret_iv
* @return bool|string $output
*/
private function crypt(string $string, string $action, string $username, string $secret_key, string $secret_iv): bool|string
private function crypt(string $string, string $action, string $secret_key, string $secret_iv): bool|string
{
$encrypt_method = 'AES-256-CBC';

Expand All @@ -87,27 +86,25 @@ private function crypt(string $string, string $action, string $username, string

/**
* Creates a hash of the password we enter
* @param string $username
* @param string $password
* @param string $secret_key
* @param string $secret_iv
* @return bool|string
*/
private function encrypt(string $username, string $password, string $secret_key, string $secret_iv): bool|string
private function encrypt(string $password, string $secret_key, string $secret_iv): bool|string
{
return $this->crypt($password, 'e', $username, $secret_key, $secret_iv);
return $this->crypt($password, 'e', $secret_key, $secret_iv);
}

/**
* Decrypt hashed password we enter
* @param string $username
* @param string $password
* @param string $secret_key
* @param string $secret_iv
* @return bool|string
*/
private function decrypt(string $username, string $password, string $secret_key, string $secret_iv): bool|string
private function decrypt(string $password, string $secret_key, string $secret_iv): bool|string
{
return $this->crypt($password, 'd', $username, $secret_key, $secret_iv);
return $this->crypt($password, 'd', $secret_key, $secret_iv);
}
}

0 comments on commit 030ad66

Please sign in to comment.