diff --git a/j_updateServer.php b/j_updateServer.php index fdd60258..7f68763c 100644 --- a/j_updateServer.php +++ b/j_updateServer.php @@ -19,12 +19,6 @@ function getVersion($target=null){ } $session = Session::requireLogin(null)->setReadOnly(); -if($session->userGrade < 5){ - Json::die([ - 'result'=>false, - 'reason'=>'권한이 충분하지 않습니다' - ]); -} $request = $_POST + $_GET; @@ -48,7 +42,24 @@ if(!$v->validate()){ $target = Util::getReq('target'); $server = basename($request['server']); -if($session->userGrade <= 5 || !$target){ + +$allowFullUpdate = in_array('fullUpdate', $session->acl[$server]??[]); +$allowFullUpdate |= $session->userGrade >= 6; + +$allowUpdate = in_array('update', $session->acl[$server]??[]); +$allowUpdate |= $session->userGrade >= 5; +$allowUpdate |= $allowFullUpdate; + + +if(!$allowUpdate){ + Json::die([ + 'result'=>false, + 'reason'=>'권한이 충분하지 않습니다' + ]); +} + + +if(!$allowFullUpdate || !$target){ $target = $storage->$server; if($target){ $target = $target[0]; diff --git a/js/admin_server.js b/js/admin_server.js index 8fec1bf7..037143ad 100644 --- a/js/admin_server.js +++ b/js/admin_server.js @@ -25,13 +25,25 @@ function serverUpdate(caller){ if(typeof isRoot !== 'boolean'){ isRoot = (isRoot != 'false'); }; + + var allowFullUpdate = (server in window.aclList && window.aclList[server].indexOf('fullUpdate')>=0); + allowFullUpdate |= window.adminGrade > 5; + + var allowUpdate = (server in window.aclList && window.aclList[server].indexOf('update')>=0); + allowUpdate |= window.adminGrade >= 5; + allowUpdate |= allowFullUpdate; + if(!allowUpdate){ + alert('권한이 없습니다!'); + return; + } + if(isRoot){ if(!confirm('서버 라이브러리, 루트 서버에 대해 git pull을 실행합니다.')){ return; } } - else if(window.adminGrade < 6){ + else if(!allowFullUpdate){ if (!confirm('다음 git tree-ish 주소로 업데이트를 시도합니다 : ' + target)) { return; } @@ -94,7 +106,7 @@ function drawServerAdminList(serverList){ var aclByServer = serverList.acl[server.name]; $.each(aclByServer, function(idx, action){ console.log(action); - if(action == 'update'){ + if(action == 'update' || action == 'fullUpdate'){ if(!server.installed){ return true; } @@ -115,8 +127,8 @@ function drawServerAdminList(serverList){ }); }); window.adminGrade = serverList.grade; - if(serverList.grade == 5){ - + window.aclList = serverList.acl; + if(serverList.grade <= 5){ $table.find('.only_admin').prop('disabled', true); } }