app/models/Data/User.php: adding findFirstByOAuthID()
This commit is contained in:
parent
481c6c206e
commit
d62914c764
1 changed files with 13 additions and 2 deletions
|
|
@ -2,8 +2,9 @@
|
||||||
|
|
||||||
namespace App\Model\Data;
|
namespace App\Model\Data;
|
||||||
|
|
||||||
use Phalcon\Mvc\Model;
|
use Phalcon\Mvc\Model,
|
||||||
use InvalidArgumentException;
|
InvalidArgumentException,
|
||||||
|
Httpcb\OAuth\UserData\UserDataInterface;
|
||||||
|
|
||||||
class User extends Model
|
class User extends Model
|
||||||
{
|
{
|
||||||
|
|
@ -207,6 +208,16 @@ class User extends Model
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public function findFirstByOAuthID(UserDataInterface $oauth)
|
||||||
|
{
|
||||||
|
$column = strtolower($oauth->getProvider());
|
||||||
|
|
||||||
|
return self::findFirst([
|
||||||
|
"{$column}_id = :id:",
|
||||||
|
"bind" => [ 'id' => $oauth->getId() ]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function beforeSave()
|
public function beforeSave()
|
||||||
{
|
{
|
||||||
// Fire event on password create/changed.
|
// Fire event on password create/changed.
|
||||||
|
|
|
||||||
Reference in a new issue