Ir al contenido
Menú
Se marcó esta pregunta
4 Respuestas
2410 Vistas

I am using Odoo 13 and above.

For testing purpose, I want update passwords of all users ( excluding Admin ) in bulk because you know update one by one in backend is time consuming and error prone.

I think I can open psql and update res_user table directly, but the password there is encrypted, I should also update set password=encrypt('password').

However, I don't know how this encryption should be done.

Anyone knows the correct method to update password using SQL? Your help is appreciated.

Avatar
Descartar
Mejor respuesta

Hello, 

You can Use Below Module For Bulk Updating Password in Backend which is available in V14,15,16.

https://apps.odoo.com/apps/modules/14.0/bulk_update_user_password_sit

Avatar
Descartar
Autor Mejor respuesta

Thanks for your swift suggestion.

Having a trial, it returns error.

UPDATE res_users SET password = crypt('password_for_test', gen_salt('sha1')) WHERE id in (6,10);

ERROR:  function gen_salt(unknown) does not exist

LINE 1: UPDATE res_users SET password = crypt('password_for_test', gen_salt('s...

                                                         ^

HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

Is the gen_salt function version dependent?

I am using Odoo 13 CE. 


Avatar
Descartar
Autor

Pagico Flex's answer is inspiring though it's not completed and not working at least on my Odoo 13 CE.

But, upon further exploration to the issue, just learn more about the Odoo password.

First, the gen_salt function inside PostgreSQL is unknown but after CREATE EXTENSION crypt, then it becomes known.

Second, even gen_salt known but it doesn't support sha1 algorithm.

Third, whether odoo is uing sha1 unknown.

I have a select id, login, password from res_users; i found all password (encrypted) in db share a same format liked
$pbkdf2-sha512$25000$dC6ltJZSas2 .............

from start up to $25000$ are the same and in between a string sha512... does it mean it's using sha512?
sha512 also not supported by gen_salt

moreover, an identical string as prefix means concatenated encrypted password?

i am still looking for a solution for a SQL to change odoo user password altogether.

any idea is appreciated.

Autor

I finally found the answer myself. It is very interesting and so simple that
update res_users set password = 'new_password' where id = xx;
that's it. simply give a password in plain text, no any complicated md5(), crypt() functions required.
then in psql,
select id, password you'll see the password in plain text, but....
you can login.
when u use backend to change password, the pw in db is encrypted.
very happy but do spend so much time on this, why didn't i just try the most simple way to update from the very beginning???

Mejor respuesta

Hi,

You can utilize the following query to update the passwords for all users.


UPDATE res_users

SET password = md5('new_password')

WHERE id != (SELECT id FROM res_users WHERE login = 'admin');


Regards

Avatar
Descartar
Autor

md5 is not work.
upon issued the update password SQL using md5() the password stored in res_users not liked other passwords created from backend.
e.g. the length of encrypted password much shorter.

Mejor respuesta

UPDATE res_users SET password = crypt('new_password', gen_salt('sha1')) WHERE login != 'admin'; 

Replace 'new_password' with the actual password you want to set, and 'admin' with the login of the user you want to exclude (e.g., the Administrator).

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
feb 24
1551
1
jun 23
1497
0
ago 21
111
1
mar 24
1055
1
may 23
2681