当前位置: 首页>>代码示例>>Python>>正文


Python current_user.is_authenticated方法代码示例

本文整理汇总了Python中flask.ext.login.current_user.is_authenticated方法的典型用法代码示例。如果您正苦于以下问题:Python current_user.is_authenticated方法的具体用法?Python current_user.is_authenticated怎么用?Python current_user.is_authenticated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flask.ext.login.current_user的用法示例。


在下文中一共展示了current_user.is_authenticated方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: view

# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import is_authenticated [as 别名]
def view(tag_name):
    criteria = {}
    tag = Tag.objects.get_or_404(key=tag_name)
    if request.args.get('filter', None) != 'mine' or not current_user.is_authenticated:
        criteria['is_private'] = False
    syntax = Syntax.objects(key=tag_name).first()
    if syntax:
        criteria['codes__syntax'] = syntax
    else:
        criteria['tags'] = tag
    pastes = Paste.objects(**criteria).order_by('-updated_at')
    page = get_page()

    pagination = pastes.paginate(page, per_page=20)

    return render_template('tags/view.html',
                           tag=tag,
                           hot_pastes=Paste.objects(is_private=False).order_by('-views')[:10],
                           pagination=pagination) 
开发者ID:DoubleCiti,项目名称:daimaduan.com,代码行数:21,代码来源:tags.py

示例2: chat_initialize

# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import is_authenticated [as 别名]
def chat_initialize():
    first_words = ['True', 'False', 'For', 'While', 'If', 'Else', 'Elif', 'Undefined', 'Do', 'Virtual', 'Inline',
                   'Exit', 'Continue', 'Super', 'Break', 'Switch', 'Try', 'Catch', 'Class', 'Object', 'Abstract', 'Interface',
                   'Def', 'Var', 'Pass', 'Return', 'Static', 'Const', 'Template', 'Delete', 'Int',
                   'Float', 'Struct', 'Void', 'Self', 'This']
    second_words = ['C', 'C++', 'Lisp', 'Python', 'Java', 'JavaScript', 'Pascal', 'Objective-C',
                    'C#', 'Perl', 'Ruby', 'Ada', 'Haskell', 'Octave', 'Basic', 'Fortran', 'PHP', 'R',
                    'Assembly', 'COBOL', 'Rust', 'Swift', 'Bash', 'Brainfuck', 'OCaml', 'Clojure']

    if current_user.is_authenticated():
        session['username'] = current_user.reddit_username
    elif 'username' not in session or session['username'] in chat_users:
        while True:
            session['username'] = random.choice(first_words) + ' ' + random.choice(second_words)
            if session['username'] not in chat_users:
                chat_users.add(session['username'])
                break
    db.session.close() 
开发者ID:eleweek,项目名称:WatchPeopleCode,代码行数:20,代码来源:views.py

示例3: executar_funcao_sat

# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import is_authenticated [as 别名]
def executar_funcao_sat(funcaosat):

    resultado = None

    if funcaosat in FUNCOES_RESTRITAS:
        if not current_user.is_authenticated:
            return app.login_manager.unauthorized()
        funcao = FUNCOES_RESTRITAS.get(funcaosat)
    else:
        funcao = FUNCOES_ABERTAS.get(funcaosat)
        if not funcao:
            abort(404)

    form = funcao.get('form_class', EmptyForm)(request.form)
    if request.method == 'POST' and form.validate():
        resultado = getattr(executor, funcao.get('funcao').lower())(form)

    return render_template('funcao.html',
            funcao=funcao,
            form=form,
            resultado=resultado) 
开发者ID:base4sistemas,项目名称:sathub,代码行数:23,代码来源:views.py

示例4: index

# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import is_authenticated [as 别名]
def index():
    form = PostForm()
    if current_user.can(Permission.WRITE_ARTICLES) and \
            form.validate_on_submit():
        post = Post(body=form.body.data,
                    author=current_user._get_current_object())
        db.session.add(post)
        return redirect(url_for('.index'))
    page = request.args.get('page', 1, type=int)
    show_followed = False
    if current_user.is_authenticated():
        show_followed = bool(request.cookies.get('show_followed', ''))
    if show_followed:
        query = current_user.followed_posts
    else:
        query = Post.query
    pagination = query.order_by(Post.timestamp.desc()).paginate(
        page, per_page=current_app.config['FLASKY_POSTS_PER_PAGE'],
        error_out=False)
    posts = pagination.items
    return render_template('index.html', form=form, posts=posts,
                           show_followed=show_followed, pagination=pagination) 
开发者ID:miguelgrinberg,项目名称:flasky-with-celery,代码行数:24,代码来源:views.py

示例5: before_request

# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import is_authenticated [as 别名]
def before_request():
    g.started_at = time.time()
    g.unread_messages_count = 0
    if current_user.is_authenticated:
        g.unread_messages_count = current_user.user.unread_messages_count 
开发者ID:DoubleCiti,项目名称:daimaduan.com,代码行数:7,代码来源:__init__.py

示例6: view

# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import is_authenticated [as 别名]
def view(hash_id):
    bookmark = Bookmark.objects(hash_id=hash_id).get_or_404()
    bookmark.views += 1
    bookmark.save()

    bookmark_hash_id = None
    if current_user.is_authenticated and current_user.user == bookmark.user:
        bookmark_hash_id = bookmark.hash_id

    return render_template('bookmarks/view.html',
                           bookmark=bookmark,
                           bookmark_hash_id=bookmark_hash_id) 
开发者ID:DoubleCiti,项目名称:daimaduan.com,代码行数:14,代码来源:bookmarks.py

示例7: validate_username

# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import is_authenticated [as 别名]
def validate_username(self, field):
        if current_user.is_authenticated and current_user.user.username == field.data:
            return True

        user = User.objects(username=field.data).first()
        if user:
            raise ValidationError(u'用户名已被使用') 
开发者ID:DoubleCiti,项目名称:daimaduan.com,代码行数:9,代码来源:userinfo.py

示例8: validate_email

# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import is_authenticated [as 别名]
def validate_email(self, field):
        if current_user.is_authenticated:
            field.data = current_user.user.email
            return True

        if session['email']:
            if session['email'] != field.data:
                raise ValidationError(u'不能修改第三方登录的email地址')
        user = User.objects(email=field.data).first()
        if user:
            raise ValidationError(u'Email地址已被使用') 
开发者ID:DoubleCiti,项目名称:daimaduan.com,代码行数:13,代码来源:userinfo.py

示例9: before_request

# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import is_authenticated [as 别名]
def before_request():
    if current_user.is_authenticated:
        current_user.ping()
        if not current_user.confirmed and request.endpoint not in req_endpoint:
            return redirect(url_for('unconfirmed')) 
开发者ID:CIRCL,项目名称:cve-portal,代码行数:7,代码来源:server.py

示例10: complete

# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import is_authenticated [as 别名]
def complete(format='json'):
    if not current_user.is_authenticated():
        msg = _("You are not authorized to see that page")
        return jsonify({'status': 'error', 'message': msg}, status=403)

    query = db.session.query(Account)
    filter_string = request.args.get('q', '') + '%'
    query = query.filter(or_(Account.name.ilike(filter_string),
                             Account.fullname.ilike(filter_string)))
    return jsonify(Pager(query)) 
开发者ID:openspending,项目名称:spendb,代码行数:12,代码来源:account.py

示例11: session

# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import is_authenticated [as 别名]
def session():
    data = {
        'logged_in': current_user.is_authenticated(),
        'user': None
    }
    if current_user.is_authenticated():
        data['user'] = current_user
        data['api_key'] = current_user.api_key
    return jsonify(data) 
开发者ID:openspending,项目名称:spendb,代码行数:11,代码来源:session.py

示例12: logged_in

# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import is_authenticated [as 别名]
def logged_in():
    return current_user.is_authenticated() and current_user.is_active() 
开发者ID:openspending,项目名称:spendb,代码行数:4,代码来源:account.py

示例13: is_accessible

# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import is_authenticated [as 别名]
def is_accessible(self):
        """
        Determines if the current user is logged in as an admin.

        Returns:
            A boolean indicating if the current user is an admin.
        """
        if current_user.is_authenticated and current_user.admin:
            return True

        return False


# Defines column labels to be shared between resource views. 
开发者ID:radremedy,项目名称:radremedy,代码行数:16,代码来源:admin_helpers.py

示例14: body_tag_args

# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import is_authenticated [as 别名]
def body_tag_args():
    from flask.ext.login import current_user

    classes = []
    args = {}

    if current_user.is_authenticated():
        classes.append('loggedin')
        args['dataUserName'] = current_user.full_name()
        args['dataUserEmail'] = current_user.email
        args['dataUserId'] = current_user.id

    args['class_'] = ' '.join(classes)
    return args 
开发者ID:Code4SA,项目名称:mma-dexter,代码行数:16,代码来源:helpers.py

示例15: default_analysis_nature_id

# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import is_authenticated [as 别名]
def default_analysis_nature_id():
    from flask.ext.login import current_user

    if current_user.is_authenticated() and current_user.default_analysis_nature_id:
        return current_user.default_analysis_nature_id

    return 1 
开发者ID:Code4SA,项目名称:mma-dexter,代码行数:9,代码来源:user.py


注:本文中的flask.ext.login.current_user.is_authenticated方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。