# if the sess is empty, it's an anonymous user or just logged out # so we can skip this
if sess and ident != sess.get('_id', None): if mode == 'basic' or sess.permanent: sess['_fresh'] = False session_protected.send(app) return False elif mode == 'strong': for k in SESSION_KEYS: sess.pop(k, None)
# if there is no '_id', then take the current one for good if '_id' not in sess: sess['_id'] = ident
# if the sess is empty, it's an anonymous user, or just logged out # so we can skip this, unless 'strong' protection is active, # in which case we need to double check for the remember me token check_protection = sess or mode == 'strong'
if check_protection and ident != sess.get('_id', None): if mode == 'basic' or sess.permanent: sess['_fresh'] = False session_protected.send(app) return False elif mode == 'strong': sess.clear() sess['remember'] = 'clear' session_protected.send(app) return True