<commit_before>import six

from datetime import datetime
from itsdangerous import BadSignature, SignatureExpired
from flask_login import current_user
from flask import current_app, flash, redirect, url_for

from dmutils.email import decode_token
from dmutils.formats import DATETIME_FORMAT

ONE_DAY_IN_SECONDS = 86400
SEVEN_DAYS_IN_SECONDS = 604800


def redirect_logged_in_user(next_url=None):
    if current_user.is_authenticated():
        if current_user.role == 'supplier':
            if next_url and next_url.startswith('/suppliers'):
                return redirect(next_url)
            else:
                return redirect('/suppliers')
        if current_user.role.startswith('admin'):
            if next_url and next_url.startswith('/admin'):
                return redirect(next_url)
            else:
                return redirect('/admin')
        if next_url:
            return redirect(next_url)<commit_msg>Only redirect to `next` pages within the Digital Marketplace<commit_after>import six

from datetime import datetime
from itsdangerous import BadSignature, SignatureExpired
from flask_login import current_user
from flask import current_app, flash, redirect, url_for

from dmutils.email import decode_token
from dmutils.formats import DATETIME_FORMAT

ONE_DAY_IN_SECONDS = 86400
SEVEN_DAYS_IN_SECONDS = 604800


def redirect_logged_in_user(next_url=None):
    if current_user.is_authenticated():
        if current_user.role == 'supplier':
            if next_url and next_url.startswith('/suppliers'):
                return redirect(next_url)
            else:
                return redirect('/suppliers')
        if current_user.role.startswith('admin'):
            if next_url and next_url.startswith('/admin'):
                return redirect(next_url)
            else:
                return redirect('/admin')
        if next_url and next_url.startswith('/'):
            return redirect(next_url)
{'fraction_non_alphanumeric': 0.07135470527404343, 'fraction_numerical': 0.011375387797311272, 'mean_word_length': 2.9896907216494846, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2984711', 'n_tokens_mistral': 577, 'n_tokens_neox': 535, 'n_words': 139}