Exemplo n.º 1
0
def load_data(f):
    with open(f, 'r') as f:
        config = yaml.load(f)

        if validate_yaml(config):

            for user in config.keys():
                user_data = config[user]
                yield from UserStore.create(
                    dict(
                        username=user,
                        email=user_data['email'],
                        password=user_data['password']
                    )
                )
                networks = user_data['networks']
                for net in networks.keys():
                    net_data = networks[net]
                    network = yield from NetworkStore.create(
                        dict(
                            user_username=user,
                            name=net,
                            nickname=net_data["nick"],
                            hostname=net_data["host"],
                            port=net_data["port"],
                            realname=net_data["realname"],
                            username=net_data["username"],
                            network_password=net_data["password"],
                            usermode=net_data["usermode"],
                        )
                    )
Exemplo n.º 2
0
Arquivo: user.py Projeto: waartaa/ircb
def user_create(username, email, password):
    """Create a user"""
    yield from UserStore.create(dict(
        username=username,
        email=email,
        password=password
    ))
Exemplo n.º 3
0
 def post(self):
     username = yield from auth.get_auth(self.request)
     if username:
         raise web.HTTPForbidden()
     data = yield from self.request.post()
     form = UserForm(formdata=data)
     form.validate()
     yield from self._validate_username(form)
     yield from self._validate_email(form)
     if form.errors:
         return web.Response(body=json.dumps(form.errors).encode(),
                             status=400,
                             content_type='application/json')
     cleaned_data = form.data
     yield from UserStore.create(
         dict(username=cleaned_data['username'],
              email=cleaned_data['email'],
              password=cleaned_data['password'],
              first_name=cleaned_data.get('first_name', ''),
              last_name=cleaned_data.get('last_name', '')))
     return web.Response(body=b'OK')
Exemplo n.º 4
0
Arquivo: user.py Projeto: waartaa/ircb
 def post(self):
     username = yield from auth.get_auth(self.request)
     if username:
         raise web.HTTPForbidden()
     data = yield from self.request.post()
     form = UserForm(formdata=data)
     form.validate()
     yield from self._validate_username(form)
     yield from self._validate_email(form)
     if form.errors:
         return web.Response(body=json.dumps(form.errors).encode(),
                             status=400,
                             content_type='application/json')
     cleaned_data = form.data
     yield from UserStore.create(
         dict(
             username=cleaned_data['username'],
             email=cleaned_data['email'],
             password=cleaned_data['password'],
             first_name=cleaned_data.get('first_name', ''),
             last_name=cleaned_data.get('last_name', '')
         )
     )
     return web.Response(body=b'OK')
Exemplo n.º 5
0
def user_create(username, email, password):
    """Create a user"""
    yield from UserStore.create(
        dict(username=username, email=email, password=password))