Jump to content

Get Member IPS\Member::load


Michael Thomas

Recommended Posts

Posted

Hello

        I've wrote a new Login Handler, and everything is working beside the part of checking if member exist or not anytime i do 

$charID = $userData['CharacterID'];
$member = \IPS\Member::load( "{$charID}", "eveonline_id" );

which is being returned from a SSO call i get the following error that column is in my database and be populated as well.

I'm not sure what is going on here. i running latest version of IPS 4.2.2

InvalidArgumentException:  (0)
#0 C:\wamp64\www\ips\system\Member\Member.php(190): IPS\Patterns\_ActiveRecord::load('91537743', 'eveonline_id', NULL)
#1 C:\wamp64\www\ips\system\Login\EVEOnline.php(112): IPS\_Member::load('91537743', 'eveonline_id')
#2 C:\wamp64\www\ips\system\Login\Login.php(406): IPS\Login\_EVEOnline->authenticate(Object(IPS\Http\Url\Friendly))
#3 C:\wamp64\www\ips\applications\core\modules\front\system\login.php(51): IPS\_Login->authenticate()
#4 C:\wamp64\www\ips\system\Dispatcher\Controller.php(96): IPS\core\modules\front\system\_login->manage()
#5 C:\wamp64\www\ips\system\Dispatcher\Dispatcher.php(146): IPS\Dispatcher\_Controller->execute()
#6 C:\wamp64\www\ips\index.php(12): IPS\_Dispatcher->run()
#7 {main}

 

#0 C:\wamp64\www\ips\init.php(523): IPS\_Log::log('InvalidArgument...', 'uncaught_except...')
#1 [internal function]: IPS\IPS::exceptionHandler(Object(InvalidArgumentException))
#2 {main}

Posted

eveonline_id isn't going to be an allowable lookup column..

 

protected static $databaseIdFields = array( 'name', 'email', 'fb_uid', 'live_id', 'google_id', 'linkedin_id', 'ipsconnect_id', 'twitter_id' );

 

Posted

FWIW, when we write integrations of this nature we tend to write a hook on \IPS\Member in order to overload the allowed columns.

	/**
	 * Add our own column to default fields
	 */
	public function __construct()
	{
		static::$databaseIdFields = array_merge( static::$databaseIdFields, array( 'sso_id' ) );
	
		parent::__construct();
	}

 

Posted
On 8/21/2017 at 11:44 AM, bfarber said:

FWIW, when we write integrations of this nature we tend to write a hook on \IPS\Member in order to overload the allowed columns.


	/**
	 * Add our own column to default fields
	 */
	public function __construct()
	{
		static::$databaseIdFields = array_merge( static::$databaseIdFields, array( 'sso_id' ) );
	
		parent::__construct();
	}

 

Does that get detected in static methods, though? I'm not sure the constructor would even be called until later in the process (when the row is already retrieved and the object is initiated). Or am I wrong? 

Posted
4 hours ago, HeadStand said:

Does that get detected in static methods, though? I'm not sure the constructor would even be called until later in the process (when the row is already retrieved and the object is initiated). Or am I wrong?

In this case, it will be included because the Session class will always instantiate a new \IPS\Member object regardless of whether or not the user is logged in (either via Remember Me, actually having an active session, or they are simply a guest with no account - each case creates an \IPS\Member instance). As such, the hook code runs, and because the static keyword is used, every object moving forward will also inherit the updated property. In the case of actual SSO, if there is no active session in the database, then \IPS\Session\Front will end up with a guest member (which is simply "new \IPS\Member" stored in the $member property for the Session class), and then code in the hook for the SSO plugin will pick up the slack, and update the object accordingly, changing it to an actual Member object, and update the actual session data to tell the suite that the session does indeed belong to an actual member (either existing, or dynamically created at run time).

In other cases, it would be best to overload the "load" method instead. That being said, however, if you are loading a lot of records based on a single field at one time, it's better to use a single query using IN() in your where clause, and ActiveRecordIterator to create your objects, to avoid running a lot of queries loading individual rows. In that instance, it's not necessary to add the column to the $databaseIdFields property.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...