LP#1772680: Changed Registration form, added code in the backend to save email into...
authorJaswinder Singh <Jaswinder.Singh0011@gmail.com>
Sun, 23 Sep 2018 15:57:01 +0000 (11:57 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 4 Jun 2019 21:33:17 +0000 (17:33 -0400)
Signed-off-by: Jaswinder Singh <jaswinder.singh0011@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/EbookAPI.pm
Open-ILS/src/templates/opac/ebook_api/rbdigital/register_modal.tt2
Open-ILS/web/js/ui/default/opac/ebook_api/ebook.js
Open-ILS/web/js/ui/default/opac/ebook_api/rbdigital.js

index 061cc0a..76767bf 100644 (file)
@@ -993,7 +993,7 @@ __PACKAGE__->register_method(
 
 # Call an API to register a patron
 sub register_patron {
-   my ($self, $conn, $auth, $session_id, $password) = @_;
+   my ($self, $conn, $auth, $session_id, $email, $password) = @_;
    $logger->info("EbookAPI: Initiating patron registration");
 
     # verify that user is authenticated in EG
@@ -1003,6 +1003,17 @@ sub register_patron {
         return;
     }
     
+    # Update email in the Evergreen system if changed by the user
+    if (lc $editor->requestor->email ne lc $email) {
+        #Begin transaction
+        $editor->xact_begin;
+        my $db_user = $editor->retrieve_actor_user($editor->requestor->id);
+        $db_user->email($email);
+
+        $editor->update_actor_user($db_user) or return $editor->die_event;
+        $editor->commit;
+    }
+
     $logger->info("EbookAPI: User Authenticated. Now, registering the patron with RBDigital");
     my $handler = new_handler($session_id);
     
@@ -1028,6 +1039,11 @@ __PACKAGE__->register_method(
                 type => 'string'
             },
             {
+                name => 'email',
+                desc => 'New email address for evergreen and vendor portal',
+                type => 'string'
+            },
+            {
                 name => 'password',
                 desc => 'The password for vendor portal',
                 type => 'string'
index ce74ae8..bc7f076 100644 (file)
@@ -6,16 +6,16 @@
       <div class="modal-content">
         <div class="modal-header">
           <button type="button" class="close" data-dismiss="modal">&times;</button>
-          <h4><span class="glyphicon glyphicon-lock"></span>New RBDigital Password</h4>
+          <h4><span class="glyphicon glyphicon-lock"></span>Create RBdigital Password</h4>
         </div>
         <div class="modal-body">
           <form id="frmRegisterRBDigital" role="form">
             <div class="form-group">
               <label for="usrname"><span class="glyphicon glyphicon-user"></span> Username</label>
-              <input type="text" class="form-control" id="userrname" placeholder="Enter email" value="[% ctx.user.usrname | html; %]" disabled>
+              <input type="text" class="form-control" id="userrname" value="[% ctx.user.usrname | html; %]" disabled>
             </div>
             <div id="divPassword" class="form-group">
-              <label for="psw"><span class="glyphicon glyphicon-eye-open"></span> New Password</label>
+              <label for="psw"><span class="glyphicon glyphicon-eye-open"></span> New RBdigital Password</label>
               <input type="password" class="form-control" id="password" name="password" placeholder="Enter new password" 
                 data-toggle="tooltip" data-placement="right" data-html="true" autofocus required>
             </div>
                 data-toggle="tooltip" data-placement="right" title="Confirm password must match the password field." required>
             </div>
             <div id="confirmPasswordError" class="hidden alert alert-danger">Confirm password must match with the password you entered.</div>
+            <div class="form-group">
+              <label for="email"><span class="glyphicon glyphicon-envelope"></span> Email</label>
+              <input type="email" class="form-control" id="email" placeholder="Enter email" value="[% ctx.user.email | html; %]"
+                data-toggle="tooltip" data-placement="right" title="Note: Changing your email here will also update your account's email address." required>
+            </div>
             
             <button id="btnRegister" type="submit" class="btn btn-success pull-left"><span class="glyphicon glyphicon-off"></span> Register</button>
             <button id="btnCancel" type="submit" class="btn btn-danger btn-default pull-right" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Cancel</button>
index 6a43274..956be5c 100644 (file)
@@ -232,7 +232,7 @@ Ebook.prototype.wishlist = function(authtoken, action, callback) {
 }
 
 //Register a patron
-Ebook.prototype.registerPatron = function(authtoken, password, callback) {
+Ebook.prototype.registerPatron = function(authtoken, email, password, callback) {
     var ebook = this;
     console.log(dojo.cookie(this.vendor));
     //Reload new session (if any)
@@ -243,7 +243,7 @@ Ebook.prototype.registerPatron = function(authtoken, password, callback) {
         
         new OpenSRF.ClientSession('open-ils.ebook_api').request({
             method: 'open-ils.ebook_api.patron.register',
-            params: [authtoken, ses, password],
+            params: [authtoken, ses, email, password],
             async: true,
             oncomplete: function(r) {
                 var resp = r.recv();
index 0364bb9..c9910f1 100644 (file)
@@ -80,13 +80,13 @@ function setupEventHandlers() {
         var password = $('#password'), 
             confirmPassword = $('#confirmPassword'),
             passwordError = $('#passwordError'),
-            confirmPasswordError = $('#confirmPasswordError');
+            confirmPasswordError = $('#confirmPasswordError'),
+            email = $('#email').val();
 
         passwordError.addClass('hidden');
         confirmPasswordError.addClass('hidden');
         $('#registerError').addClass('hidden');
 
-        console.log(password.val());
         //Check if password matches the strength
         if (!checkPasswordStrength(password.val())) {
             password.focus();
@@ -99,7 +99,7 @@ function setupEventHandlers() {
         }
         $('#btnRegister').prop("disabled", true);
         $('#registerProgress').removeClass('hidden');
-        ebook_rbdigital.registerPatron(authtoken, password.val(), registerPatronCallback);
+        ebook_rbdigital.registerPatron(authtoken, email, password.val(), registerPatronCallback);
 
     });
 
@@ -112,7 +112,6 @@ function setupEventHandlers() {
     $("#btnCloseRegisterSuccess").click(function(event) {
         //redirect user to rbdigital search page
         window.location.href = window.location.protocol+"//"+window.location.host+$("#lnkSearchResults_rbdigital").attr('href');
-
     });
 
     //Listen for Save Mapping Fields Event