def api_create(self, **data): fillable = Validator.validate(data, self.__class__.fields, self.__class__.defaults) if self.find({"login": fillable["login"]}) is not None: Validator.fail('Der Benutzername ist bereits vergeben.') resource = self.create(fillable) return resource
def PUT(self, username, password, **data): for user in self.list: if user["username"] == username: if user["password"] != password: Validator.fail("The username or password is wrong!") return json.dumps(user) Validator.fail("The username or password is wrong!")
def POST(self, **data): Validator.require(data, "login", "password") user = self.application.user.find({ "login": data["login"], "password": data["password"] }) if user is not None: return self.application.user.response(user) Validator.fail("The username or password is wrong!")
def api_create(self, **data): fillable = Validator.validate(data, self.__class__.fields, self.__class__.defaults) if self.find({"login": fillable["login"]}) is not None: Validator.fail('Der Benutzername ist bereits vergeben.'); resource = self.create(fillable) return resource
def POST(self, **data): Validator.require(data, "login", "password") user = self.application.user.find({"login": data["login"], "password": data["password"]}) if user is not None: return self.application.user.response(user) Validator.fail("The username or password is wrong!")