From: Bill Erickson Date: Mon, 17 Aug 2020 20:24:07 +0000 (-0400) Subject: LP1858833 Stamping DB upgrade for change_password X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f11549c42c3e870b04cf399db2698a47b740b36d;p=evergreen%2Ftadl.git LP1858833 Stamping DB upgrade for change_password Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index f5091efeb5..5111c427aa 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -92,7 +92,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 ('1212', :eg_version); -- berick/sandbergja/gmcharlt +INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1213', :eg_version); -- rhamby/berick CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/upgrade/1213.schema.actor_change_password.sql b/Open-ILS/src/sql/Pg/upgrade/1213.schema.actor_change_password.sql new file mode 100644 index 0000000000..d604644275 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/1213.schema.actor_change_password.sql @@ -0,0 +1,29 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('1213', :eg_version); + +CREATE OR REPLACE FUNCTION actor.change_password (user_id INT, new_pw TEXT, pw_type TEXT DEFAULT 'main') +RETURNS VOID AS $$ +DECLARE + new_salt TEXT; +BEGIN + SELECT actor.create_salt(pw_type) INTO new_salt; + + IF pw_type = 'main' THEN + -- Only 'main' passwords are required to have + -- the extra layer of MD5 hashing. + PERFORM actor.set_passwd( + user_id, pw_type, md5(new_salt || md5(new_pw)), new_salt + ); + + ELSE + PERFORM actor.set_passwd(user_id, pw_type, new_pw, new_salt); + END IF; +END; +$$ LANGUAGE 'plpgsql'; + +COMMENT ON FUNCTION actor.change_password(INT,TEXT,TEXT) IS $$ +Allows setting a salted password for a user by passing actor.usr id and the text of the password. +$$; + +COMMIT; diff --git a/Open-ILS/src/sql/Pg/upgrade/xxxx.function.actor_change_password.sql b/Open-ILS/src/sql/Pg/upgrade/xxxx.function.actor_change_password.sql deleted file mode 100644 index 88aa119bad..0000000000 --- a/Open-ILS/src/sql/Pg/upgrade/xxxx.function.actor_change_password.sql +++ /dev/null @@ -1,25 +0,0 @@ -BEGIN; - -SELECT evergreen.upgrade_deps_block_check('xxxx', :eg_version); - -CREATE OR REPLACE FUNCTION actor.change_password (user_id INT, new_pw TEXT, pw_type TEXT DEFAULT 'main') -RETURNS VOID AS $$ -DECLARE - new_salt TEXT; -BEGIN - SELECT actor.create_salt(pw_type) INTO new_salt; - - IF pw_type = 'main' THEN - -- Only 'main' passwords are required to have - -- the extra layer of MD5 hashing. - PERFORM actor.set_passwd( - user_id, pw_type, md5(new_salt || md5(new_pw)), new_salt - ); - - ELSE - PERFORM actor.set_passwd(user_id, pw_type, new_pw, new_salt); - END IF; -END; -$$ LANGUAGE 'plpgsql'; - -COMMIT;