app/models/Data/User.php: adding createFromOAuthData()
This commit is contained in:
parent
d62914c764
commit
643387b3f3
1 changed files with 13 additions and 0 deletions
|
|
@ -194,6 +194,19 @@ class User extends Model
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public function createFromOAuthData(UserDataInterface $data)
|
||||||
|
{
|
||||||
|
$oauth_id = 'set' . $data->getProvider() . 'Id';
|
||||||
|
|
||||||
|
$user = new self();
|
||||||
|
$user->setUsername($data->getUsername())
|
||||||
|
->setName($data->getName())
|
||||||
|
->setEmail($data->getEmail())
|
||||||
|
->{$oauth_id}($data->getId());
|
||||||
|
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the first user by Username or Email
|
* Find the first user by Username or Email
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Reference in a new issue