servermgrv2 init...
This commit is contained in:
parent
e494edd250
commit
514cba6a9d
@ -144,7 +144,7 @@ define('LOGINS', [
|
||||
define('AUTHS', [
|
||||
'DEBUG' => getenv('auth.debug') == 'true' ? true : false,
|
||||
'ADAPTERS' => getenv('auth.adapters') ? implode(",", getenv('auth.adapters')) : ['Local', 'Google'],
|
||||
'GOOGLE' => [
|
||||
'Google' => [
|
||||
'ICON' => '<img src="/images/auth/google_login_button.png"/>',
|
||||
'CLIENT_ID' => getenv("auth.google.client.id"),
|
||||
'CLIENT_KEY' => getenv("auth.google.client.key"),
|
||||
|
||||
@ -26,17 +26,18 @@ class AuthController extends BaseController
|
||||
|
||||
private function initAdapters()
|
||||
{
|
||||
foreach (AUTHS['ADAPTERS'] as $adapter) {
|
||||
$this->getAdapter($adapter);
|
||||
foreach (AUTHS['ADAPTERS'] as $site) {
|
||||
$this->getAdapter($site);
|
||||
}
|
||||
}
|
||||
private function getAdapter(string $adapter): Adapter
|
||||
private function getAdapter(string $site): Adapter
|
||||
{
|
||||
if (!array_key_exists($adapter, $this->_adapters)) {
|
||||
$adapterClass = sprintf("\App\Libraries\Adapter\Auth\%sAdapter", $adapter);
|
||||
$this->_adapters[$adapter] = new $adapterClass($adapter, AUTHS['DEBUG']);
|
||||
$site = ucfirst($site);
|
||||
if (!array_key_exists($site, $this->_adapters)) {
|
||||
$adapterClass = sprintf("\App\Libraries\Adapter\Auth\%sAdapter", $site);
|
||||
$this->_adapters[$site] = new $adapterClass($site, AUTHS['DEBUG']);
|
||||
}
|
||||
return $this->_adapters[$adapter];
|
||||
return $this->_adapters[$site];
|
||||
}
|
||||
|
||||
public function login()
|
||||
|
||||
@ -23,7 +23,7 @@ abstract class Adapter
|
||||
if (is_null($this->_site)) {
|
||||
throw new \Exception("Auth Adpater Site명이 정의 되지 않았습니다.");
|
||||
}
|
||||
return strtoupper($this->_site);
|
||||
return ucfirst($this->_site);
|
||||
}
|
||||
abstract public function getAuthButton();
|
||||
abstract public function signin(array $formDatas): UserEntity;
|
||||
|
||||
@ -103,7 +103,7 @@ class GoogleAdapter extends Adapter
|
||||
array("site" => $this->getSiteName(), "uid" => $result['id'])
|
||||
)->first();
|
||||
if (is_null($snsEntity)) {
|
||||
$snsEntity = $this->getUserSNSModel()->create($result);
|
||||
$snsEntity = $this->getUserSNSModel()->create($this->getSiteName(), $result);
|
||||
}
|
||||
if (is_null($snsEntity->getUserUID())) {
|
||||
throw new \Exception($this->getSiteName() . "의{$result['email']}:{$result['name']}님은 아직 사용자 지정이 되지 않았습니다.");
|
||||
|
||||
@ -31,10 +31,10 @@ class UserSNSModel extends CommonModel
|
||||
{
|
||||
return $this->getEntityByField($this->primaryKey, $uid);
|
||||
}
|
||||
public function create(array $datas): UserSNSEntity
|
||||
public function create(string $site, array $datas): UserSNSEntity
|
||||
{
|
||||
$entity = new UserSNSEntity();
|
||||
$entity->site = $this->getSiteName();
|
||||
$entity->site = $site;
|
||||
$entity->id = $datas['id'];
|
||||
$entity->name = $datas['name'];
|
||||
$entity->email = $datas['email'];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user