misc/migration/3.15.4_Any.py
changeset 10589 7c23b7de2b8d
parent 8522 85b1c4b36d1d
equal deleted inserted replaced
10588:fdaa0e4b7eaf 10589:7c23b7de2b8d
       
     1 from __future__ import print_function
       
     2 
     1 from logilab.common.shellutils import generate_password
     3 from logilab.common.shellutils import generate_password
     2 from cubicweb.server.utils import crypt_password
     4 from cubicweb.server.utils import crypt_password
     3 
     5 
     4 for user in rql('CWUser U WHERE U cw_source S, S name "system", U upassword P, U login L').entities():
     6 for user in rql('CWUser U WHERE U cw_source S, S name "system", U upassword P, U login L').entities():
     5     salt = user.upassword.getvalue()
     7     salt = user.upassword.getvalue()
     6     if crypt_password('', salt) == salt:
     8     if crypt_password('', salt) == salt:
     7         passwd = generate_password()
     9         passwd = generate_password()
     8         print 'setting random password for user %s' % user.login
    10         print('setting random password for user %s' % user.login)
     9         user.set_attributes(upassword=passwd)
    11         user.set_attributes(upassword=passwd)
    10 
    12 
    11 commit()
    13 commit()