Jump to content

External Database Login: additional clause doesn't work


Genadii Skaraev

Recommended Posts

Posted

In external database I have users who I do not want to have access to forum. There is a column named 'status', and it has values from 1 to 9 for active users and 0 or -1 for not activated and banned users.

When I write "status > 0" in field Additional clause:

1965741988_2020-01-1817_18_18.thumb.png.20819139b6300dba5f6d07f7cb899c23.png

happens nothing.... Banned and not active users from external database can still authorise on forum.

Tried different spellings, for example:

`status` > 0 

status = 1 

status = 9999
Nothing can stop banned users from logging in. Even creating new field `active` in external database, filled with 0 (and writing "active=1" in  additional clause, like in field description) doesn't help.

Maybe someone had similar problems? How to handle it?

Posted

It's a bug. Submit a ticket.

17 hours ago, Genadii Skaraev said:

How to handle it?

system/Login/Handler/ExternalDatabase/ExternalDatabase.php

Replace _getRowFromExternalDb method with

	public function _getRowFromExternalDb( $usernameOrEmail )
	{
		/* Build where clause */
		$where = array();
		
		switch ( $this->authType() )
		{
			case \IPS\Login::AUTH_TYPE_USERNAME:
				$where[] = array( "{$this->settings['db_col_user']}=?", $usernameOrEmail );
				break;
			
			case \IPS\Login::AUTH_TYPE_EMAIL:
				$where[] = array( "{$this->settings['db_col_email']}=?", $usernameOrEmail );
				break;
			
			case \IPS\Login::AUTH_TYPE_USERNAME + \IPS\Login::AUTH_TYPE_EMAIL:
				$where[] = array( "({$this->settings['db_col_user']}=? OR {$this->settings['db_col_email']}=?)", $usernameOrEmail, $usernameOrEmail );
				break;
				
		}
		if ( $this->settings['db_extra'] )
		{
			$where[] = array( $this->settings['db_extra'] );
		}
		
		/* Fetch */
		return $this->_externalDb()->select( '*', $this->settings['db_table'], $where )->first();
	}

 

Archived

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

  • Recently Browsing   0 members

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