Project

General

Profile

Actions

Feature #59532

closed

Session renewal: Add signal/hook when renewing session

Added by Clément MICHELET almost 10 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Could have
Assignee:
-
Category:
-
Target version:
Start date:
2014-06-12
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
easy
Sprint Focus:

Description

In TYPO3\CMS\Core\Authentication\AbstractUserAuthentication::fetchUserSession, there is a part dedicated to update session update time (used for expiration date).

It could be great to have an entry point to add some additional code during the session renewal.

Actions #1

Updated by Clément MICHELET almost 10 years ago

Add skeleton for this hook. I will try to push it on gerrit next week. I'm a bit in a hurry right now.

    /**
     * Read the user session from db.
     *
     * @param boolean $skipSessionUpdate
     * @return array User session data
     * @todo Define visibility
     */
    public function fetchUserSession($skipSessionUpdate = FALSE) {
        $user = FALSE;
        if ($this->writeDevLog) {
            GeneralUtility::devLog('Fetch session ses_id = ' . $this->id, 'TYPO3\\CMS\\Core\\Authentication\\AbstractUserAuthentication');
        }

        // Fetch the user session from the DB
        $statement = $this->fetchUserSessionFromDB();

        if ($statement) {
            $statement->execute();
            $user = $statement->fetch();
            $statement->free();
        }
        if ($user) {
            // A user was found
            if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->auth_timeout_field)) {
                // Get timeout from object
                $timeout = (int)$this->auth_timeout_field;
            } else {
                // Get timeout-time from usertable
                $timeout = (int)$user[$this->auth_timeout_field];
            }
            // If timeout > 0 (TRUE) and current time has not exceeded the latest sessions-time plus the timeout in seconds then accept user
            // Option later on: We could check that last update was at least x seconds ago in order not to update twice in a row if one script redirects to another...
            if ($timeout > 0 && $GLOBALS['EXEC_TIME'] < $user['ses_tstamp'] + $timeout) {
                if (!$skipSessionUpdate) {
                    $this->db->exec_UPDATEquery($this->session_table, 'ses_id=' . $this->db->fullQuoteStr($this->id, $this->session_table)
                        . ' AND ses_name=' . $this->db->fullQuoteStr($this->name, $this->session_table), array('ses_tstamp' => $GLOBALS['EXEC_TIME']));
                    // Make sure that the timestamp is also updated in the array
                    $user['ses_tstamp'] = $GLOBALS['EXEC_TIME'];

                    if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['fetchUserSession_postRenewSession'])) {

                        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['fetchUserSession_postRenewSession'] as $_funcRef) {
                            if ($_funcRef) {
                                GeneralUtility::callUserFunction($_funcRef, $user, $this);
                            }
                        }
                    }
                }
            } else {
                // Delete any user set...
                $this->logoff();
            }
        }
        return $user;
    }
Actions #2

Updated by Mathias Schreiber over 9 years ago

  • Target version changed from 7.0 to 7.1 (Cleanup)
Actions #3

Updated by Benni Mack almost 9 years ago

  • Target version changed from 7.1 (Cleanup) to 7.4 (Backend)
Actions #4

Updated by Susanne Moog almost 9 years ago

  • Target version changed from 7.4 (Backend) to 7.5
Actions #5

Updated by Benni Mack over 8 years ago

  • Target version changed from 7.5 to 8 LTS
Actions #6

Updated by Alexander Opitz over 7 years ago

  • Status changed from New to Needs Feedback

This issue is 2 years old. :-)
You wrote you want contribute code to gerrit, what is the state of this code?

Actions #7

Updated by Alexander Opitz about 7 years ago

  • Status changed from Needs Feedback to Closed

No feedback within the last 90 days => closing this issue.

If you think that this is the wrong decision or experience this issue again, then please write to the mailing list typo3.teams.bugs with issue number and an explanation or open a new ticket and add a relation to this ticket number.

Actions

Also available in: Atom PDF