Exemplo n.º 1
0
def verify_password(username_or_token, password):
    from api.models.user import UserModel
    #print("username_or_token = ", username_or_token)
    user = UserModel.verify_auth_token(username_or_token)
    if not user:
        user = UserModel.query.filter_by(username=username_or_token).first()
        if not user or not user.verify_password(password):
            return False
    g.user = user
    return True
Exemplo n.º 2
0
def verify_password(username_or_token, password):
    """
    Валидация пароля, при успешной валидации помещает объект пользователя в глобальное хранилище flask
    :param username_or_token: токен
    :param password: пароль
    :return: bool
    """
    from api.models.user import UserModel
    user = UserModel.verify_auth_token(username_or_token)
    if not user:
        user = UserModel.query.filter_by(username=username_or_token).first()
        if not user or not user.verify_password(password):
            return False
    g.user = user
    return True
Exemplo n.º 3
0
def get_user_roles(data):
    from api.models.user import UserModel
    token = data['username']
    user = UserModel.verify_auth_token(token)
    return user.get_role()