Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
+33
-10
@@ -112,8 +112,8 @@ class _Device extends \IPS\Patterns\ActiveRecord
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
/* Validate login key is valid */
|
||||
if ( !\IPS\Login::compareHashes( (string) $device->login_key, (string) $loginKey ) )
|
||||
/* Validate login key is valid - if there is no login_key set for the device, it is because the device has been deauthorized */
|
||||
if ( !$device->login_key OR !\IPS\Login::compareHashes( (string) $device->login_key, (string) $loginKey ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
@@ -154,12 +154,12 @@ class _Device extends \IPS\Patterns\ActiveRecord
|
||||
/**
|
||||
* 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 string $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 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)
|
||||
* @return void
|
||||
*/
|
||||
public function updateAfterAuthentication( $rememberMe, $loginHandler=NULL, $refreshLoginKey=TRUE )
|
||||
public function updateAfterAuthentication( $rememberMe, \IPS\Login\Handler $loginHandler=NULL, $refreshLoginKey=TRUE )
|
||||
{
|
||||
$this->user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : NULL;
|
||||
if ( $refreshLoginKey )
|
||||
@@ -169,7 +169,7 @@ class _Device extends \IPS\Patterns\ActiveRecord
|
||||
$this->last_seen = time();
|
||||
if ( $loginHandler !== NULL )
|
||||
{
|
||||
$this->login_handler = $loginHandler;
|
||||
$this->login_handler = $loginHandler->id;
|
||||
}
|
||||
$this->save();
|
||||
|
||||
@@ -218,6 +218,27 @@ class _Device extends \IPS\Patterns\ActiveRecord
|
||||
return \IPS\Http\UserAgent::parse( $this->user_agent );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get login method
|
||||
*
|
||||
* @return \IPS\Login\Handler|NULL
|
||||
*/
|
||||
public function loginMethod()
|
||||
{
|
||||
if ( is_numeric( $this->login_handler ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\Login\Handler::load( $this->login_handler );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send email to user notifying them about the new device
|
||||
*
|
||||
@@ -225,10 +246,10 @@ class _Device extends \IPS\Patterns\ActiveRecord
|
||||
*/
|
||||
protected function sendNewDeviceEmail()
|
||||
{
|
||||
$member = \IPS\Member::load( $this->member_id );
|
||||
|
||||
if ( \IPS\Settings::i()->new_device_email )
|
||||
{
|
||||
$member = \IPS\Member::load( $this->member_id );
|
||||
|
||||
{
|
||||
try
|
||||
{
|
||||
$location = \IPS\GeoLocation::getByIp( \IPS\Request::i()->ipAddress() );
|
||||
@@ -240,6 +261,8 @@ class _Device extends \IPS\Patterns\ActiveRecord
|
||||
|
||||
\IPS\Email::buildFromTemplate( 'core', 'new_device', array( $member, $this, $location ) )->send( $member );
|
||||
}
|
||||
|
||||
$member->logHistory( 'core', 'login', array( 'type' => 'new_device', 'device' => $this->device_key ), FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user