diff MoinMoin/script/account/create.py @ 3884:085328cb4f4d

script.account create, disable, resetpw: checks for already existing user (backport from 1.8)
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sat, 19 Jul 2008 23:15:59 +0200
parents 2572688e031a
children f85cd27073a9
line wrap: on
line diff
--- a/MoinMoin/script/account/create.py	Sat Jul 19 16:11:19 2008 +0200
+++ b/MoinMoin/script/account/create.py	Sat Jul 19 23:15:59 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,14 @@
         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
+        # Email should be unique - see also MoinMoin.action.newaccount
+        if self.options.email and request.cfg.user_email_unique:
+            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 ''