def handle_put_user(self, req):
        # Validate path info
        account = req.path_info_pop()
        user = req.path_info_pop()
        key = unquote(req.headers.get('x-auth-user-key', ''))
        admin = req.headers.get('x-auth-user-admin') == 'true'
        reseller_admin = \
            req.headers.get('x-auth-user-reseller-admin') == 'true'
        if reseller_admin:
            admin = True
        if req.path_info or not account or account[0] == '.' or not user or \
                user[0] == '.' or not key:
            return HTTPBadRequest(request=req)
        user_arg = account + ':' + user
        if reseller_admin:
            if not self.is_super_admin(req) and\
                    not self.is_user_changing_own_key(req, user_arg):
                        return self.denied_response(req)
        elif not self.is_account_admin(req, account) and\
                not self.is_user_changing_own_key(req, user_arg):
                    return self.denied_response(req)

        path = quote('/v1/%s/%s' % (self.auth_account, account))
        resp = self.make_pre_authed_request(
            req.environ, 'HEAD', path).get_response(self.app)
        if resp.status_int // 100 != 2:
            raise Exception('Could not retrieve account id value: %s %s' %
                            (path, resp.status))
        headers = {'X-Object-Meta-Account-Id':
                   resp.headers['x-container-meta-account-id']}
        # Create the object in the main auth account (this object represents
        # the user)
        path = quote('/v1/%s/%s/%s' % (self.auth_account, account, user))
        groups = ['%s:%s' % (account, user), account]
        if admin:
            groups.append('.admin')
        if reseller_admin:
            groups.append('.reseller_admin')
        auth_value = self.auth_encoder().encode(key)
        resp = self.make_pre_authed_request(
            req.environ, 'PUT', path,
            json.dumps({'auth': auth_value,
                        'groups': [{'name': g} for g in groups]}),
            headers=headers).get_response(self.app)
        if resp.status_int == 404:
            return HTTPNotFound(request=req)
        if resp.status_int // 100 != 2:
            raise Exception('Could not create user object: %s %s' %
                            (path, resp.status))
        return HTTPCreated(request=req)
Handles the PUT v2/<account>/<user> call for adding a user to an
dataset/ETHPy150Open openstack/swauth/swauth/middleware.py/Swauth.handle_put_user