feat: move login_required wrapper outside (#1281)

This commit is contained in:
takatost 2023-10-08 05:21:32 -05:00 committed by GitHub
parent b711ce33b7
commit 024250803a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 44 additions and 65 deletions

View File

@ -1,5 +1,5 @@
from flask_login import current_user from flask_login import current_user
from core.login.login import login_required from libs.login import login_required
import flask_restful import flask_restful
from flask_restful import Resource, fields, marshal_with from flask_restful import Resource, fields, marshal_with
from werkzeug.exceptions import Forbidden from werkzeug.exceptions import Forbidden

View File

@ -3,10 +3,9 @@ import json
import logging import logging
from datetime import datetime from datetime import datetime
import flask
from flask_login import current_user from flask_login import current_user
from core.login.login import login_required from libs.login import login_required
from flask_restful import Resource, reqparse, fields, marshal_with, abort, inputs from flask_restful import Resource, reqparse, marshal_with, abort, inputs
from werkzeug.exceptions import Forbidden from werkzeug.exceptions import Forbidden
from constants.model_template import model_templates, demo_model_templates from constants.model_template import model_templates, demo_model_templates
@ -17,11 +16,9 @@ from controllers.console.wraps import account_initialization_required
from core.model_providers.error import ProviderTokenNotInitError, LLMBadRequestError from core.model_providers.error import ProviderTokenNotInitError, LLMBadRequestError
from core.model_providers.model_factory import ModelFactory from core.model_providers.model_factory import ModelFactory
from core.model_providers.model_provider_factory import ModelProviderFactory from core.model_providers.model_provider_factory import ModelProviderFactory
from core.model_providers.models.entity.model_params import ModelType
from events.app_event import app_was_created, app_was_deleted from events.app_event import app_was_created, app_was_deleted
from fields.app_fields import app_pagination_fields, app_detail_fields, template_list_fields, \ from fields.app_fields import app_pagination_fields, app_detail_fields, template_list_fields, \
app_detail_fields_with_site app_detail_fields_with_site
from libs.helper import TimestampField
from extensions.ext_database import db from extensions.ext_database import db
from models.model import App, AppModelConfig, Site from models.model import App, AppModelConfig, Site
from services.app_model_config_service import AppModelConfigService from services.app_model_config_service import AppModelConfigService

View File

@ -2,8 +2,8 @@
import logging import logging
from flask import request from flask import request
from core.login.login import login_required from libs.login import login_required
from werkzeug.exceptions import InternalServerError, NotFound from werkzeug.exceptions import InternalServerError
import services import services
from controllers.console import api from controllers.console import api

View File

@ -5,7 +5,7 @@ from typing import Generator, Union
import flask_login import flask_login
from flask import Response, stream_with_context from flask import Response, stream_with_context
from core.login.login import login_required from libs.login import login_required
from werkzeug.exceptions import InternalServerError, NotFound from werkzeug.exceptions import InternalServerError, NotFound
import services import services

View File

@ -2,8 +2,8 @@ from datetime import datetime
import pytz import pytz
from flask_login import current_user from flask_login import current_user
from core.login.login import login_required from libs.login import login_required
from flask_restful import Resource, reqparse, fields, marshal_with from flask_restful import Resource, reqparse, marshal_with
from flask_restful.inputs import int_range from flask_restful.inputs import int_range
from sqlalchemy import or_, func from sqlalchemy import or_, func
from sqlalchemy.orm import joinedload from sqlalchemy.orm import joinedload
@ -15,7 +15,7 @@ from controllers.console.setup import setup_required
from controllers.console.wraps import account_initialization_required from controllers.console.wraps import account_initialization_required
from fields.conversation_fields import conversation_pagination_fields, conversation_detail_fields, \ from fields.conversation_fields import conversation_pagination_fields, conversation_detail_fields, \
conversation_message_detail_fields, conversation_with_summary_pagination_fields conversation_message_detail_fields, conversation_with_summary_pagination_fields
from libs.helper import TimestampField, datetime_string, uuid_value from libs.helper import datetime_string
from extensions.ext_database import db from extensions.ext_database import db
from models.model import Message, MessageAnnotation, Conversation from models.model import Message, MessageAnnotation, Conversation

View File

@ -1,5 +1,5 @@
from flask_login import current_user from flask_login import current_user
from core.login.login import login_required from libs.login import login_required
from flask_restful import Resource, reqparse from flask_restful import Resource, reqparse
from controllers.console import api from controllers.console import api

View File

@ -16,9 +16,9 @@ from controllers.console.setup import setup_required
from controllers.console.wraps import account_initialization_required from controllers.console.wraps import account_initialization_required
from core.model_providers.error import LLMRateLimitError, LLMBadRequestError, LLMAuthorizationError, LLMAPIConnectionError, \ from core.model_providers.error import LLMRateLimitError, LLMBadRequestError, LLMAuthorizationError, LLMAPIConnectionError, \
ProviderTokenNotInitError, LLMAPIUnavailableError, QuotaExceededError, ModelCurrentlyNotSupportError ProviderTokenNotInitError, LLMAPIUnavailableError, QuotaExceededError, ModelCurrentlyNotSupportError
from core.login.login import login_required from libs.login import login_required
from fields.conversation_fields import message_detail_fields from fields.conversation_fields import message_detail_fields
from libs.helper import uuid_value, TimestampField from libs.helper import uuid_value
from libs.infinite_scroll_pagination import InfiniteScrollPagination from libs.infinite_scroll_pagination import InfiniteScrollPagination
from extensions.ext_database import db from extensions.ext_database import db
from models.model import MessageAnnotation, Conversation, Message, MessageFeedback from models.model import MessageAnnotation, Conversation, Message, MessageFeedback

View File

@ -1,5 +1,4 @@
# -*- coding:utf-8 -*- # -*- coding:utf-8 -*-
import json
from flask import request from flask import request
from flask_restful import Resource from flask_restful import Resource
@ -9,7 +8,7 @@ from controllers.console import api
from controllers.console.app import _get_app from controllers.console.app import _get_app
from controllers.console.setup import setup_required from controllers.console.setup import setup_required
from controllers.console.wraps import account_initialization_required from controllers.console.wraps import account_initialization_required
from core.login.login import login_required from libs.login import login_required
from events.app_event import app_model_config_was_updated from events.app_event import app_model_config_was_updated
from extensions.ext_database import db from extensions.ext_database import db
from models.model import AppModelConfig from models.model import AppModelConfig

View File

@ -1,7 +1,7 @@
# -*- coding:utf-8 -*- # -*- coding:utf-8 -*-
from flask_login import current_user from flask_login import current_user
from core.login.login import login_required from libs.login import login_required
from flask_restful import Resource, reqparse, fields, marshal_with from flask_restful import Resource, reqparse, marshal_with
from werkzeug.exceptions import NotFound, Forbidden from werkzeug.exceptions import NotFound, Forbidden
from controllers.console import api from controllers.console import api

View File

@ -5,7 +5,7 @@ from datetime import datetime
import pytz import pytz
from flask import jsonify from flask import jsonify
from flask_login import current_user from flask_login import current_user
from core.login.login import login_required from libs.login import login_required
from flask_restful import Resource, reqparse from flask_restful import Resource, reqparse
from controllers.console import api from controllers.console import api

View File

@ -1,16 +1,13 @@
import logging import logging
from datetime import datetime
from typing import Optional
import flask_login
import requests import requests
from flask import request, redirect, current_app, session from flask import request, redirect, current_app
from flask_login import current_user from flask_login import current_user
from flask_restful import Resource from flask_restful import Resource
from werkzeug.exceptions import Forbidden from werkzeug.exceptions import Forbidden
from core.login.login import login_required from libs.login import login_required
from libs.oauth_data_source import NotionOAuth from libs.oauth_data_source import NotionOAuth
from controllers.console import api from controllers.console import api
from ..setup import setup_required from ..setup import setup_required

View File

@ -2,10 +2,10 @@ import datetime
import json import json
from cachetools import TTLCache from cachetools import TTLCache
from flask import request, current_app from flask import request
from flask_login import current_user from flask_login import current_user
from core.login.login import login_required from libs.login import login_required
from flask_restful import Resource, marshal_with, fields, reqparse, marshal from flask_restful import Resource, marshal_with, reqparse
from werkzeug.exceptions import NotFound from werkzeug.exceptions import NotFound
from controllers.console import api from controllers.console import api
@ -15,7 +15,6 @@ from core.data_loader.loader.notion import NotionLoader
from core.indexing_runner import IndexingRunner from core.indexing_runner import IndexingRunner
from extensions.ext_database import db from extensions.ext_database import db
from fields.data_source_fields import integrate_notion_info_list_fields, integrate_list_fields from fields.data_source_fields import integrate_notion_info_list_fields, integrate_list_fields
from libs.helper import TimestampField
from models.dataset import Document from models.dataset import Document
from models.source import DataSourceBinding from models.source import DataSourceBinding
from services.dataset_service import DatasetService, DocumentService from services.dataset_service import DatasetService, DocumentService

View File

@ -4,8 +4,8 @@ from flask import request, current_app
from flask_login import current_user from flask_login import current_user
from controllers.console.apikey import api_key_list, api_key_fields from controllers.console.apikey import api_key_list, api_key_fields
from core.login.login import login_required from libs.login import login_required
from flask_restful import Resource, reqparse, fields, marshal, marshal_with from flask_restful import Resource, reqparse, marshal, marshal_with
from werkzeug.exceptions import NotFound, Forbidden from werkzeug.exceptions import NotFound, Forbidden
import services import services
from controllers.console import api from controllers.console import api

View File

@ -1,11 +1,10 @@
# -*- coding:utf-8 -*- # -*- coding:utf-8 -*-
import random
from datetime import datetime from datetime import datetime
from typing import List from typing import List
from flask import request, current_app from flask import request, current_app
from flask_login import current_user from flask_login import current_user
from core.login.login import login_required from libs.login import login_required
from flask_restful import Resource, fields, marshal, marshal_with, reqparse from flask_restful import Resource, fields, marshal, marshal_with, reqparse
from sqlalchemy import desc, asc from sqlalchemy import desc, asc
from werkzeug.exceptions import NotFound, Forbidden from werkzeug.exceptions import NotFound, Forbidden
@ -25,7 +24,6 @@ from core.model_providers.model_factory import ModelFactory
from extensions.ext_redis import redis_client from extensions.ext_redis import redis_client
from fields.document_fields import document_with_segments_fields, document_fields, \ from fields.document_fields import document_with_segments_fields, document_fields, \
dataset_and_document_fields, document_status_fields dataset_and_document_fields, document_status_fields
from libs.helper import TimestampField
from extensions.ext_database import db from extensions.ext_database import db
from models.dataset import DatasetProcessRule, Dataset from models.dataset import DatasetProcessRule, Dataset
from models.dataset import Document, DocumentSegment from models.dataset import Document, DocumentSegment

View File

@ -14,13 +14,12 @@ from controllers.console.setup import setup_required
from controllers.console.wraps import account_initialization_required from controllers.console.wraps import account_initialization_required
from core.model_providers.error import LLMBadRequestError, ProviderTokenNotInitError from core.model_providers.error import LLMBadRequestError, ProviderTokenNotInitError
from core.model_providers.model_factory import ModelFactory from core.model_providers.model_factory import ModelFactory
from core.login.login import login_required from libs.login import login_required
from extensions.ext_database import db from extensions.ext_database import db
from extensions.ext_redis import redis_client from extensions.ext_redis import redis_client
from fields.segment_fields import segment_fields from fields.segment_fields import segment_fields
from models.dataset import DocumentSegment from models.dataset import DocumentSegment
from libs.helper import TimestampField
from services.dataset_service import DatasetService, DocumentService, SegmentService from services.dataset_service import DatasetService, DocumentService, SegmentService
from tasks.enable_segment_to_index_task import enable_segment_to_index_task from tasks.enable_segment_to_index_task import enable_segment_to_index_task
from tasks.disable_segment_from_index_task import disable_segment_from_index_task from tasks.disable_segment_from_index_task import disable_segment_from_index_task

View File

@ -2,8 +2,8 @@ from cachetools import TTLCache
from flask import request, current_app from flask import request, current_app
import services import services
from core.login.login import login_required from libs.login import login_required
from flask_restful import Resource, marshal_with, fields from flask_restful import Resource, marshal_with
from controllers.console import api from controllers.console import api
from controllers.console.datasets.error import NoFileUploadedError, TooManyFilesError, FileTooLargeError, \ from controllers.console.datasets.error import NoFileUploadedError, TooManyFilesError, FileTooLargeError, \

View File

@ -1,7 +1,7 @@
import logging import logging
from flask_login import current_user from flask_login import current_user
from core.login.login import login_required from libs.login import login_required
from flask_restful import Resource, reqparse, marshal from flask_restful import Resource, reqparse, marshal
from werkzeug.exceptions import InternalServerError, NotFound, Forbidden from werkzeug.exceptions import InternalServerError, NotFound, Forbidden

View File

@ -2,8 +2,8 @@
from datetime import datetime from datetime import datetime
from flask_login import current_user from flask_login import current_user
from core.login.login import login_required from libs.login import login_required
from flask_restful import Resource, reqparse, fields, marshal_with, inputs from flask_restful import Resource, reqparse, marshal_with, inputs
from sqlalchemy import and_ from sqlalchemy import and_
from werkzeug.exceptions import NotFound, Forbidden, BadRequest from werkzeug.exceptions import NotFound, Forbidden, BadRequest
@ -12,7 +12,6 @@ from controllers.console.explore.wraps import InstalledAppResource
from controllers.console.wraps import account_initialization_required from controllers.console.wraps import account_initialization_required
from extensions.ext_database import db from extensions.ext_database import db
from fields.installed_app_fields import installed_app_list_fields from fields.installed_app_fields import installed_app_list_fields
from libs.helper import TimestampField
from models.model import App, InstalledApp, RecommendedApp from models.model import App, InstalledApp, RecommendedApp
from services.account_service import TenantService from services.account_service import TenantService

View File

@ -1,6 +1,6 @@
# -*- coding:utf-8 -*- # -*- coding:utf-8 -*-
from flask_login import current_user from flask_login import current_user
from core.login.login import login_required from libs.login import login_required
from flask_restful import Resource, fields, marshal_with from flask_restful import Resource, fields, marshal_with
from sqlalchemy import and_ from sqlalchemy import and_

View File

@ -1,5 +1,5 @@
from flask_login import current_user from flask_login import current_user
from core.login.login import login_required from libs.login import login_required
from flask_restful import Resource from flask_restful import Resource
from functools import wraps from functools import wraps

View File

@ -2,7 +2,7 @@ import json
from functools import wraps from functools import wraps
from flask_login import current_user from flask_login import current_user
from core.login.login import login_required from libs.login import login_required
from flask_restful import Resource from flask_restful import Resource
from controllers.console.setup import setup_required from controllers.console.setup import setup_required
from controllers.console.wraps import account_initialization_required from controllers.console.wraps import account_initialization_required

View File

@ -4,7 +4,7 @@ from datetime import datetime
import pytz import pytz
from flask import current_app, request from flask import current_app, request
from flask_login import current_user from flask_login import current_user
from core.login.login import login_required from libs.login import login_required
from flask_restful import Resource, reqparse, fields, marshal_with from flask_restful import Resource, reqparse, fields, marshal_with
from services.errors.account import CurrentPasswordIncorrectError as ServiceCurrentPasswordIncorrectError from services.errors.account import CurrentPasswordIncorrectError as ServiceCurrentPasswordIncorrectError

View File

@ -1,7 +1,7 @@
# -*- coding:utf-8 -*- # -*- coding:utf-8 -*-
from flask import current_app from flask import current_app
from flask_login import current_user from flask_login import current_user
from core.login.login import login_required from libs.login import login_required
from flask_restful import Resource, reqparse, marshal_with, abort, fields, marshal from flask_restful import Resource, reqparse, marshal_with, abort, fields, marshal
import services import services

View File

@ -1,5 +1,5 @@
from flask_login import current_user from flask_login import current_user
from core.login.login import login_required from libs.login import login_required
from flask_restful import Resource, reqparse from flask_restful import Resource, reqparse
from werkzeug.exceptions import Forbidden from werkzeug.exceptions import Forbidden

View File

@ -1,5 +1,5 @@
from flask_login import current_user from flask_login import current_user
from core.login.login import login_required from libs.login import login_required
from flask_restful import Resource, reqparse from flask_restful import Resource, reqparse
from controllers.console import api from controllers.console import api

View File

@ -1,6 +1,6 @@
# -*- coding:utf-8 -*- # -*- coding:utf-8 -*-
from flask_login import current_user from flask_login import current_user
from core.login.login import login_required from libs.login import login_required
from flask_restful import Resource, reqparse from flask_restful import Resource, reqparse
from werkzeug.exceptions import Forbidden from werkzeug.exceptions import Forbidden

View File

@ -1,7 +1,7 @@
import json import json
from flask_login import current_user from flask_login import current_user
from core.login.login import login_required from libs.login import login_required
from flask_restful import Resource, abort, reqparse from flask_restful import Resource, abort, reqparse
from werkzeug.exceptions import Forbidden from werkzeug.exceptions import Forbidden

View File

@ -3,9 +3,8 @@ import logging
from flask import request from flask import request
from flask_login import current_user from flask_login import current_user
from core.login.login import login_required from libs.login import login_required
from flask_restful import Resource, fields, marshal_with, reqparse, marshal, inputs from flask_restful import Resource, fields, marshal_with, reqparse, marshal, inputs
from flask_restful.inputs import int_range
from controllers.console import api from controllers.console import api
from controllers.console.admin import admin_required from controllers.console.admin import admin_required

View File

@ -4,12 +4,9 @@ import services.dataset_service
from controllers.service_api import api from controllers.service_api import api
from controllers.service_api.dataset.error import DatasetNameDuplicateError from controllers.service_api.dataset.error import DatasetNameDuplicateError
from controllers.service_api.wraps import DatasetApiResource from controllers.service_api.wraps import DatasetApiResource
from core.login.login import current_user from libs.login import current_user
from core.model_providers.models.entity.model_params import ModelType from core.model_providers.models.entity.model_params import ModelType
from extensions.ext_database import db
from fields.dataset_fields import dataset_detail_fields from fields.dataset_fields import dataset_detail_fields
from models.account import Account, TenantAccountJoin
from models.dataset import Dataset
from services.dataset_service import DatasetService from services.dataset_service import DatasetService
from services.provider_service import ProviderService from services.provider_service import ProviderService

View File

@ -1,8 +1,6 @@
import datetime
import json import json
import uuid
from flask import current_app, request from flask import request
from flask_restful import reqparse, marshal from flask_restful import reqparse, marshal
from sqlalchemy import desc from sqlalchemy import desc
from werkzeug.exceptions import NotFound from werkzeug.exceptions import NotFound
@ -13,13 +11,11 @@ from controllers.service_api.app.error import ProviderNotInitializeError
from controllers.service_api.dataset.error import ArchivedDocumentImmutableError, DocumentIndexingError, \ from controllers.service_api.dataset.error import ArchivedDocumentImmutableError, DocumentIndexingError, \
NoFileUploadedError, TooManyFilesError NoFileUploadedError, TooManyFilesError
from controllers.service_api.wraps import DatasetApiResource from controllers.service_api.wraps import DatasetApiResource
from core.login.login import current_user from libs.login import current_user
from core.model_providers.error import ProviderTokenNotInitError from core.model_providers.error import ProviderTokenNotInitError
from extensions.ext_database import db from extensions.ext_database import db
from extensions.ext_storage import storage
from fields.document_fields import document_fields, document_status_fields from fields.document_fields import document_fields, document_status_fields
from models.dataset import Dataset, Document, DocumentSegment from models.dataset import Dataset, Document, DocumentSegment
from models.model import UploadFile
from services.dataset_service import DocumentService from services.dataset_service import DocumentService
from services.file_service import FileService from services.file_service import FileService

View File

@ -7,10 +7,9 @@ from flask_login import user_logged_in
from flask_restful import Resource from flask_restful import Resource
from werkzeug.exceptions import NotFound, Unauthorized from werkzeug.exceptions import NotFound, Unauthorized
from core.login.login import _get_user from libs.login import _get_user
from extensions.ext_database import db from extensions.ext_database import db
from models.account import Tenant, TenantAccountJoin, Account from models.account import Tenant, TenantAccountJoin, Account
from models.dataset import Dataset
from models.model import ApiToken, App from models.model import ApiToken, App