servermgrv2 init...
This commit is contained in:
parent
7993555469
commit
ed26d19c95
@ -138,6 +138,10 @@ define('LAYOUTS', [
|
|||||||
define('LOGINS', [
|
define('LOGINS', [
|
||||||
'ISLOGIN' => getenv('login.islogin.name') ? getenv('login.islogin.name') : "isLoggedIn",
|
'ISLOGIN' => getenv('login.islogin.name') ? getenv('login.islogin.name') : "isLoggedIn",
|
||||||
'RETURN_URL' => getenv('login.return_url.name') ? getenv('login.return_url.name') : "return_url",
|
'RETURN_URL' => getenv('login.return_url.name') ? getenv('login.return_url.name') : "return_url",
|
||||||
|
'USER' => [
|
||||||
|
'NAME' => getenv('login.user.name') ? getenv('login.user.name') : "user",
|
||||||
|
'FIELDS' => ['PK' => 'uid', 'TITLE' => 'name', 'ROLE' => 'role'],
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
//인증 관련
|
//인증 관련
|
||||||
|
|||||||
@ -32,13 +32,13 @@ class AuthFilter implements FilterInterface
|
|||||||
return redirect()->to('/login')->with('error', $error);
|
return redirect()->to('/login')->with('error', $error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array(session()->get('role'), $arguments)) {
|
if (!in_array(session()->get(LOGINS['USER']['NAME'])['role'], $arguments)) {
|
||||||
return redirect()->to('/login')->with(
|
return redirect()->to('/login')->with(
|
||||||
'error',
|
'error',
|
||||||
sprintf(
|
sprintf(
|
||||||
"%s 회원님은 %s로서 접속에 필요한 권한[%s]이 없습니다. ",
|
"%s 회원님은 %s로서 접속에 필요한 권한[%s]이 없습니다. ",
|
||||||
session()->get('name'),
|
session()->get(LOGINS['USER']['NAME'])[LOGINS['USER']['FIELDS']['TITLE']],
|
||||||
session()->get('role'),
|
session()->get(LOGINS['USER']['NAME'])[LOGINS['USER']['FIELDS']['ROLE']],
|
||||||
implode(",", $arguments)
|
implode(",", $arguments)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@ -44,22 +44,17 @@ abstract class Adapter
|
|||||||
return $this->_userSNSModel;
|
return $this->_userSNSModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function setSessionInfo(UserEntity $entity, array $authrizedDatas = array()): void
|
protected function setUserSession(UserEntity $entity): void
|
||||||
{
|
{
|
||||||
$authrizedDatas[LOGINS['ISLOGIN']] = true;
|
session()->set(LOGINS['ISLOGIN'], true);
|
||||||
$authrizedDatas['uid'] = $entity->getPrimaryKey();
|
$datas = array();
|
||||||
$authrizedDatas['name'] = $entity->getTitle();
|
foreach (LOGINS['USER']['FIELDS'] as $field) {
|
||||||
$authrizedDatas['email'] = $entity->email;
|
$datas[$field] = $entity->$field;
|
||||||
$authrizedDatas['role'] = $entity->role;
|
}
|
||||||
session()->set($authrizedDatas);
|
session()->set(array(LOGINS['USER']['NAME'] => $datas));
|
||||||
}
|
}
|
||||||
public function getSessionInfo(array $authrizedDatas = array()): array
|
protected function getUserSession(): array
|
||||||
{
|
{
|
||||||
$authrizedDatas[LOGINS['ISLOGIN']] = session()->get(LOGINS['ISLOGIN']);
|
return session()->get(LOGINS['USER']['NAME']);
|
||||||
$authrizedDatas['uid'] = session()->get('uid');
|
|
||||||
$authrizedDatas['name'] = session()->get('name');
|
|
||||||
$authrizedDatas['email'] = session()->get('email');
|
|
||||||
$authrizedDatas['role'] = session()->get('role');
|
|
||||||
return $authrizedDatas;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -114,7 +114,7 @@ class GoogleAdapter extends Adapter
|
|||||||
//인증된 사용자 정보를 가져온후 세션 정보 처리
|
//인증된 사용자 정보를 가져온후 세션 정보 처리
|
||||||
$entity = $this->getUserModel()->getEntity($snsEntity->user_id);
|
$entity = $this->getUserModel()->getEntity($snsEntity->user_id);
|
||||||
//Session에 인증정보 설정
|
//Session에 인증정보 설정
|
||||||
$this->setSessionInfo($entity);
|
$this->setUserSession($entity);
|
||||||
return $entity;
|
return $entity;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw new \Exception("관리자에게 문의하시기 바랍니다.<BR>{$e->getMessage()}");
|
throw new \Exception("관리자에게 문의하시기 바랍니다.<BR>{$e->getMessage()}");
|
||||||
|
|||||||
@ -29,7 +29,7 @@ class LocalAdapter extends Adapter
|
|||||||
throw new \Exception("암호가 맞지않습니다.");
|
throw new \Exception("암호가 맞지않습니다.");
|
||||||
}
|
}
|
||||||
//Session에 인증정보 설정
|
//Session에 인증정보 설정
|
||||||
$this->setSessionInfo($entity);
|
$this->setUserSession($entity);
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,7 +31,7 @@ class LoggerModel extends CommonModel
|
|||||||
public function create(array $datas): LoggerEntity
|
public function create(array $datas): LoggerEntity
|
||||||
{
|
{
|
||||||
$entity = new LoggerEntity($datas);
|
$entity = new LoggerEntity($datas);
|
||||||
$entity->user_uid = session()->get('uid');
|
$entity->user_uid = session()->get(LOGINS['USER']['NAME'])[LOGINS['USER']['FIELDS']['PK']];
|
||||||
return parent::create_process($entity);
|
return parent::create_process($entity);
|
||||||
}
|
}
|
||||||
public function modify(LoggerEntity $entity, array $datas): LoggerEntity
|
public function modify(LoggerEntity $entity, array $datas): LoggerEntity
|
||||||
|
|||||||
@ -7,10 +7,12 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"><i class="fa fa-id-card"></i></i><?=$session->get('name')?></a>
|
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"><i class="fa fa-id-card"></i></i><?= session()->get(LOGINS['USER']['NAME'])[LOGINS['USER']['FIELDS']['TITLE']] ?></a>
|
||||||
<ul class="dropdown-menu dropdown-menu-end">
|
<ul class="dropdown-menu dropdown-menu-end">
|
||||||
<li><a href="/admin/user/update/<?=$session->get('uid')?>"><i class="fa fa-cog"></i>내정보수정</a></li>
|
<li><a href="/admin/user/update/<?= session()->get(LOGINS['USER']['NAME'])[LOGINS['USER']['FIELDS']['PK']] ?>"><i class="fa fa-cog"></i>내정보수정</a></li>
|
||||||
<li><hr class="dropdown-divider"></li>
|
<li>
|
||||||
|
<hr class="dropdown-divider">
|
||||||
|
</li>
|
||||||
<li><a href="/logout"><i class="fa fa-sign-out" aria-hidden="true"></i>Logout</a></li>
|
<li><a href="/logout"><i class="fa fa-sign-out" aria-hidden="true"></i>Logout</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user