Пример #1
0
def load_token(token):
    max_age = app.config["REMEMBER_COOKIE_DURATION"].total_seconds()
    data = login_serializer.loads(token, max_age=max_age)
    user = User.query.get(data[0])
    if user and data[1] == hash_pass(user.password):
        return user
    return None
Пример #2
0
def load_token(token):
    max_age = app.config["REMEMBER_COOKIE_DURATION"].total_seconds()
    data = login_serializer.loads(token, max_age=max_age)
    user = models.User.query.get(data[0])
    if user and data[1] == user.password:
        return user
    return None
Пример #3
0
def load_token(token):
    """
    Flask-Login token_loader callback.
    The token_loader function asks this function to take the token that was
    stored on the users computer process it to check if its valid and then
    return a User Object if its valid or None if its not valid.
    """

    # The Token itself was generated by User.get_auth_token.  So it is up to
    # us to known the format of the token data itself.

    # The Token was encrypted using itsdangerous.URLSafeTimedSerializer which
    # allows us to have a max_age on the token itself.  When the cookie is stored
    # on the users computer it also has a exipry date, but could be changed by
    # the user, so this feature allows us to enforce the exipry date of the token
    # server side and not rely on the users cookie to exipre.
    max_age = app.config["REMEMBER_COOKIE_DURATION"].total_seconds()

    # Decrypt the Security Token, data = [username, hashpass]
    data = login_serializer.loads(token, max_age=max_age)

    # Find the User
    user = models.User.query.filter_by(id=data[0]).first()

    # Check Password and return user or None
    # if user and user.is_correct_password(data[1]):
    if user and user.password == data[1]:
        return user
    return None
Пример #4
0
def load_token(token):
    max_age = timedelta(days=14).total_seconds()
    data = login_serializer.loads(token, max_age=max_age)
    user = User.query.filter_by(username=data[0])

    if user and data[1] == user.password_hash:
        return user
    return None
Пример #5
0
def load_token(token):
    max_age = app.config["REMEMBER_COOKIE_DURATION"].total_seconds()

    #Decrypt the Security Token, data = [username, hashpass]
    data = login_serializer.loads(token, max_age=max_age)

    #Find the User
    user = models.Users.query.get(data[0])

    #Check Password and return user or None
    if user and data[1] == user.password:
        return user
    return None
Пример #6
0
def load_token(token):
    max_age = app.config["REMEMBER_COOKIE_DURATION"].total_seconds()
 
    #Decrypt the Security Token, data = [username, hashpass]
    data = login_serializer.loads(token, max_age=max_age)
 
    #Find the User
    user = models.Users.query.get(data[0])
 
    #Check Password and return user or None
    if user and data[1] == user.password:
        return user
    return None
Пример #7
0
def load_token(token):
    max_age = app.config["REMEMBER_COOKIE_DURATION"].total_seconds()

    # Decrypt the Security Token, data = [username, hashpass]
    data = login_serializer.loads(token, max_age=max_age)

    # Find the User
    user = models.User.query.filter_by(id=data[0]).first()

    # Check Password and return user or None
    # if user and user.is_correct_password(data[1]):
    if user and user.password == data[1]:
        return user
    return None
Пример #8
0
def load_token(token):
    try:
        max_age = app.config["REMEMBER_COOKIE_DURATION"].total_seconds()
        payload = login_serializer.loads(token, max_age)

        #print('user='******'exception occurred=' + e.message)