Exemplo n.º 1
0
    def post(self):
        '''
        Create a new user (if user exists, error response is returned) from
        sent data (user object at JSON format).
        '''

        if UserManager.getUser():
            self.return_failure("User already exists.")

        else:
            data = self.get_body_as_dict(expectedFields=["name"])

            if data:
                user = User()
                user.name = data['name']
                user.save()
                user.key = user._id
                user.save()

                self.return_json(user.toJson(), 201)

            else:
                self.return_failure(
                    "Data are not correct. User has not been created.",
                    400)
Exemplo n.º 2
0
def set_default_user(step):
    world.user = User(name="John Doe",
                      password=hashlib.sha224("password").hexdigest(),
                      key="key",
                      authorKey="authorKey",
                      url="url",
                      description="my description")
    world.user._id = "userid"
Exemplo n.º 3
0
def set_a_new_user(step):
    world.user = User(
        name = "John Doe",
        password = hashlib.sha224("password").hexdigest(),
        key = None,
        authorKey = "authorKey",
        url = ROOT_URL,
        description = "my description"
    )
Exemplo n.º 4
0
    def set_default_user(self, url=ROOT_URL):
        '''
        Set to DB default user. This is useful for automatic login.
        '''

        self.root_url = url

        self.user = UserManager.getUser()
        if self.user:
            self.user.delete()

        self.user = User(name="John Doe",
                         password=hashlib.sha224("password").hexdigest(),
                         key="key",
                         authorKey="authorKey",
                         url=url,
                         description="my description")
        self.user.save()