Roundcube Community Forum

 

password plugin sql update multiple tables

Started by Juppers, March 09, 2024, 11:22:28 AM

Previous topic - Next topic

Juppers

I am trying to update multiple tables when someone changes their password. Because the second table is external via the connect engine in mariadb, I can't use a trigger to update it.
I have been trying to update the sql query to handle both updates, but it fails even thought the query is valid. Yes, I have disabled password encryption for the moment for troubleshooting.

Is there an easier way to have the password plugin run multiple queries or dealing with multiple dsn's?

$config['password_query'] = "UPDATE mailbox SET password=%P,plain_password=%p,passwordlastchange=NOW() WHERE username=%u;update email_data set password =%p where emailaddr=%u";


Mar  9 10:40:15 mail roundcube: <0f5vgmc9> DB Error: [1064] You have an error in your SQL syntax; check the manual that correspo
nds to your MariaDB server version for the right syntax to use near 'update email_data set password ='etstetst' where emailaddr='sup
ertest@domain...' at line 1 (SQL Query: UPDATE mailbox SET password='{PLAIN}etstetst',plain_password='etstetst',passwordlastchange=
NOW() WHERE username='supertest@domain.com' ;update email_data set password ='etstetst' where emailaddr='supertest@domain.com') in
/opt/www/roundcubemail-1.6.5/program/lib/Roundcube/rcube_db.php on line 577 (POST /mail/?_task=settings&_action=plugin.password-sav
e)

JohnDoh

I'm not sure if you can put multiple statements in a single query() call. How would the response be handled? I think a better way is to use an SQL function. You can see some examples in the password plugin readme. In the function you can execute multiple statements.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

Juppers

Unfortunately the connect engine doesn't allow stored procedures or functions either.

I guess I will need to just script the changes and use the expect or some other cli based driver. Thanks.