[open-ils-commits] [GIT] Evergreen ILS branch master updated. 3891ba9abdf39dd079472e5213e7db1407e47b8d

Evergreen Git git at git.evergreen-ils.org
Tue Oct 4 13:12:45 EDT 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  3891ba9abdf39dd079472e5213e7db1407e47b8d (commit)
       via  0bb87e5c2c8cc4d8ec2e76773a26d1c5f07dbd38 (commit)
       via  7abf33b9d79e6b565621b84be2c08d68e69db5e9 (commit)
       via  1f3b8dc16977fcb1a76b22443b79fbc204be7ed2 (commit)
       via  501968ff1bb546e26e6e683901c9f58b4f187596 (commit)
       via  0d181b644230dc82ce9dfcb5b16e59276a3a1f5d (commit)
       via  412b231c92c2dc9efe221a9c00c08a97ea35a0a2 (commit)
      from  949039a1666f888444dc541ad5fa2601c57aef47 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 3891ba9abdf39dd079472e5213e7db1407e47b8d
Author: Bill Erickson <berick at esilibrary.com>
Date:   Tue Oct 4 13:00:59 2011 -0400

    Stamped upgrade script for username limit settings
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index fe76dfd..9004611 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -86,7 +86,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0631', :eg_version); -- tsbere/dbwells
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0632', :eg_version); -- tsbere/berick
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.temp.sql b/Open-ILS/src/sql/Pg/upgrade/0632.data.username-limit-settings.sql
similarity index 91%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.temp.sql
rename to Open-ILS/src/sql/Pg/upgrade/0632.data.username-limit-settings.sql
index 3e64e0b..62f70d8 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.temp.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0632.data.username-limit-settings.sql
@@ -1,3 +1,8 @@
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('0632', :eg_version);
+
 INSERT INTO config.org_unit_setting_type (name, grp, label, description, datatype) VALUES
 ( 'opac.username_regex', 'glob',
     oils_i18n_gettext('opac.username_regex',
@@ -24,3 +29,5 @@ INSERT INTO config.org_unit_setting_type (name, grp, label, description, datatyp
         'coust', 'description'),
     'bool')
 ;
+
+COMMIT;

commit 0bb87e5c2c8cc4d8ec2e76773a26d1c5f07dbd38
Author: Thomas Berezansky <tsbere at mvlc.org>
Date:   Mon Sep 26 10:19:20 2011 -0400

    Unwrapped, badly named upgrade script
    
    Signed-off-by: Thomas Berezansky <tsbere at mvlc.org>
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.temp.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.temp.sql
new file mode 100644
index 0000000..3e64e0b
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.temp.sql
@@ -0,0 +1,26 @@
+INSERT INTO config.org_unit_setting_type (name, grp, label, description, datatype) VALUES
+( 'opac.username_regex', 'glob',
+    oils_i18n_gettext('opac.username_regex',
+        'Patron username format',
+        'coust', 'label'),
+    oils_i18n_gettext('opac.username_regex',
+        'Regular expression defining the patron username format, used for patron registration and self-service username changing only',
+        'coust', 'description'),
+    'string')
+,( 'opac.lock_usernames', 'glob',
+    oils_i18n_gettext('opac.lock_usernames',
+        'Lock Usernames',
+        'coust', 'label'),
+    oils_i18n_gettext('opac.lock_usernames',
+        'If enabled username changing via the OPAC will be disabled',
+        'coust', 'description'),
+    'bool')
+,( 'opac.unlimit_usernames', 'glob',
+    oils_i18n_gettext('opac.unlimit_usernames',
+        'Allow multiple username changes',
+        'coust', 'label'),
+    oils_i18n_gettext('opac.unlimit_usernames',
+        'If enabled (and Lock Usernames is not set) patrons will be allowed to change their username when it does not look like a barcode. Otherwise username changing in the OPAC will only be allowed when the patron''s username looks like a barcode.',
+        'coust', 'description'),
+    'bool')
+;

commit 7abf33b9d79e6b565621b84be2c08d68e69db5e9
Author: Thomas Berezansky <tsbere at mvlc.org>
Date:   Sat Sep 24 22:37:22 2011 -0400

    Wording change on username error
    
    Add that they may be restricted by policy.
    
    Signed-off-by: Thomas Berezansky <tsbere at mvlc.org>
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/src/templates/opac/myopac/update_username.tt2 b/Open-ILS/src/templates/opac/myopac/update_username.tt2
index 5bfb3f1..a3a0bd2 100644
--- a/Open-ILS/src/templates/opac/myopac/update_username.tt2
+++ b/Open-ILS/src/templates/opac/myopac/update_username.tt2
@@ -7,7 +7,7 @@
 [% IF ctx.invalid_username %]
     <div id='account-update-email-error'> <!-- borrow css from update-email page -->
         [% bad_user = ctx.invalid_username | html %]
-        [% l('"<b>[_1]</b>" is not a valid username.  Usernames cannot have any spaces or look like a barcode.  Please try a different username.', bad_user) %]
+        [% l('"<b>[_1]</b>" is not a valid username.  Usernames cannot have any spaces or look like a barcode, and may be restricted by policy.  Please try a different username.', bad_user) %]
     </div>
 
 [% ELSIF ctx.username_exists %]
diff --git a/Open-ILS/web/opac/locale/en-US/opac.dtd b/Open-ILS/web/opac/locale/en-US/opac.dtd
index f1ea647..02e8231 100644
--- a/Open-ILS/web/opac/locale/en-US/opac.dtd
+++ b/Open-ILS/web/opac/locale/en-US/opac.dtd
@@ -292,7 +292,7 @@ Please see a librarian to renew your account.">
 <!ENTITY myopac.summary.username.dup "The requested username is not available.  Please choose a different username.">
 <!ENTITY myopac.summary.username.success "Username successfully updated">
 <!ENTITY myopac.summary.username.failure "Username update failed">
-<!ENTITY myopac.summary.username.invalid "Username cannot contain spaces or have the same format as a barcode">
+<!ENTITY myopac.summary.username.invalid "Username cannot contain spaces or have the same format as a barcode, and may be restricted by policy">
 <!ENTITY myopac.summary.email.error "Please enter a valid email address">
 <!ENTITY myopac.summary.email.success "Email address successfully updated">
 <!ENTITY myopac.summary.email.failed "Email address update failed">

commit 1f3b8dc16977fcb1a76b22443b79fbc204be7ed2
Author: Thomas Berezansky <tsbere at mvlc.org>
Date:   Sat Sep 24 22:31:41 2011 -0400

    Username Change Limits
    
    Default is "Only allowed to change username if it looks like a barcode".
    
    There is a "Lock Username Changes" option to disallow username changing via
    the OPAC entirely, useful if syncing usernames to an outside source.
    
    There is also a username change limit disabling option that, if enabled and
    the Lock option is disabled, allows the previous behaviour of unlimited
    username changes.
    
    Signed-off-by: Thomas Berezansky <tsbere at mvlc.org>
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
index 60e33d7..b63f89a 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
@@ -91,6 +91,25 @@ sub load_myopac_prefs {
     $self->prepare_extended_user_info;
     my $user = $self->ctx->{user};
 
+    my $lock_usernames = $self->ctx->{get_org_setting}->($e->requestor->home_ou, 'opac.lock_usernames');
+    if($lock_usernames == 1) {
+        # Policy says no username changes
+        $self->ctx->{username_change_disallowed} = 1;
+    } else {
+        my $username_unlimit = $self->ctx->{get_org_setting}->($e->requestor->home_ou, 'opac.unlimit_usernames');
+        if($username_unlimit != 1) {
+            my $regex_check = $self->ctx->{get_org_setting}->($e->requestor->home_ou, 'opac.barcode_regex');
+            if(!$regex_check) {
+                # Default is "starts with a number"
+                $regex_check = '^\d+';
+            }
+            # You already have a username?
+            if($regex_check and $self->ctx->{user}->usrname !~ /$regex_check/) {
+                $self->ctx->{username_change_disallowed} = 1;
+            }
+        }
+    }
+
     return Apache2::Const::OK unless 
         $pending_addr or $replace_addr or $delete_pending;
 
@@ -1178,6 +1197,36 @@ sub load_myopac_update_username {
     my $username = $self->cgi->param('username') || '';
     my $current_pw = $self->cgi->param('current_pw') || '';
 
+    $self->prepare_extended_user_info;
+
+    my $allow_change = 1;
+    my $regex_check;
+    my $lock_usernames = $self->ctx->{get_org_setting}->($e->requestor->home_ou, 'opac.lock_usernames');
+    if($lock_usernames == 1) {
+        # Policy says no username changes
+        $allow_change = 0;
+    } else {
+        # We want this further down.
+        $regex_check = $self->ctx->{get_org_setting}->($e->requestor->home_ou, 'opac.barcode_regex');
+        my $username_unlimit = $self->ctx->{get_org_setting}->($e->requestor->home_ou, 'opac.unlimit_usernames');
+        if($username_unlimit != 1) {
+            if(!$regex_check) {
+                # Default is "starts with a number"
+                $regex_check = '^\d+';
+            }
+            # You already have a username?
+            if($regex_check and $self->ctx->{user}->usrname !~ /$regex_check/) {
+                $allow_change = 0;
+            }
+        }
+    }
+    if(!$allow_change) {
+        my $url = $self->apache->unparsed_uri;
+        $url =~ s/update_username/prefs/;
+
+        return $self->generic_redirect($url);
+    }
+
     return Apache2::Const::OK 
         unless $self->cgi->request_method eq 'POST';
 
@@ -1187,7 +1236,6 @@ sub load_myopac_update_username {
     }
 
     # New username can't look like a barcode if we have a barcode regex
-    my $regex_check = $ctx->{get_org_setting}->($e->requestor->home_ou, 'opac.barcode_regex');
     if($regex_check and $username =~ /$regex_check/) {
         $ctx->{invalid_username} = $username;
         return Apache2::Const::OK;
diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
index eff9a54..e605528 100644
--- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql
+++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
@@ -3653,6 +3653,15 @@ INSERT into config.org_unit_setting_type
         'coust', 'description'),
     'bool', null)
 
+,( 'opac.lock_usernames', 'glob',
+    oils_i18n_gettext('opac.lock_usernames',
+        'Lock Usernames',
+        'coust', 'label'),
+    oils_i18n_gettext('opac.lock_usernames',
+        'If enabled username changing via the OPAC will be disabled',
+        'coust', 'description'),
+    'bool', null)
+
 ,( 'opac.org_unit_hiding.depth', 'opac',
     oils_i18n_gettext('opac.org_unit_hiding.depth',
         'Org Unit Hiding Depth',
@@ -3671,6 +3680,15 @@ INSERT into config.org_unit_setting_type
         'coust', 'description'),
     'interval', null)
 
+,( 'opac.unlimit_usernames', 'glob',
+    oils_i18n_gettext('opac.unlimit_usernames',
+        'Allow multiple username changes',
+        'coust', 'label'),
+    oils_i18n_gettext('opac.unlimit_usernames',
+        'If enabled (and Lock Usernames is not set) patrons will be allowed to change their username when it does not look like a barcode. Otherwise username changing in the OPAC will only be allowed when the patron''s username looks like a barcode.',
+        'coust', 'description'),
+    'bool', null)
+
 ,( 'opac.username_regex', 'glob',
     oils_i18n_gettext('opac.username_regex',
         'Patron username format',
diff --git a/Open-ILS/src/templates/opac/myopac/prefs.tt2 b/Open-ILS/src/templates/opac/myopac/prefs.tt2
index 2aeea79..87cdfd0 100644
--- a/Open-ILS/src/templates/opac/myopac/prefs.tt2
+++ b/Open-ILS/src/templates/opac/myopac/prefs.tt2
@@ -84,7 +84,11 @@
                     </div>[% l("Username") %]
                 </td>
                 <td class='light_border'>[% ctx.user.usrname | html %]</td>
+                [% IF ctx.username_change_disallowed %]
+                <td></td>
+                [% ELSE %]
                 <td class='light_border'><a href='update_username'>[% l("Change") %]</a></td>
+                [% END %]
             </tr>
             <tr>
                 <td class='color_4 light_border'>[% l("Password") %]</td>
diff --git a/Open-ILS/web/opac/skin/default/js/myopac.js b/Open-ILS/web/opac/skin/default/js/myopac.js
index 8ac1448..24caa23 100644
--- a/Open-ILS/web/opac/skin/default/js/myopac.js
+++ b/Open-ILS/web/opac/skin/default/js/myopac.js
@@ -890,6 +890,22 @@ function _myOPACSummaryShowUer(r) {
 	req.callback(myopacDrawNotes);
 	req.send();
 
+    r = fetchOrgSettingDefault(G.user.home_ou(), 'opac.lock_usernames');
+    if(r) {
+        // No changing username - Policy Lock
+        hideMe($('myopac_summary_username_change'));
+    } else {
+        r = fetchOrgSettingDefault(G.user.home_ou(), 'opac.unlimit_usernames');
+        if(!r) {
+            r = fetchOrgSettingDefault(G.user.home_ou(), 'opac.barcode_regex');
+            if(r) REGEX_BARCODE = new RegExp(r);
+
+            if(!user.usrname().match(REGEX_BARCODE)) {
+                // No changing username - You already have one!
+                hideMe($('myopac_summary_username_change'));
+            }
+        }
+    }
 
 	var tbody = $('myopac_addr_tbody');
 	var template;
@@ -1068,7 +1084,7 @@ function myOPACUpdateUsername() {
 		return;
 	}
 
-    r = fetchOrgSettingDefault(globalOrgTree.id(), 'opac.barcode_regex');
+    r = fetchOrgSettingDefault(G.user.home_ou(), 'opac.barcode_regex');
     if(r) REGEX_BARCODE = new RegExp(r);
 
     if(username.match(REGEX_BARCODE)) {

commit 501968ff1bb546e26e6e683901c9f58b4f187596
Author: Thomas Berezansky <tsbere at mvlc.org>
Date:   Sat Sep 24 21:50:15 2011 -0400

    Username Rules
    
    In TPac, enforce the "username can't look like a barcode" rule.
    Add new setting for username validation. If set, usernames must match.
    Add patron registration checks for usernames:
        No spaces
        If set, can look like a barcode (initial/no username picked)
        If set, can look like a username
        If both set, must look like one of them
    
    Signed-off-by: Thomas Berezansky <tsbere at mvlc.org>
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
index 2e6f527..60e33d7 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
@@ -1186,6 +1186,20 @@ sub load_myopac_update_username {
         return Apache2::Const::OK;
     }
 
+    # New username can't look like a barcode if we have a barcode regex
+    my $regex_check = $ctx->{get_org_setting}->($e->requestor->home_ou, 'opac.barcode_regex');
+    if($regex_check and $username =~ /$regex_check/) {
+        $ctx->{invalid_username} = $username;
+        return Apache2::Const::OK;
+    }
+
+    # New username has to look like a username if we have a username regex
+    $regex_check = $ctx->{get_org_setting}->($e->requestor->home_ou, 'opac.username_regex');
+    if($regex_check and $username !~ /$regex_check/) {
+        $ctx->{invalid_username} = $username;
+        return Apache2::Const::OK;
+    }
+
     if($username ne $e->requestor->usrname) {
 
         my $evt = $U->simplereq(
diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
index 2dfc497..eff9a54 100644
--- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql
+++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
@@ -3671,6 +3671,15 @@ INSERT into config.org_unit_setting_type
         'coust', 'description'),
     'interval', null)
 
+,( 'opac.username_regex', 'glob',
+    oils_i18n_gettext('opac.username_regex',
+        'Patron username format',
+        'coust', 'label'),
+    oils_i18n_gettext('opac.username_regex',
+        'Regular expression defining the patron username format, used for patron registration and self-service username changing only',
+        'coust', 'description'),
+    'string', null)
+
 ,( 'org.bounced_emails', 'prog',
     oils_i18n_gettext('org.bounced_emails',
         'Sending email address for patron notices',
diff --git a/Open-ILS/src/templates/opac/myopac/update_username.tt2 b/Open-ILS/src/templates/opac/myopac/update_username.tt2
index 70449cc..5bfb3f1 100644
--- a/Open-ILS/src/templates/opac/myopac/update_username.tt2
+++ b/Open-ILS/src/templates/opac/myopac/update_username.tt2
@@ -7,7 +7,7 @@
 [% IF ctx.invalid_username %]
     <div id='account-update-email-error'> <!-- borrow css from update-email page -->
         [% bad_user = ctx.invalid_username | html %]
-        [% l('"<b>[_1]</b>" is not a valid username.  Usernames cannot have any spaces.  Please try a different username.', bad_user) %]
+        [% l('"<b>[_1]</b>" is not a valid username.  Usernames cannot have any spaces or look like a barcode.  Please try a different username.', bad_user) %]
     </div>
 
 [% ELSIF ctx.username_exists %]
diff --git a/Open-ILS/web/js/ui/default/actor/user/register.js b/Open-ILS/web/js/ui/default/actor/user/register.js
index 3fe41b8..cfbefca 100644
--- a/Open-ILS/web/js/ui/default/actor/user/register.js
+++ b/Open-ILS/web/js/ui/default/actor/user/register.js
@@ -166,7 +166,9 @@ function load() {
         'ui.patron.edit.aua.post_code.example',
         'ui.patron.edit.aua.county.require',
         'format.date',
-        'ui.patron.edit.default_suggested'
+        'ui.patron.edit.default_suggested',
+        'opac.barcode_regex',
+        'opac.username_regex'
     ]);
 
     for(k in orgSettings)
@@ -987,6 +989,31 @@ function attachWidgetEvents(fmcls, fmfield, widget) {
         switch(fmfield) {
 
             case 'usrname':
+                widget.widget.isValid = function() {
+                    // No spaces
+                    if(this.attr("value").match(/\s/)) {
+                        return false;
+                    }
+                    // Can look like a barcode (for initial value)
+                    if(orgSettings['opac.barcode_regex']) {
+                        var test_regexp = new RegExp(orgSettings['opac.barcode_regex']);
+                        if(test_regexp.test(this.attr("value"))) {
+                            return true;
+                        }
+                    }
+                    // Can look like a username
+                    if(orgSettings['opac.username_regex']) {
+                        var test_regexp = new RegExp(orgSettings['opac.username_regex']);
+                        if(test_regexp.test(this.attr("value"))) {
+                            return true;
+                        }
+                    }
+                    // If we know what a barcode and username look like and we got here, reject
+                    if(orgSettings['opac.barcode_regex'] && orgSettings['opac.username_regex'])
+                        return false;
+                    // Otherwise we don't have enough info to say either way, let it through.
+                    return true;
+                }
                 dojo.connect(widget.widget, 'onChange', 
                     function() {
                         var input = findWidget('au', 'usrname');
diff --git a/Open-ILS/web/opac/skin/default/js/myopac.js b/Open-ILS/web/opac/skin/default/js/myopac.js
index 1f4108e..8ac1448 100644
--- a/Open-ILS/web/opac/skin/default/js/myopac.js
+++ b/Open-ILS/web/opac/skin/default/js/myopac.js
@@ -1076,6 +1076,14 @@ function myOPACUpdateUsername() {
         return;
     }
 
+    r = fetchOrgSettingDefault(G.user.home_ou(), 'opac.username_regex');
+    if(r) {
+        if(!username.match(new RegExp(r))) {
+            alert($('myopac_invalid_username').innerHTML);
+            return;
+        }
+    }
+
 	/* first see if the requested username is taken */
 	var req = new Request(CHECK_USERNAME, G.user.session, username);
 	req.send(true);

commit 0d181b644230dc82ce9dfcb5b16e59276a3a1f5d
Author: Thomas Berezansky <tsbere at mvlc.org>
Date:   Sat Sep 24 16:51:20 2011 -0400

    Require password to change email/username
    
    Alter backend to check password period, not just for password changes.
    Add form elements for asking for current password to JSPac and TPac.
    Add handling for said form elements where needed.
    Add handling for "incorrect password" events in TPac.
    
    Signed-off-by: Thomas Berezansky <tsbere at mvlc.org>
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm
index 4710d81..ebb56a1 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm
@@ -1259,9 +1259,10 @@ __PACKAGE__->register_method(
         desc   => "Update the operator's username", 
         params => [
             { desc => 'Authentication token', type => 'string' },
-            { desc => 'New username',         type => 'string' }
+            { desc => 'New username',         type => 'string' },
+            { desc => 'Current password',     type => 'string' }
         ],
-        return => {desc => '1 on success, Event on error'}
+        return => {desc => '1 on success, Event on error or incorrect current password'}
     }
 );
 
@@ -1272,9 +1273,10 @@ __PACKAGE__->register_method(
         desc   => "Update the operator's email address", 
         params => [
             { desc => 'Authentication token', type => 'string' },
-            { desc => 'New email address',    type => 'string' }
+            { desc => 'New email address',    type => 'string' },
+            { desc => 'Current password',     type => 'string' }
         ],
-        return => {desc => '1 on success, Event on error'}
+        return => {desc => '1 on success, Event on error or incorrect current password'}
     }
 );
 
@@ -1287,12 +1289,14 @@ sub update_passwd {
         or return $e->die_event;
     my $api = $self->api_name;
 
+    # make sure the original password matches the in-database password
+    if (md5_hex($orig_pw) ne $db_user->passwd) {
+        $e->rollback;
+        return new OpenILS::Event('INCORRECT_PASSWORD');
+    }
+
     if( $api =~ /password/o ) {
-        # make sure the original password matches the in-database password
-        if (md5_hex($orig_pw) ne $db_user->passwd) {
-            $e->rollback;
-            return new OpenILS::Event('INCORRECT_PASSWORD');
-        }
+
         $db_user->passwd($new_val);
 
     } else {
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
index 83257e7..2e6f527 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
@@ -1138,6 +1138,7 @@ sub load_myopac_update_email {
     my $e = $self->editor;
     my $ctx = $self->ctx;
     my $email = $self->cgi->param('email') || '';
+    my $current_pw = $self->cgi->param('current_pw') || '';
 
     # needed for most up-to-date email address
     if (my $r = $self->prepare_extended_user_info) { return $r };
@@ -1153,7 +1154,12 @@ sub load_myopac_update_email {
     my $stat = $U->simplereq(
         'open-ils.actor', 
         'open-ils.actor.user.email.update', 
-        $e->authtoken, $email);
+        $e->authtoken, $email, $current_pw);
+
+    if($U->event_equals($stat, 'INCORRECT_PASSWORD')) {
+        $ctx->{password_incorrect} = 1;
+        return Apache2::Const::OK;
+    }
 
     unless ($self->cgi->param("redirect_to")) {
         my $url = $self->apache->unparsed_uri;
@@ -1170,6 +1176,7 @@ sub load_myopac_update_username {
     my $e = $self->editor;
     my $ctx = $self->ctx;
     my $username = $self->cgi->param('username') || '';
+    my $current_pw = $self->cgi->param('current_pw') || '';
 
     return Apache2::Const::OK 
         unless $self->cgi->request_method eq 'POST';
@@ -1184,7 +1191,12 @@ sub load_myopac_update_username {
         my $evt = $U->simplereq(
             'open-ils.actor', 
             'open-ils.actor.user.username.update', 
-            $e->authtoken, $username);
+            $e->authtoken, $username, $current_pw);
+
+        if($U->event_equals($evt, 'INCORRECT_PASSWORD')) {
+            $ctx->{password_incorrect} = 1;
+            return Apache2::Const::OK;
+        }
 
         if($U->event_equals($evt, 'USERNAME_EXISTS')) {
             $ctx->{username_exists} = $username;
diff --git a/Open-ILS/src/templates/opac/myopac/update_email.tt2 b/Open-ILS/src/templates/opac/myopac/update_email.tt2
index b920e08..6b662bd 100644
--- a/Open-ILS/src/templates/opac/myopac/update_email.tt2
+++ b/Open-ILS/src/templates/opac/myopac/update_email.tt2
@@ -9,6 +9,12 @@
         [% bad_email = ctx.invalid_email | html %]
         [% l('The email address "<b>[_1]</b>" is invalid.  Please try a different email address.', bad_email) %]
     </div>
+
+[% ELSIF ctx.password_incorrect %]
+    <div id='account-update-email-error'>
+        [% |l %] Your current password was not correct. [% END %]
+    </div>
+
 [% END %]
 
 <form method='POST' id='account-update-email'>
@@ -17,6 +23,7 @@
     [% END %]
     <table> 
         <tr><td>[% l('Current Email') %]</td><td>[% ctx.user.email | html %]</td></tr>
+        <tr><td>[% l('Current Password') %]</td><td><input type='password' name='current_pw'/></td></tr>
         <tr><td>[% l('New Email') %]</td><td><input type='text' name='email' value='[% ctx.invalid_email | html %]'/></td></tr>
         <tr><td colspan='2' align='center'><input value="[% l('Submit') %]" type='submit'/></td></tr>
     </table>
diff --git a/Open-ILS/src/templates/opac/myopac/update_username.tt2 b/Open-ILS/src/templates/opac/myopac/update_username.tt2
index 6f48320..70449cc 100644
--- a/Open-ILS/src/templates/opac/myopac/update_username.tt2
+++ b/Open-ILS/src/templates/opac/myopac/update_username.tt2
@@ -17,11 +17,18 @@
         The username "<b>[_1]</b>" is taken.  Please try a different username.
         [% END %]
     </div>
+
+[% ELSIF ctx.password_incorrect %]
+    <div id='account-update-email-error'>
+        [% |l %] Your current password was not correct. [% END %]
+    </div>
+
 [% END %]
 
 <form method='POST' id='account-update-email'> 
     <table> 
         <tr><td>[% l('Current Username') %]</td><td>[% ctx.user.usrname | html %]</td></tr>
+        <tr><td>[% l('Current Password') %]</td><td><input type='password' name='current_pw'/></td></tr>
         <tr><td>[% l('New Username') %]</td><td><input type='text' name='username' value='[% ctx.invalid_username | html %]'/></td></tr>
         <tr><td colspan='2' align='center'><input value="[% l('Submit') %]" type='submit'/></td></tr>
     </table>
diff --git a/Open-ILS/web/opac/skin/default/js/myopac.js b/Open-ILS/web/opac/skin/default/js/myopac.js
index 8e5c079..1f4108e 100644
--- a/Open-ILS/web/opac/skin/default/js/myopac.js
+++ b/Open-ILS/web/opac/skin/default/js/myopac.js
@@ -1057,6 +1057,7 @@ function myopacSaveAddress(row, addr, deleteMe) {
 
 function myOPACUpdateUsername() {
 	var username = $('myopac_new_username').value;
+	var curpassword = $('myopac_username_current_password').value;
 	if(username == null || username == "") {
 		alert($('myopac_username_error').innerHTML);
 		return;
@@ -1091,7 +1092,7 @@ function myOPACUpdateUsername() {
 		return;
 	}
 
-	var req = new Request(UPDATE_USERNAME, G.user.session, username );
+	var req = new Request(UPDATE_USERNAME, G.user.session, username, curpassword );
 	req.send(true);
 	if(req.result()) {
 
@@ -1115,12 +1116,13 @@ function myOPACUpdateUsername() {
 
 function myOPACUpdateEmail() {
 	var email = $('myopac_new_email').value;
+	var curpassword = $('myopac_email_current_password').value;
 	if(email == null || email == "") {
 		alert($('myopac_email_error').innerHTML);
 		return;
 	}
 
-	var req = new Request(UPDATE_EMAIL, G.user.session, email );
+	var req = new Request(UPDATE_EMAIL, G.user.session, email, curpassword );
 	req.send(true);
 	if(req.result()) {
 		G.user.email(email);
diff --git a/Open-ILS/web/opac/skin/default/xml/myopac/myopac_summary.xml b/Open-ILS/web/opac/skin/default/xml/myopac/myopac_summary.xml
index 40eda7f..821f870 100644
--- a/Open-ILS/web/opac/skin/default/xml/myopac/myopac_summary.xml
+++ b/Open-ILS/web/opac/skin/default/xml/myopac/myopac_summary.xml
@@ -61,15 +61,26 @@
 				<td class='color_4 light_border'>&common.username;</td>
 				<td class='light_border' id='myopac_summary_username'> </td>
 				<td class='light_border'><a href='javascript:void(0);' 
-					onclick='unHideMe($("myopac_update_username_row"));$("myopac_new_username").focus();'
+					onclick='unHideMe($("myopac_update_username_row"));$("myopac_username_current_password").focus();'
 					id='myopac_summary_username_change' style='text-decoration: underline;'>&myopac.summary.change;</a></td>
 			</tr>
 
 			<tr id='myopac_update_username_row' class='hide_me'>
 				<td class='myopac_update_cell' colspan='3'>
-					<span class='myopac_update_span'>&myopac.summary.username.enter; </span>
-					<input type='text' size='24' id='myopac_new_username'
-						onkeydown='if(userPressedEnter(event)) myOPACUpdateUsername();' />
+
+					<table><tbody>
+						<tr>
+							<td><span class='myopac_update_span'>&myopac.summary.password.current; </span></td>
+							<td><input type='password' size='24' id='myopac_username_current_password'
+								onkeydown='if(userPressedEnter(event)) myOPACUpdateUsername();' /></td>
+						</tr>
+						<tr>
+							<td><span class='myopac_update_span'>&myopac.summary.username.enter; </span></td>
+							<td><input type='text' size='24' id='myopac_new_username'
+								onkeydown='if(userPressedEnter(event)) myOPACUpdateUsername();' /></td>
+						</tr>
+					</tbody></table>
+
 					<span class='myopac_update_span'>
 						<button onclick='myOPACUpdateUsername();'>&common.submit;</button>
 					</span>
@@ -122,15 +133,26 @@
 				<td class='color_4 light_border'>&myopac.summary.email;</td>
 				<td class='light_border' id='myopac_summary_email'> </td>
 				<td class='light_border'><a href='javascript:void(0);' 
-					onclick='unHideMe($("myopac_update_email_row"));$("myopac_new_email").focus();'
+					onclick='unHideMe($("myopac_update_email_row"));$("myopac_email_current_password").focus();'
 					id='myopac_summary_email_change' style='text-decoration: underline;'>&myopac.summary.change;</a></td>
 			</tr>
 
 			<tr id='myopac_update_email_row' class='hide_me'>
 				<td class='myopac_update_cell' colspan='3'>
-					<span class='myopac_update_span'>&myopac.summary.email.new; </span>
-					<input type='text' size='24' id='myopac_new_email'
-						onkeydown='if(userPressedEnter(event)) myOPACUpdateEmail();' />
+
+					<table><tbody>
+						<tr>
+							<td><span class='myopac_update_span'>&myopac.summary.password.current; </span></td>
+							<td><input type='password' size='24' id='myopac_email_current_password'
+								onkeydown='if(userPressedEnter(event)) myOPACUpdateEmail();' /></td>
+						</tr>
+						<tr>
+							<td><span class='myopac_update_span'>&myopac.summary.email.new; </span></td>
+							<td><input type='text' size='24' id='myopac_new_email'
+								onkeydown='if(userPressedEnter(event)) myOPACUpdateEmail();' /></td>
+						</tr>
+					</tbody></table>
+
 					<span class='myopac_update_span'>
 						<button onclick='myOPACUpdateEmail();'>&common.submit;</button>
 					</span>

commit 412b231c92c2dc9efe221a9c00c08a97ea35a0a2
Author: Thomas Berezansky <tsbere at mvlc.org>
Date:   Sat Sep 24 16:28:29 2011 -0400

    TPac: Default Password Strength Rule
    
    Every other password interface seems to have it.
    Implemented as a single regex in this case.
    
    Signed-off-by: Thomas Berezansky <tsbere at mvlc.org>
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
index 726db95..83257e7 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
@@ -1217,6 +1217,11 @@ sub load_myopac_update_password {
 
     my $pw_regex = $ctx->{get_org_setting}->($e->requestor->home_ou, 'global.password_regex');
 
+    if(!$pw_regex) {
+        # This regex duplicates the JSPac's default "digit, letter, and 7 characters" rule
+        $pw_regex = '(?=.*\d+.*)(?=.*[A-Za-z]+.*).{7,}';
+    }
+
     if($pw_regex and $new_pw !~ /$pw_regex/) {
         $ctx->{password_invalid} = 1;
         return Apache2::Const::OK;

-----------------------------------------------------------------------

Summary of changes:
 .../src/perlmods/lib/OpenILS/Application/Actor.pm  |   22 +++--
 .../lib/OpenILS/WWW/EGCatLoader/Account.pm         |   83 +++++++++++++++++++-
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 Open-ILS/src/sql/Pg/950.data.seed-values.sql       |   27 +++++++
 .../upgrade/0632.data.username-limit-settings.sql  |   33 ++++++++
 Open-ILS/src/templates/opac/myopac/prefs.tt2       |    4 +
 .../src/templates/opac/myopac/update_email.tt2     |    7 ++
 .../src/templates/opac/myopac/update_username.tt2  |    9 ++-
 Open-ILS/web/js/ui/default/actor/user/register.js  |   29 +++++++-
 Open-ILS/web/opac/locale/en-US/opac.dtd            |    2 +-
 Open-ILS/web/opac/skin/default/js/myopac.js        |   32 +++++++-
 .../skin/default/xml/myopac/myopac_summary.xml     |   38 +++++++--
 12 files changed, 262 insertions(+), 26 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/0632.data.username-limit-settings.sql


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list