mirror of
https://github.com/myvesta/vesta
synced 2025-07-11 15:46:43 -07:00
Log in as user / Logout to real user.
This commit is contained in:
parent
29772cbfdd
commit
b13c07cca2
6 changed files with 111 additions and 32 deletions
|
@ -11,9 +11,9 @@ $('document').ready(function() {
|
||||||
App.Utils.detectBrowser();
|
App.Utils.detectBrowser();
|
||||||
App.Ref.init();
|
App.Ref.init();
|
||||||
|
|
||||||
//App.Env.world = 'USER';
|
App.Env.world = 'USER';
|
||||||
// Disabled cookie tab restoring. Enable if needed
|
// Disabled cookie tab restoring. Enable if needed
|
||||||
if ('undefined' != typeof App.Tmp.loadTAB) {
|
/*if ('undefined' != typeof App.Tmp.loadTAB) {
|
||||||
App.Env.world = App.Tmp.loadTAB;
|
App.Env.world = App.Tmp.loadTAB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ $('document').ready(function() {
|
||||||
else {
|
else {
|
||||||
App.Env.world = App.Constants.TABS[0];
|
App.Env.world = App.Constants.TABS[0];
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
App.Pages.init();
|
App.Pages.init();
|
||||||
App.Core.listen();
|
App.Core.listen();
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
App.Actions.login_as = function(evt)
|
||||||
|
{
|
||||||
|
var elm = $(evt.target);
|
||||||
|
var ref = elm.parents('.row');
|
||||||
|
var source = App.Helpers.evalJSON($(ref).find('.source').val())
|
||||||
|
App.Ajax.request('USER.loginAs', {'user': source.LOGIN_NAME}, function(reply) {
|
||||||
|
if (reply.result) {
|
||||||
|
location.href = "";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
App.Helpers.alert('You cannot do this action. Please contact support');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
App.Actions.toggle_suspend = function(evt)
|
App.Actions.toggle_suspend = function(evt)
|
||||||
{
|
{
|
||||||
var elm = $(evt.target);
|
var elm = $(evt.target);
|
||||||
|
@ -156,6 +171,19 @@ App.Actions.change_password = function(evt)
|
||||||
App.Actions.profile_exit = function(evt)
|
App.Actions.profile_exit = function(evt)
|
||||||
{
|
{
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
|
if (App.Env.initialParams.real_user) { // exit "logged in as" state
|
||||||
|
App.Ajax.request('USER.logoutAs', {}, function(reply) {
|
||||||
|
if (reply.result) {
|
||||||
|
location.href = "";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
App.Helpers.alert('You cannot do this action. Please contact support');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
App.Ajax.request('MAIN.logoff', {}, function(reply) {
|
App.Ajax.request('MAIN.logoff', {}, function(reply) {
|
||||||
location.href = '';
|
location.href = '';
|
||||||
});
|
});
|
||||||
|
|
|
@ -134,6 +134,13 @@ App.Helpers.updateInitial = function()
|
||||||
});
|
});
|
||||||
$('#user-name').html(App.Env.initialParams.PROFILE.uid);
|
$('#user-name').html(App.Env.initialParams.PROFILE.uid);
|
||||||
$('#page').removeClass('hidden');
|
$('#page').removeClass('hidden');
|
||||||
|
|
||||||
|
if (App.Env.initialParams.real_user) {
|
||||||
|
var tpl = App.Templates.get('logged_as', 'general');
|
||||||
|
tpl.set(':YOU_ARE', App.Env.initialParams.real_user);
|
||||||
|
tpl.set(':USER', App.Env.initialParams.auth_user.uid.uid);
|
||||||
|
$('body').prepend(tpl.finalize());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
App.Helpers.beforeAjax = function(jedi_method)
|
App.Helpers.beforeAjax = function(jedi_method)
|
||||||
|
|
|
@ -16,7 +16,8 @@ App.Templates.html = {
|
||||||
"Well," the farmer said, "I didn\'t have anymore rope, so I took off my belt and tied her tail to the rafter. In that moment, my pants fell down and my wife walked in ... Some things you just can\'t explain."']
|
"Well," the farmer said, "I didn\'t have anymore rope, so I took off my belt and tied her tail to the rafter. In that moment, my pants fell down and my wife walked in ... Some things you just can\'t explain."']
|
||||||
},
|
},
|
||||||
general: {
|
general: {
|
||||||
over_bar: ['<span style="width:~!:OVER_PERCENTS~!%;right:-~!:OVER_PERCENTS_2~!%;" class="bar_overdraft"></span>'],
|
logged_as: ['<div id="logged-in-as">You (<i>~!:YOU_ARE~!</i>) are viewing <strong style="font-weight: bold; color: #2A8FBD;">~!:USER~!</strong> interface. Exit it to return to your own.</div>'],
|
||||||
|
over_bar: ['<span style="width:~!:OVER_PERCENTS~!%;right:-~!:OVER_PERCENTS_2~!%;" class="bar_overdraft"></span>'],
|
||||||
loading: ['<div id="loading" style="border-radius: 0 0 6px 6px;top: 0;font-size:19px;font-weight: bol;position:fixed;width: 150px; background-color:#6E6E62;z-index: 9999; padding: 8px;left: 50%;margin-left:-75px;">\
|
loading: ['<div id="loading" style="border-radius: 0 0 6px 6px;top: 0;font-size:19px;font-weight: bol;position:fixed;width: 150px; background-color:#6E6E62;z-index: 9999; padding: 8px;left: 50%;margin-left:-75px;">\
|
||||||
<center><div style="width: 105px; height:30px;background-image: url(\'../images/loading.png\');"></center>\
|
<center><div style="width: 105px; height:30px;background-image: url(\'../images/loading.png\');"></center>\
|
||||||
</div>'],
|
</div>'],
|
||||||
|
@ -397,13 +398,13 @@ App.Templates.html = {
|
||||||
</div>\
|
</div>\
|
||||||
<div class="form-row cc">\
|
<div class="form-row cc">\
|
||||||
<label for="#" class="field-label">Package:</label>\
|
<label for="#" class="field-label">Package:</label>\
|
||||||
<select name="PACKAGE" class="styled">\
|
<select name="PACKAGE" class="styled disabled" >\
|
||||||
~!:PACKAGE_OPTIONS~!\
|
~!:PACKAGE_OPTIONS~!\
|
||||||
</select>\
|
</select>\
|
||||||
</div>\
|
</div>\
|
||||||
<div class="form-row cc">\
|
<div class="form-row cc">\
|
||||||
<label for="#" class="field-label">Shell:</label>\
|
<label for="#" class="field-label">Shell:</label>\
|
||||||
<select class="styled" name="SHELL">\
|
<select class="styled disabled" name="SHELL">\
|
||||||
~!:SHELL_OPTIONS~!\
|
~!:SHELL_OPTIONS~!\
|
||||||
</select>\
|
</select>\
|
||||||
</div>\
|
</div>\
|
||||||
|
@ -474,6 +475,9 @@ App.Templates.html = {
|
||||||
</span>\
|
</span>\
|
||||||
</div>\
|
</div>\
|
||||||
<div class="user-details-box">\
|
<div class="user-details-box">\
|
||||||
|
<span class="prop-box prop-box_group-values cc user-details do_action_login_as">\
|
||||||
|
<span class="prop-value login-as do_action_login_as">login as</span>\
|
||||||
|
</span>\
|
||||||
<span class="prop-box user-name">\
|
<span class="prop-box user-name">\
|
||||||
<span class="prop-title">name:</span>\
|
<span class="prop-title">name:</span>\
|
||||||
<span class="prop-value">~!:FULLNAME~!</span>\
|
<span class="prop-value">~!:FULLNAME~!</span>\
|
||||||
|
|
|
@ -227,7 +227,8 @@ MAIL;
|
||||||
'DB' => $this->getDbParams($data_db),
|
'DB' => $this->getDbParams($data_db),
|
||||||
'USERS' => $this->getUsersParams($data_user),
|
'USERS' => $this->getUsersParams($data_user),
|
||||||
'totals' => $totals,
|
'totals' => $totals,
|
||||||
'PROFILE' => $user
|
'PROFILE' => $user,
|
||||||
|
'real_user' => $_SESSION['real_user'] ? $_SESSION['real_user'] : NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->reply(true, $reply);
|
return $this->reply(true, $reply);
|
||||||
|
|
|
@ -158,7 +158,7 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if ($_s['SSL']) {
|
/* if ($_s['SSL']) {
|
||||||
$params = array(
|
$params = array(
|
||||||
'USER' => $user['uid'],
|
'USER' => $user['uid'],
|
||||||
'DOMAIN' => $_s['DOMAIN'],
|
'DOMAIN' => $_s['DOMAIN'],
|
||||||
|
@ -178,7 +178,7 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
}
|
}
|
||||||
if ($_s['SSL_HOME']) {
|
if ($_s['SSL_HOME']) {
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
/*if (!empty($_s['DNS'])) {
|
/*if (!empty($_s['DNS'])) {
|
||||||
$params = array(
|
$params = array(
|
||||||
|
@ -264,25 +264,42 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
|
|
||||||
$_old['ELOG'] = $_old['ELOG'] == 'yes' ? 'on' : 'off';
|
$_old['ELOG'] = $_old['ELOG'] == 'yes' ? 'on' : 'off';
|
||||||
$_old['CGI'] = $_old['CGI'] == 'yes' ? 'on' : 'off';
|
$_old['CGI'] = $_old['CGI'] == 'yes' ? 'on' : 'off';
|
||||||
$_old['AUTH'] = $_old['AUTH'] == 'yes' ? 'on' : 'off';
|
$_old['AUTH'] = $_old['AUTH'] == 'yes' ? 'on' : 'off';
|
||||||
$_old['SSL'] = $_old['SSL'] == 'yes' ? 'on' : 'off';
|
$_old['SSL'] = $_old['SSL'] == 'yes' ? 'on' : 'off';
|
||||||
|
|
||||||
$user = $this->getLoggedUser();
|
$user = $this->getLoggedUser();
|
||||||
$_DOMAIN = $_new['DOMAIN'];
|
$_DOMAIN = $_new['DOMAIN'];
|
||||||
|
|
||||||
if ($_new['SUSPEND'] == 'on') {
|
if ($_old['SUSPEND'] != $_new['SUSPEND']) {
|
||||||
$result = Vesta::execute(Vesta::V_SUSPEND_WEB_DOMAIN, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
|
if ($_new['SUSPEND'] == 'on') {
|
||||||
if (!$result['status']) {
|
$result = Vesta::execute(Vesta::V_SUSPEND_WEB_DOMAIN, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
|
||||||
$this->status = FALSE;
|
if (!$result['status']) {
|
||||||
$this->errors['SUSPEND'] = array($result['error_code'] => $result['error_message']);
|
$this->status = FALSE;
|
||||||
|
$this->errors['SUSPEND'] = array($result['error_code'] => $result['error_message']);
|
||||||
|
}
|
||||||
|
// return $this->reply($result['status']);
|
||||||
}
|
}
|
||||||
// return $this->reply($result['status']);
|
else {
|
||||||
}
|
$result = Vesta::execute(Vesta::V_UNSUSPEND_WEB_DOMAIN, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
|
||||||
else {
|
if (!$result['status']) {
|
||||||
$result = Vesta::execute(Vesta::V_UNSUSPEND_WEB_DOMAIN, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
|
$this->status = FALSE;
|
||||||
if (!$result['status']) {
|
$this->errors['UNSUSPEND'] = array($result['error_code'] => $result['error_message']);
|
||||||
$this->status = FALSE;
|
}
|
||||||
$this->errors['UNSUSPEND'] = array($result['error_code'] => $result['error_message']);
|
}
|
||||||
|
if ($_new['SUSPEND'] == 'on') {
|
||||||
|
$result = Vesta::execute(Vesta::V_SUSPEND_WEB_DOMAIN, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
|
||||||
|
if (!$result['status']) {
|
||||||
|
$this->status = FALSE;
|
||||||
|
$this->errors['SUSPEND'] = array($result['error_code'] => $result['error_message']);
|
||||||
|
}
|
||||||
|
// return $this->reply($result['status']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$result = Vesta::execute(Vesta::V_UNSUSPEND_WEB_DOMAIN, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
|
||||||
|
if (!$result['status']) {
|
||||||
|
$this->status = FALSE;
|
||||||
|
$this->errors['UNSUSPEND'] = array($result['error_code'] => $result['error_message']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,7 +439,7 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_new['SSL']) {
|
/*if ($_new['SSL']) {
|
||||||
$params = array(
|
$params = array(
|
||||||
'USER' => $user['uid'],
|
'USER' => $user['uid'],
|
||||||
'DOMAIN' => $_new['DOMAIN'],
|
'DOMAIN' => $_new['DOMAIN'],
|
||||||
|
@ -439,16 +456,19 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
if (!$result['status']) {
|
if (!$result['status']) {
|
||||||
$this->errors['SSL'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['SSL'] = array($result['error_code'] => $result['error_message']);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
if (!empty($_s['SSL_KEY'])) {
|
||||||
|
$ssl_file = tempnam(sys_get_temp_dir(), 'ssl');
|
||||||
|
file_put_contents($ssl_file, $_s['SSL_KEY']);
|
||||||
|
|
||||||
if ($_s['SSL_KEY']) {
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'USER' => $user['uid'],
|
'USER' => $user['uid'],
|
||||||
'DOMAIN' => $_s['DOMAIN'],
|
'DOMAIN' => $_s['DOMAIN'],
|
||||||
'SSL_KEY' => $_s['SSL_KEY']
|
'SSL_KEY' => $ssl_file
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($_s['SSL_HOME']) {
|
if (!empty($_s['SSL_HOME'])) {
|
||||||
$params['SSL_HOME'] = $_s['SSL_HOME'];
|
$params['SSL_HOME'] = $_s['SSL_HOME'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,6 +480,26 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!empty($_s['SSL_CERT'])) {
|
||||||
|
$sslcert_file = tempnam(sys_get_temp_dir(), 'ssl');
|
||||||
|
file_put_contents($sslcert_file, $_s['SSL_CERT']);
|
||||||
|
|
||||||
|
$params = array(
|
||||||
|
'USER' => $user['uid'],
|
||||||
|
'DOMAIN' => $_s['DOMAIN'],
|
||||||
|
'SSL_CERT' => $sslcert_file
|
||||||
|
);
|
||||||
|
|
||||||
|
$result = 0;
|
||||||
|
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_SSLCERT, $params);
|
||||||
|
|
||||||
|
if (!$result['status']) {
|
||||||
|
$this->errors['SSL_CERT'] = array($result['error_code'] => $result['error_message']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return $this->reply($result['status'], $result['data']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,7 +551,7 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
$_entities = $request->getParameter('entities');
|
$_entities = $request->getParameter('entities');
|
||||||
|
|
||||||
foreach($_entities as $entity){
|
foreach($_entities as $entity){
|
||||||
$result = Vesta::execute(Vesta::V_SUSPEND_WEB_DOMAIN, array('USER' => $user['uid'], $entity['DOMAIN']));
|
$result = Vesta::execute(Vesta::V_SUSPEND_WEB_DOMAIN, array('USER' => $user, $entity['DOMAIN']));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->reply($result['status'], $result['data']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
|
@ -523,7 +563,7 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
$_entities = $request->getParameter('entities');
|
$_entities = $request->getParameter('entities');
|
||||||
|
|
||||||
foreach($_entities as $entity){
|
foreach($_entities as $entity){
|
||||||
$result = Vesta::execute(Vesta::V_UNUSPEND_WEB_DOMAIN, array('USER' => $user['uid'], $entity['DOMAIN']));
|
$result = Vesta::execute(Vesta::V_UNUSPEND_WEB_DOMAIN, array('USER' => $user, $entity['DOMAIN']));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->reply($result['status'], $result['data']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
|
@ -535,10 +575,9 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
$_entities = $request->getParameter('entities');
|
$_entities = $request->getParameter('entities');
|
||||||
|
|
||||||
foreach($_entities as $entity){
|
foreach($_entities as $entity){
|
||||||
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN, array('USER' => $user['uid'], $entity['DOMAIN']));
|
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN, array('USER' => $user, $entity['DOMAIN']));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->reply($result['status'], $result['data']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue