Skip to content

Commit

Permalink
Merge branch 'dev' into dimenovels.org
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Aug 28, 2024
2 parents b36c0fe + 174c1c3 commit 891bd48
Show file tree
Hide file tree
Showing 12 changed files with 187 additions and 177 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 2.8.0 - 2024-08-28

### Added

- Added a check to verify existing password before changing to new one.
- \GeebyDeeby\Crypt\PasswordHasher class to replace laminas-crypt library.

### Changed

- Nothing.

### Removed

- Dependency on deprecated laminas-crypt library.

### Fixed

- Nothing.

## 2.7.0 - 2024-08-12

### Added
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"easyrdf/easyrdf": "^1.1.1",
"vufind-org/vufindcode": "^1.2",
"laminas/laminas-authentication": "^2.10.1",
"laminas/laminas-crypt": "^3.6.0",
"laminas/laminas-db": "^2.15.0",
"laminas/laminas-eventmanager": "^3.4.0",
"laminas/laminas-feed": "^2.17.0",
Expand Down
149 changes: 9 additions & 140 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions module/GeebyDeeby/src/GeebyDeeby/Controller/AbstractBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,24 @@ protected function forceLogin($extras = [], $forward = true)
: $this->redirect()->toRoute('login');
}

/**
* Perform authentication
*
* @param string $username Username
* @param string $password Password
*
* @return \GeebyDeeby\Authentication\Adapter
* @throws \Exception
*/
protected function getAuthenticationAdapter($username, $password)
{
return new \GeebyDeeby\Authentication\Adapter(
$this->getDbTable('user'),
$username,
$password
);
}

/**
* Format an RDF response.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

namespace GeebyDeeby\Controller;

use Laminas\Crypt\Password\Bcrypt;
use GeebyDeeby\Crypt\PasswordHasher;

/**
* Edit user controller
Expand Down Expand Up @@ -97,8 +97,8 @@ public function indexAction()

// Change password, if necessary:
if ($password && isset($view->affectedRow)) {
$bcrypt = new Bcrypt();
$view->affectedRow->Password_Hash = $bcrypt->create($password);
$hasher = new PasswordHasher();
$view->affectedRow->Password_Hash = $hasher->create($password);
$view->affectedRow->save();
}

Expand Down
12 changes: 6 additions & 6 deletions module/GeebyDeeby/src/GeebyDeeby/Controller/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ public function loginAction()
{
$view = $this->createViewModel();
if ($this->getRequest()->isPost()) {
$adapter = new \GeebyDeeby\Authentication\Adapter(
$this->getDbTable('user'),
$this->params()->fromPost('user'),
$this->params()->fromPost('pass')
);
try {
$result = $this->getAuth()->authenticate($adapter);
$result = $this->getAuth()->authenticate(
$this->getAuthenticationAdapter(
$this->params()->fromPost('user'),
$this->params()->fromPost('pass')
)
);
} catch (\GeebyDeeby\Authentication\UnapprovedUserException $e) {
$view->msg = 'Your account has not been approved yet.';
return $view;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

namespace GeebyDeeby\Controller;

use Laminas\Crypt\Password\Bcrypt;
use GeebyDeeby\Crypt\PasswordHasher;
use Laminas\Db\Adapter\Exception\InvalidQueryException;

use function call_user_func;
Expand Down Expand Up @@ -371,10 +371,10 @@ protected function getAddressID($current)
protected function migrateUserPasswords()
{
$users = $this->getDbTable('user');
$bcrypt = new Bcrypt();
$hasher = new PasswordHasher();
$count = 0;
foreach ($users->select(['Password_Hash' => '']) as $user) {
$user->Password_Hash = $bcrypt->create($user->Password);
$user->Password_Hash = $hasher->create($user->Password);
$user->save();
$count++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

namespace GeebyDeeby\Controller;

use Laminas\Crypt\Password\Bcrypt;
use GeebyDeeby\Crypt\PasswordHasher;

use function count;

Expand Down Expand Up @@ -85,11 +85,11 @@ public function indexAction()
if (count($exists) > 0) {
$view->error = 'The username you selected is already in use.';
} else {
$bcrypt = new Bcrypt();
$hasher = new PasswordHasher();
$table->insert(
[
'Username' => $view->user,
'Password_Hash' => $bcrypt->create($password1),
'Password_Hash' => $hasher->create($password1),
'Name' => $view->fullname,
'Address' => $view->address,
'Join_Reason' => $view->reason,
Expand Down
Loading

0 comments on commit 891bd48

Please sign in to comment.