Python flask.g 模块,token_used() 实例源码

我们从Python开源项目中,提取了以下33个代码示例,用于说明如何使用flask.g.token_used()

项目:myproject    作者:dengliangshi    | 项目源码 | 文件源码
def verify_password(email_or_token, password):
    """Verify user using email and address or token, 
    otherwise, set as anonymous user.
    """
    if email_or_token == '':
        g.current_user = AnonymousUser()
        return True
    if password == '':
        g.current_user = User.verify_auth_token(email_or_token)
        g.token_used = True
        return g.current_user is not None
    user = User.query.filter_by(email=email_or_token).first()
    if not user:
        return False
    g.current_user = user
    g.token_used = False
    return user.verify_password(password)
项目:Plog    作者:thundernet8    | 项目源码 | 文件源码
def verify_password(username, password):
    authorization = request.headers.get('Authorization', '').split(' ')
    bearer = authorization[1] if len(authorization) > 1 else ''
    if bearer:
        g.current_user = User.verify_access_token(bearer)
        g.token_used = True
        return g.current_user is not None
    if username == '':
        g.current_user = AnonymousUser()
        return True
    user = User(username=username)
    if not user or not user.user_id:
        return False
    g.current_user = user
    g.token_used = False
    return user.verify_password(password)
项目:flask-blog    作者:zhuwei05    | 项目源码 | 文件源码
def verify_password(email_or_token, password):
    if email_or_token == '':
        g.current_user = AnonymousUser()
        return True
    if password == '':
        g.current_user = User.verify_auth_token(email_or_token)
        g.token_used = True
        return g.current_user is not None
    user = User.query.filter_by(email=email_or_token).first()
    if not user:
        return False
    g.current_user = user
    g.token_used = False
    return user.verify_password(password)

# 401
项目:MyFlasky    作者:aliasxu    | 项目源码 | 文件源码
def verify_password(email_or_token,password):
    if email_or_token == '':
        g.current_user = AnonymousUser()
        return True

    if password == '':
        g.current_user = User.verify_auth_token(email_or_token)
        g.token_used = True
        return g.current_user is not None

    user = User.query.filter_by(email=email_or_token).first()
    if not user:
        return False
    g.current_user = user
    g.token_used = False

    return user.verify_password(password)
项目:circleci-demo-python-flask    作者:CircleCI-Public    | 项目源码 | 文件源码
def verify_password(email_or_token, password):
    if email_or_token == '':
        g.current_user = AnonymousUser()
        return True
    if password == '':
        g.current_user = User.verify_auth_token(email_or_token)
        g.token_used = True
        return g.current_user is not None
    user = User.query.filter_by(email=email_or_token).first()
    if not user:
        return False
    g.current_user = user
    g.token_used = False
    return user.verify_password(password)
项目:circleci-demo-python-flask    作者:CircleCI-Public    | 项目源码 | 文件源码
def get_token():
    if g.current_user.is_anonymous or g.token_used:
        return unauthorized('Invalid credentials')
    return jsonify({'token': g.current_user.generate_auth_token(
        expiration=3600), 'expiration': 3600})
项目:Simpleblog    作者:Blackyukun    | 项目源码 | 文件源码
def verify_password(email_or_token, password):
    if email_or_token == '':
        g.current_user = AnonymousUser()
        return True
    if password == '':
        g.current_user = User.verify_auth_token(email_or_token)
        g.token_used = True
        return g.current_user is not None
    user = User.query.filter_by(email=email_or_token).first()
    if not user:
        return False
    g.current_user = user
    g.token_used = False
    return user.verify_password(password)
项目:Simpleblog    作者:Blackyukun    | 项目源码 | 文件源码
def get_token():
    if g.current_user.is_anonymous or g.token_used:
        return unauthorized('Invalid credentials')
    return jsonify({'token': g.current_user.generate_auth_token(
        expiration=3600), 'expiration': 3600})
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def verify_password(email_or_token, password):
    if email_or_token == '':
        g.current_user = AnonymousUser()
        return True
    if password == '':
        g.current_user = User.verify_auth_token(email_or_token)
        g.token_used = True
        return g.current_user is not None
    user = User.query.filter_by(email=email_or_token).first()
    if not user:
        return False
    g.current_user = user
    g.token_used = False
    return user.verify_password(password)
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def get_token():
    if g.current_user.is_anonymous or g.token_used:
        return unauthorized('Invalid credentials')
    return jsonify({'token': g.current_user.generate_auth_token(
        expiration=3600), 'expiration': 3600})
