Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Convert validate user to post request
  • Loading branch information
samerton committed Sep 25, 2021
1 parent 12c964f commit e247226
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
12 changes: 11 additions & 1 deletion custom/panel_templates/Default/core/users_edit.tpl
Expand Up @@ -56,7 +56,7 @@
{if isset($UPDATE_UUID)}<a class="dropdown-item"
href="{$UPDATE_UUID_LINK}">{$UPDATE_UUID}</a>{/if}
{if isset($VALIDATE_USER)}<a class="dropdown-item"
href="{$VALIDATE_USER_LINK}">{$VALIDATE_USER}</a>{/if}
href="#" onclick="validateUser()">{$VALIDATE_USER}</a>{/if}
</div>
</div>
<a href="{$BACK_LINK}" class="btn btn-warning">{$BACK}</a>
Expand Down Expand Up @@ -215,6 +215,10 @@
<!-- End Wrapper -->
</div>

<form style="display:none" action="{$VALIDATE_USER_LINK}" method="post" id="validateUserForm">
<input type="hidden" name="token" value="{$TOKEN}" />
</form>

{include file='scripts.tpl'}

<script type="text/javascript">
Expand All @@ -223,6 +227,12 @@
$('#deleteModal').modal().show();
}
{/if}
{if isset($VALIDATE_USER)}
function validateUser() {
$('#validateUserForm').submit();
}
{/if}
</script>

</body>
Expand Down
35 changes: 19 additions & 16 deletions modules/Core/pages/panel/users_edit.php
Expand Up @@ -39,23 +39,26 @@

if (isset($_GET['action'])) {
if ($_GET['action'] == 'validate') {
// Validate the user
if ($user_query->active == 0) {
$queries->update('users', $user_query->id, array(
'active' => 1,
'reset_code' => ''
));

HookHandler::executeEvent('validateUser', array(
'event' => 'validateUser',
'user_id' => $user_query->id,
'username' => Output::getClean($user_query->username),
'uuid' => Output::getClean($user_query->uuid),
'language' => $language
));

Session::flash('edit_user_success', $language->get('admin', 'user_validated_successfully'));
if (Token::check()) {
// Validate the user
if ($user_query->active == 0) {
$queries->update('users', $user_query->id, array(
'active' => 1,
'reset_code' => ''
));

HookHandler::executeEvent('validateUser', array(
'event' => 'validateUser',
'user_id' => $user_query->id,
'username' => Output::getClean($user_query->username),
'uuid' => Output::getClean($user_query->uuid),
'language' => $language
));

Session::flash('edit_user_success', $language->get('admin', 'user_validated_successfully'));
}
}

} else if ($_GET['action'] == 'update_mcname') {
require_once(ROOT_PATH . '/core/integration/uuid.php');
$uuid = $user_query->uuid;
Expand Down

0 comments on commit e247226

Please sign in to comment.