Mercurial > moin > 1.9
changeset 3770:749d7148b080
script.account: create user checks for already known email adress or username,
disable and resetpw checks if the user exists
author | Reimar Bauer <rb.proj AT googlemail DOT com> |
---|---|
date | Sun, 22 Jun 2008 16:57:00 +0200 |
parents | 8a6960133ec2 |
children | c57d79281471 |
files | MoinMoin/script/account/create.py MoinMoin/script/account/disable.py MoinMoin/script/account/resetpw.py |
diffstat | 3 files changed, 21 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/script/account/create.py Sun Jun 22 16:35:00 2008 +0200 +++ b/MoinMoin/script/account/create.py Sun Jun 22 16:57:00 2008 +0200 @@ -22,9 +22,6 @@ --config-dir=/path/to/my/cfg/ --wiki-url=wiki.example.org/ [create-options] see below: - 0. Verify that the account does not exist. - Currently this script does not check if the user exists. - 1. Verify that you have specified the right options. This script does no verification of email addresses or the like. @@ -49,7 +46,7 @@ ) self.parser.add_option( "--password", metavar="PASSWORD", dest="password", - help="Set the user's password to PASSWORD (either cleartext or {SHA1}...)." + help="Set the user's password to PASSWORD." ) def mainloop(self): @@ -67,6 +64,12 @@ request = self.request from MoinMoin import user + if user.User(request, name=self.options.uname).exists(): + print 'This username "%s" exists already!' % self.options.uname + return + if user.get_by_email_address(request, self.options.email): + print 'This emailaddress "%s" belongs to someone else!' % self.options.email + return u = user.User(request, None, self.options.uname, password=self.options.password) u.email = self.options.email u.aliasname = self.options.ualiasname or ''
--- a/MoinMoin/script/account/disable.py Sun Jun 22 16:35:00 2008 +0200 +++ b/MoinMoin/script/account/disable.py Sun Jun 22 16:57:00 2008 +0200 @@ -25,13 +25,10 @@ 0. Verify that you really want to disable the account. While there is a disable script, no such enable script exists. - 1. If using usernames, verify that multiple usernames with the same - user ID do not exist. - - 2. To disable the user 'JohnSmith': + 1. To disable the user 'JohnSmith': moin ... account disable --name JohnSmith - 3. To disable the user 'JohnSmith', based on his UID '1198872910.78.56322': + 2. To disable the user 'JohnSmith', based on his UID '1198872910.78.56322': moin ... account disable --uid 1198872910.78.56322 """ @@ -65,6 +62,11 @@ u = user.User(request, self.options.uid) elif self.options.uname: u = user.User(request, None, self.options.uname) + + if not u.exists(): + print 'This user "%s" does not exists!' % u.name + return + print " %-20s %-25s %-35s" % (u.id, u.name, u.email), if not u.disabled: # only disable once u.disabled = 1
--- a/MoinMoin/script/account/resetpw.py Sun Jun 22 16:35:00 2008 +0200 +++ b/MoinMoin/script/account/resetpw.py Sun Jun 22 16:57:00 2008 +0200 @@ -23,13 +23,10 @@ --config-dir=/path/to/my/cfg/ --wiki-url=wiki.example.org/ [newpw-options] see below: - 1. If using usernames, verify that multiple usernames with the same - user ID do not exist. - - 2. To change JohnSmith's password: + 1. To change JohnSmith's password: moin ... account resetpw --name JohnSmith new-password - 3. To change the password for the UID '1198872910.78.56322': + 2. To change the password for the UID '1198872910.78.56322': moin ... account resetpw --uid 1198872910.78.56322 new-password """ @@ -64,5 +61,10 @@ u = user.User(request, self.options.uid) elif self.options.uname: u = user.User(request, None, self.options.uname) + + if not u.exists(): + print 'This user "%s" does not exists!' % u.name + return + u.enc_password = user.encodePassword(newpass) u.save()