项目:PilosusBot    作者:pilosus    | 项目源码 | 文件源码
def verify_password(email_or_token, password):
    if email_or_token == '':
        g.current_user = AnonymousUser()
        return True
    if password == '':
        g.current_user = User.verify_auth_token(email_or_token)
        g.token_used = True
        return g.current_user is not None
    user = User.query.filter_by(email=email_or_token).first()
    if not user:
        return False
    g.current_user = user
    g.token_used = False
    return user.verify_password(password)
项目:PilosusBot    作者:pilosus    | 项目源码 | 文件源码
def get_token():
    if g.current_user.is_anonymous or g.token_used:
        return unauthorized('Invalid credentials')
    return jsonify({'token': g.current_user.generate_auth_token(
        expiration=3600), 'expiration': 3600})
项目:pyetje    作者:rorlika    | 项目源码 | 文件源码
def verify_password(email_or_token, password):
    if email_or_token == '':
        g.current_user = AnonymousUser()
        return True
    if password == '':
        g.current_user = User.verify_auth_token(email_or_token)
        g.token_used = True
        return g.current_user is not None
    user = User.query.filter_by(email=email_or_token).first()
    if not user:
        return False
    g.current_user = user
    g.token_used = False
    return user.verify_password(password)
项目:pyetje    作者:rorlika    | 项目源码 | 文件源码
def get_token():
    if g.current_user.is_anonymous or g.token_used:
        return unauthorized('Invalid credentials')
    return jsonify({'token': g.current_user.generate_auth_token(
        expiration=3600), 'expiration': 3600})
项目:smart-iiot    作者:quanpower    | 项目源码 | 文件源码
def verify_password(email_or_token, password):
    if email_or_token == '':
        return False
    if password == '':
        g.current_user = User.verify_auth_token(email_or_token)
        g.token_used = True
        return g.current_user is not None
    user = User.query.filter_by(email=email_or_token).first()
    if not user:
        return False
    g.current_user = user
    g.token_used = False
    return user.verify_password(password)
项目:smart-iiot    作者:quanpower    | 项目源码 | 文件源码
def get_token():
    if g.current_user.is_anonymous or g.token_used:
        return unauthorized('Invalid credentials')
    return jsonify({'token': g.current_user.generate_auth_token(
        expiration=3600), 'expiration': 3600})
项目:SweetHeart    作者:haojunyu    | 项目源码 | 文件源码
def verify_password(openid_or_token, password):
  print 'api: verify password'
  print openid_or_token
  if openid_or_token == '':
    print 'openid_or_token == null'
    g.current_user = AnonymousUser()
    return True
  user = User.verify_auth_token(openid_or_token)
  if user:
    # token??
    print 'token login'
    g.token_used = True
  else:
    user = User.query.filter_by(openId=openid_or_token).first()
    if user:
      # openId??
      print 'openid login'
      g.token_used = False
    else:
      # ?token?openId??
      return False
  g.current_user = user
  print g.token_used, user
  return True

# ?????????
项目:SweetHeart    作者:haojunyu    | 项目源码 | 文件源码
def get_token():
  if g.current_user.is_anonymous or g.token_used:
    return unauthorized('Invalid credentials')
  return jsonify({'token': g.current_user.generate_auth_token(expiration=3600), 'expiratioin': 3600})
项目:webapp    作者:superchilli    | 项目源码 | 文件源码
def verify_password(email_or_token, password):
    if email_or_token == '':
        g.current_user = AnonymousUser()
        return True
    if password == '':
        g.current_user = User.verify_auth_token(email_or_token)
        g.token_used = True
        return g.current_user is not None
    user = User.query.filter_by(email=email_or_token).first()
    if not user:
        return False
    g.current_user = user
    g.token_used = False
    return user.verify_password(password)
项目:webapp    作者:superchilli    | 项目源码 | 文件源码
def get_token():
    if g.current_user.is_anonymous or g.token_used:
        return unauthorized('Invalid credentials')
    return jsonify({'token': g.current_user.generate_auth_token(
        expiration=3600), 'expiration': 3600})
项目:project    作者:Junctionzc    | 项目源码 | 文件源码
def verify_password(email_or_token, password):
    if email_or_token== '':
        g.current_user = AnonymousUser()
        return True
    if password == '':
        g.current_user = User.verify_auth_token(email_or_token)
        g.token_used = True
        return g.current_user is not None
    user = User.query.filter_by(email = email_or_token).first()
    if not user:
        return False
    g.current_user = user
    g.token_used = False
    return user.verify_password(password)
