src/login_github.php
public static function get_by_info($info, $update_oauth_token=true) {
	$mysql = bootstrap::get_library('mysql');
	
	// find via the oauth token
	$sql   = "SELECT * FROM `login_github` WHERE `oauth_token` = '%s';";
	$login = $mysql::select('row', $sql, $info['oauth_token']);
	if (!empty($login)) {
		return new static($login['id']);
	}
	
	// find via the github username
	$sql   = "SELECT * FROM `login_github` WHERE `github_username` = '%s';";
	$login = $mysql::select('row', $sql, $info['github_username']);
	if (empty($login)) {
		return false;
	}
	
	$object = new static($login['id']);
	
	// keep token up to date
	if ($update_oauth_token && $info['oauth_token'] != $login['oauth_token']) {
		$object->update_oauth_token($info['oauth_token']);
	}
	
	return $object;
}
public static function get_by_info($info, $update_oauth_token=true) {
	$mysql = bootstrap::get_library('mysql');
	
	// find via the oauth token
	$sql   = "SELECT * FROM `login_github` WHERE `oauth_token` = '%s';";
	$login = $mysql::select('row', $sql, $info['oauth_token']);
	if (!empty($login)) {
		return new static($login['id']);
	}
	
	// find via the github username
	$sql   = "SELECT * FROM `login_github` WHERE `github_username` = '%s';";
	$login = $mysql::select('row', $sql, $info['github_username']);
	if (empty($login)) {
		return false;
	}
	
	$object = new static($login['id']);
	
	// keep token up to date
	if ($update_oauth_token && $info['oauth_token'] != $login['oauth_token']) {
		$object->update_oauth_token($info['oauth_token']);
	}
	
	return $object;
}
public static function get_by_info ( $ info , $ update_oauth_token = true ) { $ mysql = bootstrap :: get_library ( 'mysql' ) ; // find via the oauth token $ sql = "SELECT * FROM `login_github` WHERE `oauth_token` = '%s';" ; $ login = $ mysql :: select ( 'row' , $ sql , $ info [ 'oauth_token' ] ) ; if ( ! empty ( $ login ) ) { return new static ( $ login [ 'id' ] ) ; } // find via the github username $ sql = "SELECT * FROM `login_github` WHERE `github_username` = '%s';" ; $ login = $ mysql :: select ( 'row' , $ sql , $ info [ 'github_username' ] ) ; if ( empty ( $ login ) ) { return false ; } $ object = new static ( $ login [ 'id' ] ) ; // keep token up to date if ( $ update_oauth_token && $ info [ 'oauth_token' ] != $ login [ 'oauth_token' ] ) { $ object -> update_oauth_token ( $ info [ 'oauth_token' ] ) ; } return $ object ; }
checks whether the login match one on file
and returns the found login

$info needs to contain both 'oauth_token' and 'github_username'
use ::get_by_oauth_token() if only the 'oauth_token' is known

magic alert: also update the token on file if the token is different but the username is found
to do manually, set $update_oauth_token to false and call $login->update_oauth_token()

@param  array         $info               as returned by ::is_valid()
@param  boolean       $update_oauth_token defaults to true
@return $this|boolean false               when the token is not found
checks whether the login match one on file and returns the found login