view MoinMoin/script/account/ @ 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 0259bd2d0777
children a20de9383481
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
MoinMoin - disable a user account

@copyright: 2006 MoinMoin:ThomasWaldmann,
            2008 MoinMoin:JohannesBerg
@license: GNU GPL, see COPYING for details.

from MoinMoin.script import MoinScript

class PluginScript(MoinScript):
This tool allows you to change a user password via a command line interface.

Detailed Instructions:
General syntax: moin [options] account resetpw [newpw-options] newpassword

[options] usually should be:

[newpw-options] see below:
    1. To change JohnSmith's password:
       moin ... account resetpw --name JohnSmith new-password

    2. To change the password for the UID '1198872910.78.56322':
       moin ... account resetpw --uid 1198872910.78.56322 new-password

    def __init__(self, argv, def_values):
        MoinScript.__init__(self, argv, def_values)
            "--uid", metavar="UID", dest="uid",
            help="Reset password for the user with user id UID."
            "--name", metavar="NAME", dest="uname",
            help="Reset password for the user with user name NAME."

    def mainloop(self):
        # we don't expect non-option arguments
        if len(self.args) != 1:
            self.parser.error("no new password given")
        newpass = self.args[0]

        flags_given = self.options.uid or self.options.uname
        if not flags_given:
            import sys

        request = self.request

        from MoinMoin import user
        if self.options.uid:
            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.enc_password = user.encodePassword(newpass)