<commit_before><?php

namespace Backend\Core\Engine;

use Backend\Core\Engine\Model as BackendModel;
use Backend\Modules\Users\Engine\Model as BackendUsersModel;
use Common\Events\ForkEvents;
use Common\Events\ForkSessionIdChangedEvent;
use RuntimeException;

/**
 * The class below will handle all authentication stuff. It will handle module-access, action-access, ...
 */
class Authentication
{
    /**
     * All allowed modules
     *
     * @var array
     */
    private static $allowedActions = [];

    /**
     * All allowed modules
     *
     * @var array
     */
    private static $allowedModules = [];

    /**
     * A user object for the current authenticated user
     *
     * @var User
     */
    private static $user;

    /**
     * This is used to prevent logging out multiple times (less queries)
     *
     * @var bool
     */
    private static $alreadyLoggedOut = false;

    /**
     * Check the strength of the password
     *
     * @param string $password The password.
     *
     * @return string
     */
    public static function checkPassword(string $password): string
    {
        return PasswordStrengthChecker::checkPassword($password);
    }

    /**
     * Cleanup sessions for the current user and sessions that are invalid
     */
    public static function cleanupOldSessions(): void
    {
        // remove all sessions that are invalid (older then 30 min)
        BackendModel::get('database')->delete('users_sessions', 'date <= DATE_SUB(NOW(), INTERVAL 30 MINUTE)');<commit_msg>Make the old session clean-up method timezone aware<commit_after><?php

namespace Backend\Core\Engine;

use Backend\Core\Engine\Model as BackendModel;
use Backend\Modules\Users\Engine\Model as BackendUsersModel;
use Common\Events\ForkEvents;
use Common\Events\ForkSessionIdChangedEvent;
use RuntimeException;

/**
 * The class below will handle all authentication stuff. It will handle module-access, action-access, ...
 */
class Authentication
{
    /**
     * All allowed modules
     *
     * @var array
     */
    private static $allowedActions = [];

    /**
     * All allowed modules
     *
     * @var array
     */
    private static $allowedModules = [];

    /**
     * A user object for the current authenticated user
     *
     * @var User
     */
    private static $user;

    /**
     * This is used to prevent logging out multiple times (less queries)
     *
     * @var bool
     */
    private static $alreadyLoggedOut = false;

    /**
     * Check the strength of the password
     *
     * @param string $password The password.
     *
     * @return string
     */
    public static function checkPassword(string $password): string
    {
        return PasswordStrengthChecker::checkPassword($password);
    }

    /**
     * Cleanup sessions for the current user and sessions that are invalid
     */
    public static function cleanupOldSessions(): void
    {
        $deleteIfOlderThan = (new DateTime('- 30 minutes', new DateTimeZone('UTC')))->format('Y-m-d H:i:s');
        BackendModel::get('database')->delete('users_sessions', 'date <= ?', [$deleteIfOlderThan]);
{'fraction_non_alphanumeric': 0.10637616148670298, 'fraction_numerical': 0.0019224607497596924, 'mean_word_length': 2.6344586728754367, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, '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': '7238107', 'n_tokens_mistral': 868, 'n_tokens_neox': 847, 'n_words': 263}