Skip to content

Commit

Permalink
action_ycom_auth_db: logout entfernt, id wenn user vorhanden -> sql[i…
Browse files Browse the repository at this point in the history
…d] für action:db_query #236
  • Loading branch information
dergel committed Sep 17, 2019
1 parent 1aab280 commit 34e6e8d
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions plugins/auth/lib/yform/action/ycom_auth_db.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ class rex_yform_action_ycom_auth_db extends rex_yform_action_abstract
public function execute()
{
$user = rex_ycom_auth::getUser();
$action = '';
if (!rex::isBackend() && !$user) {

if (rex::isBackend() || !$user) {
echo 'error - access denied - user not logged in';
return;

} else {
switch ($this->getElement(2)) {
case 'logout':
rex_ycom_auth::clearUserSession();
$action = 'logout';
break;

switch ($this->getElement(2)) {
case 'delete':
rex_ycom_auth::deleteUser($user->getValue('id'));
rex_ycom_auth::clearUserSession();
Expand All @@ -23,6 +21,7 @@ public function execute()

case 'update':
default:

$sql = rex_sql::factory();
if ($this->params['debug']) {
$sql->setDebug();
Expand All @@ -32,9 +31,13 @@ public function execute()
foreach ($this->params['value_pool']['sql'] as $key => $value) {
$sql->setValue($key, $value);
}
$sql->setWhere('id='.$user->getValue('id').'');
$sql->setWhere('id = :id', ['id' => $user->getValue('id')]);
$sql->update();
$action = 'update';

$this->params['main_id'] = $user->getValue('id');
$this->params['value_pool']['sql']['id'] = $user->getValue('id');

break;
}
}
Expand All @@ -49,10 +52,11 @@ public function execute()
'yform' => true,
]
));

}

public function getDescription()
{
return 'action|ycom_auth_db|update(default)/delete/logout';
return 'action|ycom_auth_db|update(default)/delete';
}
}

0 comments on commit 34e6e8d

Please sign in to comment.