huskar_api/api/user.py
def put(self, username):
        """Changes the password or email of specified user.

        :param username: The username of specified user.
        :form old_password: The old passwor of specified user.
        :form new_password: Optional. If you want to modify your password,
                            specify it.
        :form email: Optional. If you want to modify your email, specify it.
        :<header Authorization: Huskar Token (See :ref:`token`)
        :status 403: The old password is incorrect or this modification is
                     not permitted.
        :status 404: The user is not found.
        :status 200: The user is modified successfully.
        """
        old_password = request.form['old_password']
        new_password = request.form.get('new_password')
        new_email = request.form.get('email')

        if g.auth.username != username:
            abort(403, '%s is not permitted to modify %s.' % (
                g.auth.username, username
            ))
        validate_fields(user_schema, {'email': new_email},
                        optional_fields=['email'], partial=True)

        user = self._get_user_or_404(username)
        if not user.check_password(old_password):
            abort(403, 'password is not correct')

        if new_password:
            with audit_log(audit_log.types.CHANGE_USER_PASSWORD, user=user):
                user.change_password(new_password)
        if new_email:
            change_email(user, new_email)

        return api_response()
Changes the password or email of specified user.

        :param username: The username of specified user.
        :form old_password: The old passwor of specified user.
        :form new_password: Optional. If you want to modify your password,
                            specify it.
        :form email: Optional. If you want to modify your email, specify it.
        :<header Authorization: Huskar Token (See :ref:`token`)
        :status 403: The old password is incorrect or this modification is
                     not permitted.
        :status 404: The user is not found.
        :status 200: The user is modified successfully.
        
Changes the password or email of specified user.
Changes the password or email of specified user .
def put(self, username):
        old_password = request.form['old_password']
        new_password = request.form.get('new_password')
        new_email = request.form.get('email')
        if g.auth.username != username:
            abort(403, '%s is not permitted to modify %s.' % (
                g.auth.username, username
            ))
        validate_fields(user_schema, {'email': new_email},
                        optional_fields=['email'], partial=True)
        user = self._get_user_or_404(username)
        if not user.check_password(old_password):
            abort(403, 'password is not correct')
        if new_password:
            with audit_log(audit_log.types.CHANGE_USER_PASSWORD, user=user):
                user.change_password(new_password)
        if new_email:
            change_email(user, new_email)
        return api_response()
def put ( self , username ) : old_password = request . form [ 'old_password' ] new_password = request . form . get ( 'new_password' ) new_email = request . form . get ( 'email' ) if g . auth . username != username : abort ( 403 , '%s is not permitted to modify %s.' % ( g . auth . username , username ) ) validate_fields ( user_schema , { 'email' : new_email } , optional_fields = [ 'email' ] , partial = True ) user = self . _get_user_or_404 ( username ) if not user . check_password ( old_password ) : abort ( 403 , 'password is not correct' ) if new_password : with audit_log ( audit_log . types . CHANGE_USER_PASSWORD , user = user ) : user . change_password ( new_password ) if new_email : change_email ( user , new_email ) return api_response ( )
Changes the password or email of specified user.
Changes the password or email of specified user .
"""Changes the password or email of specified user.

        :param username: The username of specified user.
        :form old_password: The old passwor of specified user.
        :form new_password: Optional. If you want to modify your password,
                            specify it.
        :form email: Optional. If you want to modify your email, specify it.
        :<header Authorization: Huskar Token (See :ref:`token`)
        :status 403: The old password is incorrect or this modification is
                     not permitted.
        :status 404: The user is not found.
        :status 200: The user is modified successfully.
        """
self
username
The username of specified user.
The username of specified user .
form
The old passwor of specified user.
The old passwor of specified user .
form
Optional. If you want to modify your password,
specify it.
Optional . If you want to modify your password specify it .
form
Optional. If you want to modify your email, specify it.
Optional . If you want to modify your email specify it .
<header
Huskar Token (See :ref:`token`)
Huskar Token ( See : ref : ` token ` )
status
The old password is incorrect or this modification is
not permitted.
The old password is incorrect or this modification is not permitted .
status
The user is not found.
The user is not found .
status
The user is modified successfully.
The user is modified successfully .