LP#1468422 Manual password migrate does not re-migrate
authorBill Erickson <berickxx@gmail.com>
Thu, 18 Feb 2016 15:28:46 +0000 (10:28 -0500)
committerBill Erickson <berickxx@gmail.com>
Fri, 26 Feb 2016 15:07:42 +0000 (10:07 -0500)
Avoid migrating already-migrated passwords when actor.migrate_passwd()
is called manually.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/src/sql/Pg/005.schema.actors.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.password-storage.sql

index 912b2fc..da94af0 100644 (file)
@@ -965,6 +965,16 @@ BEGIN
      * hashing is not required of other passwords.
      */
 
+    -- Avoid calling get_salt() here, because it may result in a 
+    -- migrate_passwd() call, creating a loop.
+    SELECT INTO pw_salt salt FROM actor.passwd 
+        WHERE usr = pw_usr AND passwd_type = 'main';
+
+    -- Only migrate passwords that have not already been migrated.
+    IF FOUND THEN
+        RETURN pw_salt;
+    END IF;
+
     SELECT INTO usr_row * FROM actor.usr WHERE id = pw_usr;
 
     pw_salt := actor.create_salt('main');
index 343eb39..309823b 100644 (file)
@@ -157,6 +157,16 @@ BEGIN
      * hashing is not required of other passwords.
      */
 
+    -- Avoid calling get_salt() here, because it may result in a 
+    -- migrate_passwd() call, creating a loop.
+    SELECT INTO pw_salt salt FROM actor.passwd 
+        WHERE usr = pw_usr AND passwd_type = 'main';
+
+    -- Only migrate passwords that have not already been migrated.
+    IF FOUND THEN
+        RETURN pw_salt;
+    END IF;
+
     SELECT INTO usr_row * FROM actor.usr WHERE id = pw_usr;
 
     pw_salt := actor.create_salt('main');