servermgrv2 init...

This commit is contained in:
최준흠 2023-07-19 20:59:23 +09:00
parent 7993555469
commit ed26d19c95
7 changed files with 24 additions and 23 deletions

View File

@ -138,6 +138,10 @@ define('LAYOUTS', [
define('LOGINS', [
'ISLOGIN' => getenv('login.islogin.name') ? getenv('login.islogin.name') : "isLoggedIn",
'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'],
]
]);
//인증 관련

View File

@ -32,13 +32,13 @@ class AuthFilter implements FilterInterface
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(
'error',
sprintf(
"%s 회원님은 %s로서 접속에 필요한 권한[%s]이 없습니다. ",
session()->get('name'),
session()->get('role'),
session()->get(LOGINS['USER']['NAME'])[LOGINS['USER']['FIELDS']['TITLE']],
session()->get(LOGINS['USER']['NAME'])[LOGINS['USER']['FIELDS']['ROLE']],
implode(",", $arguments)
)
);

View File

@ -44,22 +44,17 @@ abstract class Adapter
return $this->_userSNSModel;
}
protected function setSessionInfo(UserEntity $entity, array $authrizedDatas = array()): void
protected function setUserSession(UserEntity $entity): void
{
$authrizedDatas[LOGINS['ISLOGIN']] = true;
$authrizedDatas['uid'] = $entity->getPrimaryKey();
$authrizedDatas['name'] = $entity->getTitle();
$authrizedDatas['email'] = $entity->email;
$authrizedDatas['role'] = $entity->role;
session()->set($authrizedDatas);
session()->set(LOGINS['ISLOGIN'], true);
$datas = array();
foreach (LOGINS['USER']['FIELDS'] as $field) {
$datas[$field] = $entity->$field;
}
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']);
$authrizedDatas['uid'] = session()->get('uid');
$authrizedDatas['name'] = session()->get('name');
$authrizedDatas['email'] = session()->get('email');
$authrizedDatas['role'] = session()->get('role');
return $authrizedDatas;
return session()->get(LOGINS['USER']['NAME']);
}
}

View File

@ -114,7 +114,7 @@ class GoogleAdapter extends Adapter
//인증된 사용자 정보를 가져온후 세션 정보 처리
$entity = $this->getUserModel()->getEntity($snsEntity->user_id);
//Session에 인증정보 설정
$this->setSessionInfo($entity);
$this->setUserSession($entity);
return $entity;
} catch (\Exception $e) {
throw new \Exception("관리자에게 문의하시기 바랍니다.<BR>{$e->getMessage()}");

View File

@ -29,7 +29,7 @@ class LocalAdapter extends Adapter
throw new \Exception("암호가 맞지않습니다.");
}
//Session에 인증정보 설정
$this->setSessionInfo($entity);
$this->setUserSession($entity);
return $entity;
}
}

View File

@ -31,7 +31,7 @@ class LoggerModel extends CommonModel
public function create(array $datas): LoggerEntity
{
$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);
}
public function modify(LoggerEntity $entity, array $datas): LoggerEntity

View File

@ -7,10 +7,12 @@
</ul>
</li>
<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">
<li><a href="/admin/user/update/<?=$session->get('uid')?>"><i class="fa fa-cog"></i>내정보수정</a></li>
<li><hr class="dropdown-divider"></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><a href="/logout"><i class="fa fa-sign-out" aria-hidden="true"></i>Logout</a></li>
</ul>
</li>