-
Notifications
You must be signed in to change notification settings - Fork 359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable password recovery when using ILS Authentication #3997
Open
oharacj
wants to merge
20
commits into
vufind-org:dev
Choose a base branch
from
oharacj:ilsPasswordRecovery
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
fa64c72
Initial changes to enable password recovery when using ILS Authentica…
oharacj e80e27b
Initial changes to enable password recovery when using ILS Authentica…
oharacj a06804d
Initial changes to enable password recovery when using ILS Authentica…
oharacj 6afdc74
Remove the return clause in setFollowupUrlToReferer method.
oharacj e61daf3
Updated based on Demian's comments
oharacj 95926c5
Add getPatronFromUsername to SierraRest driver.
oharacj f4e32f2
Add getPatronFromUsername to SierraRest driver.
oharacj e977b33
Add getPatronFromUsername to SierraRest driver.
oharacj 03bff51
Add getPatronFromUsername to SierraRest driver.
oharacj 58a2f2f
Multi-ILS Driver work and bug fixes
oharacj 9a8defa
Fixed some encoding and comment issues
oharacj f731cde
removed comment block in .js file
oharacj a85a525
added displayILSPasswordRecoveryLink to the top exported comment
oharacj fd7d5a7
PHP 8.3 updates and space fixes
oharacj 44d8456
PHP 8.3 updates and space fixes
oharacj 9800f5b
PHP 8.3 double quotes in template
oharacj 4183693
PHP 8.3 double quotes in template
oharacj 072d3fb
Merge branch 'dev' into ilsPasswordRecovery
oharacj 11e26a4
Remove hard-coded pin length in changePassword function
oharacj 475f222
Update settings file to remove redundant setting.
oharacj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1725,6 +1725,23 @@ public function recoverAction() | |||||||||
} elseif ($username = $this->params()->fromPost('username')) { | ||||||||||
$user = $userService->getUserByUsername($username); | ||||||||||
} | ||||||||||
//ILS Driver: | ||||||||||
//if the user hasn't logged in yet, but is found by the ILS, call function | ||||||||||
//getPatronFromUsername | ||||||||||
if (!$user && $this->formWasSubmitted() && !empty($username)) { | ||||||||||
$dbService = $this->getDbService(UserServiceInterface::class); | ||||||||||
$entity = $dbService->createEntityForUsername($username); | ||||||||||
$catalog = $this->getILS()->getDriver(); | ||||||||||
if ($catalog->supportsMethod('getPatronFromUsername', $username)) { | ||||||||||
$patron = $catalog->getPatronFromUsername($username); | ||||||||||
$entity->setEmail($patron['email']); | ||||||||||
$entity->setCatPassEnc($patron['password']); | ||||||||||
$entity->setFirstname($patron['firstname']); | ||||||||||
$entity->setLastname($patron['lastname']); | ||||||||||
$dbService->persistEntity($entity); | ||||||||||
} | ||||||||||
$user = $dbService->getUserByUsername($username); | ||||||||||
} | ||||||||||
$view = $this->createViewModel(); | ||||||||||
$view->useCaptcha = $this->captcha()->active('passwordRecovery'); | ||||||||||
// If we have a submitted form | ||||||||||
|
@@ -1766,14 +1783,18 @@ protected function sendRecoveryEmail(UserEntityInterface $user, $config) | |||||||||
$config = $this->getConfig(); | ||||||||||
$renderer = $this->getViewRenderer(); | ||||||||||
$method = $this->getAuthManager()->getAuthMethod(); | ||||||||||
// If target exists create query string to include it as part of reset url | ||||||||||
$target = $this->getRequest()->getQuery('target') ? '&target=' | ||||||||||
. $this->getRequest()->getQuery('target') : null; | ||||||||||
// Custom template for emails (text-only) | ||||||||||
$message = $renderer->render( | ||||||||||
'Email/recover-password.phtml', | ||||||||||
[ | ||||||||||
'library' => $config->Site->title, | ||||||||||
'url' => $this->getServerUrl('myresearch-verify') | ||||||||||
. '?hash=' | ||||||||||
. $user->getVerifyHash() . '&auth_method=' . $method, | ||||||||||
. $user->getVerifyHash() . '&auth_method=' . $method | ||||||||||
. $target, | ||||||||||
] | ||||||||||
); | ||||||||||
$this->getService(Mailer::class)->send( | ||||||||||
|
@@ -1938,6 +1959,7 @@ public function verifyAction() | |||||||||
$view->auth_method = $this->getAuthManager()->getAuthMethod(); | ||||||||||
$view->hash = $hash; | ||||||||||
$view->username = $user->getUsername(); | ||||||||||
$view->target = $this->getRequest()->getQuery('target') ?? null; | ||||||||||
$view->useCaptcha = $this->captcha()->active('changePassword'); | ||||||||||
$view->passwordPolicy = $this->getAuthManager() | ||||||||||
->getPasswordPolicy(); | ||||||||||
|
@@ -2066,18 +2088,23 @@ public function newPasswordAction() | |||||||||
return $view; | ||||||||||
} | ||||||||||
} | ||||||||||
// Update password | ||||||||||
// Set/Reset password | ||||||||||
try { | ||||||||||
$user = $this->getAuthManager()->updatePassword($this->getRequest()); | ||||||||||
$user = $this->getAuthManager()->newPassword($this->getRequest()); | ||||||||||
} catch (AuthException $e) { | ||||||||||
$this->flashMessenger()->addMessage($e->getMessage(), 'error'); | ||||||||||
return $view; | ||||||||||
} | ||||||||||
// Update hash to prevent reusing hash | ||||||||||
$this->getAuthManager()->updateUserVerifyHash($user); | ||||||||||
// Login | ||||||||||
if ($followUp = $this->followup()->retrieve('url')) { | ||||||||||
//This exists because the followupURL gets set to Verify which returns | ||||||||||
//an error message due to trying to check the hash a second time | ||||||||||
Comment on lines
+2101
to
+2102
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor style suggestion -- add spaces after
Suggested change
|
||||||||||
$followUpUrl = str_contains($followUp, 'Verify') ? $this->url()->fromRoute('home') : $followUp; | ||||||||||
$this->followup()->clear('url'); | ||||||||||
$this->followup()->store([], $followUpUrl); | ||||||||||
} | ||||||||||
$this->getAuthManager()->login($this->request); | ||||||||||
// Return to account home | ||||||||||
$this->flashMessenger()->addMessage('new_password_success', 'success'); | ||||||||||
return $this->redirect()->toRoute('myresearch-home'); | ||||||||||
} | ||||||||||
|
@@ -2238,9 +2265,9 @@ protected function setUpAuthenticationFromRequest() | |||||||||
$this->params()->fromPost('auth_method') | ||||||||||
) | ||||||||||
); | ||||||||||
|
||||||||||
if (!empty($method)) { | ||||||||||
$this->getAuthManager()->setAuthMethod($method); | ||||||||||
} | ||||||||||
} $this->getAuthManager()->setAuthMethod($method); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There seems to be a formatting problem here -- did this brace get moved up a line somehow? |
||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a counterpart in MultiILS that supports checking the selected target. For inspiration:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My initial work is only supposed to be for the ILS auth. MultiILS is something I'll look at in the future but I'm not sure it's part of the scope of this work. Is this piece a necessity? If so, I can start working on this and I'll resubmit when I have it done. I only have one ILS and I can't really test but I'm happy to look into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could potentially use the Demo driver as a second ILS for testing purposes, if that helps! Let me know if you need more details/help to get that set up.