Archived
1
0
Fork 0

app/models/Data/User.php: adding createFromOAuthData()

This commit is contained in:
Henrik Hautakoski 2018-06-07 23:40:58 +02:00
parent d62914c764
commit 643387b3f3

View file

@ -194,6 +194,19 @@ class User extends Model
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
*