Пример #1
0
    def put(self, *_args, **_kwargs):
        args = self.parse_json_arguments(username=ENFORCED,
                                         email=ENFORCED,
                                         password=ENFORCED)

        if not self.pattern_match('email', args.email):
            return self.fail(3032)
        if not self.pattern_match('password', args.password):
            return self.fail(3031)

        exists_result = tasks.query_email_or_username_exists(
            username=args.username, email=args.email)
        if exists_result:
            return self.fail(3004)

        insert_result = tasks.insert_user(
            username=args.username,
            email=args.email,
            pswd=md5(args.password.encode()).hexdigest())

        insert_result = tasks.insert_category(
            category_name='默认分类',
            category_type=0,
            user_id=insert_result['data']['user_id'])

        self.success()
Пример #2
0
    def put(self, *_args, **_kwargs):
        _params = self.check_auth(2)
        if not _params:
            return

        args = self.parse_json_arguments(category_name=ENFORCED)

        insert_result = tasks.insert_category(category_name=args.category_name,
                                              category_type=1,
                                              user_id=_params.user_id)

        self.success()