huskar_api/api/user.py
def post(self):
        """Creates a new user with your site admin authority.

        We will send you an email of random password if don't specify password
        explicitly.

        :form username: The username of new user.
        :form password: The optional password of new user.
        :form email: The email of new user.
        :<header Authorization: Huskar Token (See :ref:`token`)
        :status 400: The username is used or the format is invalid.
        :status 200: The new user is created successfully.
        """
        g.auth.require_admin('only admin can add users')

        username = request.form['username'].strip()
        password = request.form.get('password', gen_salt(30))
        is_generated_password = 'password' not in request.form
        email = request.form['email'].strip()
        validate_fields(user_schema, {'username': username, 'email': email})

        user = User.get_by_name(username)
        if user:
            abort(400, u'{0} is used username'.format(username))

        try:
            user = User.create_normal(username, password, email,
                                      is_active=True)
        except NameOccupiedError:
            abort(400, u'User %s has been archived' % username)
        audit_log.emit(audit_log.types.CREATE_USER, user=user)

        if is_generated_password:
            deliver_email(EmailTemplate.SIGNUP, user.email, {
                'username': user.username,
                'password': password,
            })

        return api_response()
Creates a new user with your site admin authority.

        We will send you an email of random password if don't specify password
        explicitly.

        :form username: The username of new user.
        :form password: The optional password of new user.
        :form email: The email of new user.
        :<header Authorization: Huskar Token (See :ref:`token`)
        :status 400: The username is used or the format is invalid.
        :status 200: The new user is created successfully.
        
Creates a new user with your site admin authority.
We will send you an email of random password if don't specify password
explicitly.
Creates a new user with your site admin authority . We will send you an email of random password if don ' t specify password explicitly .
def post(self):
        g.auth.require_admin('only admin can add users')
        username = request.form['username'].strip()
        password = request.form.get('password', gen_salt(30))
        is_generated_password = 'password' not in request.form
        email = request.form['email'].strip()
        validate_fields(user_schema, {'username': username, 'email': email})
        user = User.get_by_name(username)
        if user:
            abort(400, u'{0} is used username'.format(username))
        try:
            user = User.create_normal(username, password, email,
                                      is_active=True)
        except NameOccupiedError:
            abort(400, u'User %s has been archived' % username)
        audit_log.emit(audit_log.types.CREATE_USER, user=user)
        if is_generated_password:
            deliver_email(EmailTemplate.SIGNUP, user.email, {
                'username': user.username,
                'password': password,
            })
        return api_response()
def post ( self ) : g . auth . require_admin ( 'only admin can add users' ) username = request . form [ 'username' ] . strip ( ) password = request . form . get ( 'password' , gen_salt ( 30 ) ) is_generated_password = 'password' not in request . form email = request . form [ 'email' ] . strip ( ) validate_fields ( user_schema , { 'username' : username , 'email' : email } ) user = User . get_by_name ( username ) if user : abort ( 400 , u'{0} is used username' . format ( username ) ) try : user = User . create_normal ( username , password , email , is_active = True ) except NameOccupiedError : abort ( 400 , u'User %s has been archived' % username ) audit_log . emit ( audit_log . types . CREATE_USER , user = user ) if is_generated_password : deliver_email ( EmailTemplate . SIGNUP , user . email , { 'username' : user . username , 'password' : password , } ) return api_response ( )
Creates a new user with your site admin authority.
Creates a new user with your site admin authority .
"""Creates a new user with your site admin authority.

        We will send you an email of random password if don't specify password
        explicitly.

        :form username: The username of new user.
        :form password: The optional password of new user.
        :form email: The email of new user.
        :<header Authorization: Huskar Token (See :ref:`token`)
        :status 400: The username is used or the format is invalid.
        :status 200: The new user is created successfully.
        """
self
form
The username of new user.
The username of new user .
form
The optional password of new user.
The optional password of new user .
form
The email of new user.
The email of new user .
<header
Huskar Token (See :ref:`token`)
Huskar Token ( See : ref : ` token ` )
status
The username is used or the format is invalid.
The username is used or the format is invalid .
status
The new user is created successfully.
The new user is created successfully .