Bugzilla – Attachment 134772 Details for
Bug 30700
Patrons who can log into staff interface should be able to change their own password
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30700: Allow staff users to change their password via staff client
Bug-30700-Allow-staff-users-to-change-their-passwo.patch (text/plain), 6.41 KB, created by
David Nind
on 2022-05-09 04:18:15 UTC
(
hide
)
Description:
Bug 30700: Allow staff users to change their password via staff client
Filename:
MIME Type:
Creator:
David Nind
Created:
2022-05-09 04:18:15 UTC
Size:
6.41 KB
patch
obsolete
>From 06e7ba7179c2cfe375ba30033203ac6da90a16b6 Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Fri, 6 May 2022 02:04:35 +0000 >Subject: [PATCH] Bug 30700: Allow staff users to change their password via > staff client > >Patrons who can log into the staff client (have the 'catalogue' >permission) should be able to change their own password. > >To test: >1) Create a user with only 'catalogue' permissions (Patron A) >2) Log in to the staff client as Patron A >3) Click the menu with your username in the top-right of the window. >Click the 'your account' menu link. >4) Confirm you are forced to a login screen, so you cannot view your >account, which is where the 'change password' link is normally found. >5) Try to access the page to change your password directly >http://localhost:8081/cgi-bin/koha/members/member-password.pl?member=X >(swap Patron A's borrowernumber in). Confirm you are forced to a login >screen. >6) Apply this patch and restart services. Go back to the mainpage logged >in as Patron A. >7) Click the menu with your username in the top-right of the window. >Notice there is now a 'Change password' menu link. Go to 'change >password'. >8) Confirm you are now shown a page to change your password. Change your >password, and confirm you are redirect to the mainpage. >9) Try to access the page to change someone else's page directly >http://localhost:8081/cgi-bin/koha/members/member-password.pl?member=X >(swap some other borrowernumber in). Confirm you are redirected to a >404. >10) Log out and log back in as your original borrower. Confirm you are >able to change your password as normal. > >Sponsored-by: Education Services Australia SCIS > >Signed-off-by: David Nind <david@davidnind.com> >--- > .../intranet-tmpl/prog/en/includes/header.inc | 5 +++++ > .../prog/en/includes/members-toolbar.inc | 4 +++- > members/member-password.pl | 18 +++++++++++++++--- > 3 files changed, 23 insertions(+), 4 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >index 754ac0d294..2e4fbb6ba9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >@@ -192,6 +192,11 @@ > <a class="toplinks" href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% loggedinusernumber | html %]">My checkouts</a> > </li> > [% END %] >+ >+ <li class ="toplinks-changepassword"> >+ <a class="toplinks" href="/cgi-bin/koha/members/member-password.pl?member=[% loggedinusernumber | html %]">Change password</a> >+ </li> >+ > <li> > <a id="logout" class="toplinks" href="/cgi-bin/koha/mainpage.pl?logout.x=1">Log out</a> > </li> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc >index 0466779a60..adcc1d982a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc >@@ -13,9 +13,11 @@ > [% IF patron.is_adult AND Koha.Preference("borrowerRelationship") %] > <a id="addchild" class="btn btn-default" href="/cgi-bin/koha/members/memberentry.pl?op=add&guarantor_id=[% patron.borrowernumber | html %]&category_type=C"><i class="fa fa-plus"></i> Add guarantee</a> > [% END %] >- <a id="changepassword" class="btn btn-default" href="/cgi-bin/koha/members/member-password.pl?member=[% patron.borrowernumber | html %]"><i class="fa fa-lock"></i> Change password</a> > <a id="duplicate" class="btn btn-default" href="/cgi-bin/koha/members/memberentry.pl?op=duplicate&borrowernumber=[% patron.borrowernumber | html %]"><i class="fa fa-copy"></i> Duplicate</a> > [% END %] >+ [% IF CAN_user_borrowers_edit_borrowers || patron.borrowernumber == logged_in_user.borrowernumber %] >+ <a id="changepassword" class="btn btn-default" href="/cgi-bin/koha/members/member-password.pl?member=[% patron.borrowernumber | html %]"><i class="fa fa-lock"></i> Change password</a> >+ [% END %] > > [% IF CAN_user_circulate_circulate_remaining_permissions %] > <div class="btn-group"> >diff --git a/members/member-password.pl b/members/member-password.pl >index d44f29d0f7..40adcfb0fc 100755 >--- a/members/member-password.pl >+++ b/members/member-password.pl >@@ -28,11 +28,19 @@ my ( $template, $loggedinuser, $cookie, $staffflags ) = get_template_and_user( > template_name => "members/member-password.tt", > query => $input, > type => "intranet", >- flagsrequired => { borrowers => 'edit_borrowers' }, >+ flagsrequired => { catalogue => 1 }, > } > ); > > my $patron_id = $input->param('member'); >+my $logged_in_user = Koha::Patrons->find( $loggedinuser ); >+ >+if ( !$logged_in_user->has_permission({ borrowers => 'edit_borrowers' }) and $loggedinuser != $patron_id ) { >+ print $input->redirect("/cgi-bin/koha/errors/404.pl"); >+ >+} else { >+# patron has permission to edit other borrowers, or is changing their own password >+ > my $destination = $input->param('destination'); > my $newpassword = $input->param('newpassword'); > my $newpassword2 = $input->param('newpassword2'); >@@ -40,7 +48,6 @@ my $new_user_id = $input->param('newuserid'); > > my @errors; > >-my $logged_in_user = Koha::Patrons->find( $loggedinuser ); > my $patron = Koha::Patrons->find( $patron_id ); > output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); > >@@ -68,7 +75,10 @@ if ( $newpassword and not @errors) { > $patron->userid($new_user_id)->store > if $new_user_id and $new_user_id ne $patron->userid; > $template->param( newpassword => $newpassword ); >- if ( $destination eq 'circ' ) { >+ if ( !$patron->has_permission({ borrowers => 'edit_borrowers' }) ) { >+ print $input->redirect("/cgi-bin/koha/mainpage.pl"); >+ } >+ elsif ( $destination eq 'circ' ) { > print $input->redirect("/cgi-bin/koha/circ/circulation.pl?findborrower=" . $patron->cardnumber); > } > else { >@@ -107,4 +117,6 @@ if ( scalar(@errors) ) { > } > } > >+} # patron has permission to edit other borrowers, or is changing their own password >+ > output_html_with_http_headers $input, $cookie, $template->output; >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30700
:
134669
|
134772
|
135087
|
135173
|
135174
|
135176
|
153248
|
153249
|
153250
|
153290
|
153291
|
153292
|
156512
|
156513
|
156514
|
156515
|
156516