项目:project    作者:Junctionzc    | 项目源码 | 文件源码
def get_token():
    if g.current_user.is_anonymous or g.token_used:
        return unauthorized('Invalid credentials')
    return jsonify({'token': g.current_user.generate_auth_token(
        expiration = 3600), 'expiration': 3600})
项目:Oyster-app    作者:XzAmrzs    | 项目源码 | 文件源码
def verify_password(email_or_token, password):
    if email_or_token == '':
        g.current_user = AnonymousUser()
        return True
    if password == '':
        g.current_user = User.verify_auth_token(email_or_token)
        g.token_used = True
        return g.current_user is not None
    user = User.query.filter_by(email=email_or_token).first()
    if not user:
        return False
    g.current_user = user
    g.token_used = False
    return user.verify_password(password)
项目:Oyster-app    作者:XzAmrzs    | 项目源码 | 文件源码
def get_token():
    if g.current_user.is_anonymous or g.token_used:
        return unauthorized('Invalid credentials')
    return jsonify({'token': g.current_user.generate_auth_token(
        expiration=3600), 'expiration': 3600})
项目:LivroFlask    作者:antoniocsz    | 项目源码 | 文件源码
def verify_password(email_or_token, password):
    if email == '':
        g.current_user = AnonymousUser()
        return True
    if password == '':
        g.current_user = User.verify_auth_token(email_or_token)
        g.token_used = True
        return g.current_user is not None
    user = User.query.filter_by(email=email_or_token).first()
    if not user:
        return False
    g.current_user = user
    g.token_used = False
    return user.verify_password(password)
项目:ztool-backhend    作者:Z-Tool    | 项目源码 | 文件源码
def verify_password(email_or_token, password):
    if email_or_token == '':
        g.current_user = AnonymousUser()
        return True
    if password == '':
        g.current_user = User.verify_auth_token(email_or_token)
        g.token_used = True
        return g.current_user is not None
    user = User.query.filter_by(email=email_or_token).first()
    if not user:
        return False
    g.current_user = user
    g.token_used = False
    return user.verify_password(password)
项目:ztool-backhend    作者:Z-Tool    | 项目源码 | 文件源码
def get_token():
    if g.current_user.is_anonymous or g.token_used:
        return unauthorized('Invalid credentials')
    return jsonify(token=g.current_user.generate_auth_token(expiration=86400), expiration=86400, email=g.current_user.email)
项目:flask-blog    作者:zhuwei05    | 项目源码 | 文件源码
def get_token():
    if g.current_user.is_anonymous or g.token_used:
        return unauthorized('Invalid credentials')
    return jsonify({'token': g.current_user.generate_auth_token(
        expiration=3600), 'expiration': 3600})
项目:blog    作者:hukaixuan    | 项目源码 | 文件源码
def verify_password(email_or_token, password):
    if email_or_token == '':
        g.current_user = AnonymousUser()
        return True
    if password == '':
        g.current_user = User.verify_auth_token(email_or_token)
        g.token_used = True
        return g.current_user is not None
    user = User.query.filter_by(email=email_or_token).first()
    if not user:
        return False
    g.current_user = user
    g.token_used = False
    return user.verify_password(password)
项目:blog    作者:hukaixuan    | 项目源码 | 文件源码
def get_token():
    if g.current_user.is_anonymous or g.token_used:
        return unauthorized('Invalid creentials')
    return jsonify({'token': g.current_user.generate_auth_token(
                    expiration=3600), 'expiration':3600})
项目:ztool-backhend-mongo    作者:Z-Tool    | 项目源码 | 文件源码
def verify_password(email_or_token, password):
    if email_or_token == '':
        g.current_user = AnonymousUser()
        return True
    if password == '':
        g.current_user = User.verify_auth_token(email_or_token)
        g.token_used = True
        return g.current_user is not None
    user = User.objects.filter(email=email_or_token)
    if not user:
        return False
    user = user.first_or_404()
    g.current_user = user
    g.token_used = False
    return user.verify_password(password)
项目:ztool-backhend-mongo    作者:Z-Tool    | 项目源码 | 文件源码
def get_token():
    if g.current_user.is_anonymous or g.token_used:
        return unauthorized('Invalid credentials')
    return jsonify(token=g.current_user.generate_auth_token(expiration=86400).decode(), expiration=86400,
                   email=g.current_user.email)
项目:MyFlasky    作者:aliasxu    | 项目源码 | 文件源码
def get_token():
    if g.current_user.is_anonymous or g.token_used:
        return unauthorized('Invalid credentials')
    return jsonify({'token':g.current_user.generate_auth_token(expiration=3600),'expiration':3600})