def wrapped(*args, **kwargs): user = get_authenticated_user() if not user or user.robot: raise Unauthorized() if get_validated_oauth_token(): return func(*args, **kwargs) last_login = session.get("login_time", datetime.datetime.min) valid_span = datetime.datetime.now() - FRESH_LOGIN_TIMEOUT logger.debug("Checking fresh login for user %s: Last login at %s", user.username, last_login) if (last_login >= valid_span or not authentication.supports_fresh_login or not authentication.has_password_set(user.username)): return func(*args, **kwargs) raise FreshLoginRequired()
def wrapped(*args, **kwargs): user = get_authenticated_user() if not user: raise Unauthorized() if get_validated_oauth_token(): return func(*args, **kwargs) logger.debug("Checking fresh login for user %s", user.username) last_login = session.get("login_time", datetime.datetime.min) valid_span = datetime.datetime.now() - datetime.timedelta(minutes=10) if (not user.password_hash or last_login >= valid_span or not authentication.supports_fresh_login): return func(*args, **kwargs) raise FreshLoginRequired()