diff options
author | Marian Sigler <m@qjym.de> | 2012-09-21 04:06:13 +0200 |
---|---|---|
committer | Marian Sigler <m@qjym.de> | 2012-09-21 04:06:13 +0200 |
commit | 85b73458a145749f51b10a0b1d530cc43605d59c (patch) | |
tree | 3112e28fcfb1d527fff25b21197e2287bc27260c /account.py | |
parent | 571263f162e97a12c455dfff4d7ba33a8a973e98 (diff) | |
download | web-85b73458a145749f51b10a0b1d530cc43605d59c.tar.gz web-85b73458a145749f51b10a0b1d530cc43605d59c.tar.bz2 web-85b73458a145749f51b10a0b1d530cc43605d59c.zip |
account: don't fail on unicode input strings. Update examples
Diffstat (limited to 'account.py')
-rw-r--r-- | account.py | 22 |
1 files changed, 14 insertions, 8 deletions
@@ -20,12 +20,12 @@ class AccountService: ssh spline -L 5678:vm-splinux:389 -N * register a new user - >> service = AccountService(LDAP_HOST, LDAP_BASE_DN,SERVICES) + >> service = AccountService(LDAP_HOST, LDAP_BASE_DN, ADMIN_USER, ADMIN_PW, SERVICES) >> foo = Account('foo','foo@bar.de', password='bar') - >> service.register(foo, LDAP_ADMIN_USER, LDAP_ADMIN_PASS) + >> service.register(foo) * authenticate a new user - >> service = AccountService(LDAP_HOST, LDAP_BASE_DN,SERVICES) + >> service = AccountService(LDAP_HOST, LDAP_BASE_DN, ADMIN_USER, ADMIN_PW,, SERVICES) >> foo = service.auth('foo', 'bar') * updates an account @@ -34,16 +34,16 @@ class AccountService: >> foo.change_password('bar2', 'gitlab') # changes password for gitlab >> service.update(foo) # save changes in ldap backend # save changes in ldap backend as admin user - >> service.update(foo, LDAP_ADMIN_USER, LDAP_ADMIN_PASS) + >> service.update(foo, as_admin=True) * delete an account - >> service = AccountService(LDAP_HOST, LDAP_BASE_DN,SERVICES) + >> service = AccountService(LDAP_HOST, LDAP_BASE_DN, LDAP_ADMIN_USER, LDAP_ADMIN_PASS, SERVICES) >> service.delete(Account) >> service.delete('foo') * find accounts - >> service = AccountService(LDAP_HOST, LDAP_BASE_DN,SERVICES) - >> all_accounts = service.find(LDAP_ADMIN_USER, LDAP_ADMIN_PASS) + >> service = AccountService(LDAP_HOST, LDAP_BASE_DN, LDAP_ADMIN_USER, LDAP_ADMIN_PASS, SERVICES) + >> all_accounts = service.find() >> print([x.uid for x in all_accounts]) """ @@ -217,12 +217,15 @@ class Account: return "<Account uid=%s>" % self.uid - def change_password(self, new_password, service = None): + def change_password(self, new_password, service=None): """ Changes a password for a given service. You have to use the AccountService class to make the changes permanent. If no service is given, the root password will be changed. """ + if isinstance(new_password, unicode): + new_password = new_password.encode('utf8') + if not service: self.new_password_root = new_password else: @@ -234,4 +237,7 @@ class Account: Changes the mail address of an account. You have to use the AccountService class to make changes permanent. """ + if isinstance(new_mail, unicode): + new_mail = new_mail.encode('utf8') + self.mail = new_mail |