Ignore:
Timestamp:
Feb 15, 2006 3:34:50 AM (18 years ago)
Author:
scdev
Message:

Added Auth_File::requireLogin()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Auth_File.inc.php

    r65 r66  
    2121        'login_timeout' => 21600, // 6 hours.
    2222        'idle_timeout' => 3600, // 1 hour.
     23        'login_url' => '/login.php',
    2324    );
    2425    var $_users = array();
     
    173174                App::raiseMsg(_("Your session has closed. You need to log-in again."), MSG_NOTICE, __FILE__, __LINE__);
    174175                $this->clearAuth();
     176                return false;
    175177            }
    176178        }
    177179        return false;
     180    }
     181
     182    /**
     183     * Redirect user to login page if they are not logged in.
     184     *
     185     * @param string $message The text description of a message to raise.
     186     * @param int    $type    The type of message: MSG_NOTICE,
     187     *                        MSG_SUCCESS, MSG_WARNING, or MSG_ERR.
     188     * @param string $file    __FILE__.
     189     * @param string $line    __LINE__.
     190     * @access public
     191     */
     192    function requireLogin($message='', $type=MSG_NOTICE, $file=null, $line=null)
     193    {
     194        if (!$this->isLoggedIn()) {
     195            // Display message for requiring login.
     196            App::raiseMsg($message, $type, $file, $line);
     197
     198            // Login scripts must have the same 'login' tag for boomerangURL verification/manipulation.
     199            App::setBoomerangURL(absoluteMe(), 'login');
     200            App::dieURL($this->_params['login_url']);
     201        }
    178202    }
    179203
Note: See TracChangeset for help on using the changeset viewer.