Version 4.3.6
This commit is contained in:
1 parent
fe1acf984a
commit
1a0c7fd3c2
609 files changed
+14707
-5726
No files matched your search
+20
-16
@@ -150,16 +150,17 @@ class _Device extends \IPS\Patterns\ActiveRecord
|
||||
$object->device_key = $deviceKey;
|
||||
return $object;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update after logging in / automatic authentication with current request's user agent / IP address, etc.
|
||||
*
|
||||
* @param bool|null $rememberMe Remember me? NULL can be provided if the login is being processed from somewhere that doesn't ask
|
||||
* @param \IPS\Login\Handler $loginHandler The login handler which processed the login, or NULL if updating an existing login. Can also be empty string for logins that weren't processed by any handler (such as after registration or using the lost password feature)
|
||||
* @param bool $refreshLoginKey If login key should be refreshed (FALSE for automatic logins which will need the same login key subsequently)
|
||||
* @param book $setCookies Should the cookies be set ( FALSE for ACP login )
|
||||
* @return void
|
||||
*/
|
||||
public function updateAfterAuthentication( $rememberMe, \IPS\Login\Handler $loginHandler=NULL, $refreshLoginKey=TRUE )
|
||||
public function updateAfterAuthentication( $rememberMe, \IPS\Login\Handler $loginHandler=NULL, $refreshLoginKey=TRUE, $setCookies = TRUE )
|
||||
{
|
||||
$this->user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : NULL;
|
||||
if ( $refreshLoginKey )
|
||||
@@ -174,21 +175,24 @@ class _Device extends \IPS\Patterns\ActiveRecord
|
||||
$this->save();
|
||||
|
||||
$this->logIpAddress( \IPS\Request::i()->ipAddress() );
|
||||
|
||||
$cookieExpiration = ( new \IPS\DateTime )->add( new \DateInterval( static::LOGIN_KEY_VALIDITY ) );
|
||||
if ( $rememberMe === NULL )
|
||||
|
||||
if ( $setCookies )
|
||||
{
|
||||
\IPS\Request::i()->setCookie( 'member_id', $this->member_id, $cookieExpiration );
|
||||
}
|
||||
elseif ( $rememberMe === TRUE )
|
||||
{
|
||||
\IPS\Request::i()->setCookie( 'member_id', $this->member_id, $cookieExpiration );
|
||||
\IPS\Request::i()->setCookie( 'login_key', $this->login_key, $cookieExpiration );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Request::i()->setCookie( 'member_id', $this->member_id, NULL ); // Just tells the guest caching mechanism that we are logged in, so it can expire on the session end
|
||||
\IPS\Request::i()->setCookie( 'login_key', NULL ); // Clear it in case they previously had chosen "Remember Me"
|
||||
$cookieExpiration = ( new \IPS\DateTime )->add( new \DateInterval( static::LOGIN_KEY_VALIDITY ) );
|
||||
if ( $rememberMe === NULL )
|
||||
{
|
||||
\IPS\Request::i()->setCookie( 'member_id', $this->member_id, $cookieExpiration );
|
||||
}
|
||||
elseif ( $rememberMe === TRUE )
|
||||
{
|
||||
\IPS\Request::i()->setCookie( 'member_id', $this->member_id, $cookieExpiration );
|
||||
\IPS\Request::i()->setCookie( 'login_key', $this->login_key, $cookieExpiration );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Request::i()->setCookie( 'member_id', $this->member_id, NULL ); // Just tells the guest caching mechanism that we are logged in, so it can expire on the session end
|
||||
\IPS\Request::i()->setCookie( 'login_key', NULL ); // Clear it in case they previously had chosen "Remember Me"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user