def post(self): args = self.__parse_args() email = args[self.FIELD_EMAIL] password = args[self.FIELD_PASSWORD] if not is_email_valid(email): raise ValidationError(message=errors.ERROR_INVALID_EMAIL_ADDRESS, field=self.FIELD_EMAIL) u = User.query.filter_by(email=email).first() if u: return u.verify_password(password) else: raise ObjectNotFoundError(message=errors.ERROR_USER_DOES_NOT_EXIST)
def post(self): args = self.__parse_args() if not is_email_valid(args[self.FIELD_EMAIL]): raise ValidationError(message=errors.ERROR_INVALID_EMAIL_ADDRESS, field=self.FIELD_EMAIL) if self.__user_exists(args[self.FIELD_EMAIL]): raise ObjectAlreadyExistsError(message=errors.ERROR_USER_ALREADY_EXIST) u = User(args[self.FIELD_NAME], args[self.FIELD_EMAIL], args[self.FIELD_PASSWORD], str(uuid.uuid4())) db.session.add(u) db.session.commit() return u