cubicweb/misc/migration/3.15.4_Any.py
author Denis Laxalde <denis.laxalde@logilab.fr>
Thu, 08 Sep 2016 11:57:46 +0200
changeset 11453 3522d2a3389e
parent 11057 0b59724cb3f2
permissions -rw-r--r--
[pkg] Add missing entries to MANIFEST.in Detected by running `check-manifest <https://github.com/mgedmin/check-manifest>`_. Add a tox environment accordingly. Closes #15229018.

from __future__ import print_function

from logilab.common.shellutils import generate_password
from cubicweb.server.utils import crypt_password

for user in rql('CWUser U WHERE U cw_source S, S name "system", U upassword P, U login L').entities():
    salt = user.upassword.getvalue()
    if crypt_password('', salt) == salt:
        passwd = generate_password()
        print('setting random password for user %s' % user.login)
        user.set_attributes(upassword=passwd)

commit()