示例#1
0
def index():
    clients = Client.query.filter_by(
        user_id=current_user.get_id(),
        is_internal=False,
    ).all()

    tokens = Token.query.options(db.joinedload('client')).filter(
        Token.user_id == current_user.get_id(),
        Token.is_personal == True,  # noqa
        Token.is_internal == False,
        Client.is_internal == True,
    ).all()

    authorized_apps = Token.query.options(db.joinedload('client')).filter(
        Token.user_id == current_user.get_id(),
        Token.is_personal == False,  # noqa
        Token.is_internal == False,
        Client.is_internal == False,
    ).all()

    return render_template(
        "oauth2server/settings/index.html",
        clients=clients,
        tokens=tokens,
        authorized_apps=authorized_apps,
    )
示例#2
0
def index():
    clients = Client.query.filter_by(
        user_id=current_user.get_id(),
        is_internal=False,
    ).all()

    tokens = Token.query.options(db.joinedload('client')).filter(
        Token.user_id == current_user.get_id(),
        Token.is_personal == True,  # noqa
        Token.is_internal == False,
        Client.is_internal == True,
    ).all()

    authorized_apps = Token.query.options(db.joinedload('client')).filter(
        Token.user_id == current_user.get_id(),
        Token.is_personal == False,  # noqa
        Token.is_internal == False,
        Client.is_internal == False,
    ).all()

    return render_template(
        "oauth2server/settings/index.html",
        clients=clients,
        tokens=tokens,
        authorized_apps=authorized_apps,
    )
示例#3
0
 def get_by_token(cls, client_id, access_token, token_type=''):
     """Get RemoteAccount object for token."""
     return cls.query.options(db.joinedload('remote_account')).filter(
         RemoteAccount.id == RemoteToken.id_remote_account,
         RemoteAccount.client_id == client_id,
         RemoteToken.token_type == token_type,
         RemoteToken.access_token == access_token,
     ).first()
示例#4
0
def get_message(uid, msgid):
    """
    Get a message with its status and sender nickname.
    @param uid: user id
    @param msgid: message id
    @return: exactly one message or raise an exception.
    """
    return UserMsgMESSAGE.query.options(
        db.joinedload_all(UserMsgMESSAGE.message, MsgMESSAGE.user_from)).\
        options(db.joinedload(UserMsgMESSAGE.user_to)).\
        filter(filter_user_message(uid, msgid)).one()
示例#5
0
 def get_by_token(cls, client_id, access_token, token_type=""):
     """Get RemoteAccount object for token."""
     return (
         cls.query.options(db.joinedload("remote_account"))
         .filter(
             RemoteAccount.id == RemoteToken.id_remote_account,
             RemoteAccount.client_id == client_id,
             RemoteToken.token_type == token_type,
             RemoteToken.access_token == access_token,
         )
         .first()
     )
示例#6
0
    def get(cls, user_id, client_id, token_type="", access_token=None):
        """Get RemoteToken for user."""
        args = [
            RemoteAccount.id == RemoteToken.id_remote_account,
            RemoteAccount.user_id == user_id,
            RemoteAccount.client_id == client_id,
            RemoteToken.token_type == token_type,
        ]

        if access_token:
            args.append(RemoteToken.access_token == access_token)

        return cls.query.options(db.joinedload("remote_account")).filter(*args).first()
示例#7
0
    def get(cls, user_id, client_id, token_type='', access_token=None):
        """Get RemoteToken for user."""
        args = [
            RemoteAccount.id == RemoteToken.id_remote_account,
            RemoteAccount.user_id == user_id,
            RemoteAccount.client_id == client_id,
            RemoteToken.token_type == token_type,
        ]

        if access_token:
            args.append(RemoteToken.access_token == access_token)

        return cls.query.options(
            db.joinedload('remote_account')).filter(*args).first()
示例#8
0
def get_all_messages_for_user(uid):
    """
    Get all messages for a user's inbox, without the eventual
    non-expired reminders.

    @param uid: user id
    @return: [(message_id,
              id_user_from,
              nickname_user_from,
              message_subject,
              message_sent_date,
              message_status)]
    """
    update_user_inbox_for_reminders(uid)
    return MsgMESSAGE.query.options(db.joinedload(MsgMESSAGE.user_from)).\
        join(UserMsgMESSAGE).\
        filter(filter_all_messages_from_user(uid)).\
        order_by(MsgMESSAGE.sent_date).all()