-- utility sql for modifying user 'main' passwords
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';
What I have locally. Can branch-ify.
-- utility sql for modifying user 'main' passwords password (user_id INT, new_pw TEXT, pw_type TEXT DEFAULT 'main') salt(pw_ type) INTO new_salt;
CREATE OR REPLACE FUNCTION actor.change_
RETURNS VOID AS $$
DECLARE
new_salt TEXT;
BEGIN
SELECT actor.create_
IF pw_type = 'main' THEN
user_ id, pw_type, md5(new_salt || md5(new_pw)), new_salt
-- Only 'main' passwords are required to have
-- the extra layer of MD5 hashing.
PERFORM actor.set_passwd(
);
ELSE passwd( user_id, pw_type, new_pw, new_salt);
PERFORM actor.set_
END IF;
END;
$$ LANGUAGE 'plpgsql';