Skip to content

Commit

Permalink
Testing done!
Browse files Browse the repository at this point in the history
Installing, uninstalling, testing...
  • Loading branch information
lokamaya committed Mar 30, 2019
1 parent 4783a63 commit 537ad11
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 265 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ A MODx extra to works with JSON Web Token (JWT)
===============================================

Documentation: https://github.com/lokamaya/modJWT (next on this)

Bugs and Feature Requests: https://github.com/lokamaya/modJWT/issues

Discussion and Questions: [MODx Community](https://community.modx.com/t/modjwt-an-extra-to-works-with-json-web-token-jwt/330?u=lokamaya)

4 changes: 4 additions & 0 deletions _build/config/modjwt.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@
'alias' => 'modjwt',
'richtext' => false,
'published' => true,
'template' => 0,
),
'token' => array( /* idea: json page */
'pagetitle' => 'Token',
Expand All @@ -267,6 +268,7 @@
'parent' => 'modjwt',
'richtext' => false,
'published' => true,
'template' => 0,
'content_type' => 7,
),
'validate' => array( /* idea: json page */
Expand All @@ -276,6 +278,7 @@
'parent' => 'modjwt',
'richtext' => false,
'published' => true,
'template' => 0,
'content_type' => 7,
),
'custom' => array( /* idea: json page */
Expand All @@ -286,6 +289,7 @@
'richtext' => false,
'published' => true,
'container' => true,
'template' => 0,
'content_type' => 7,
),
),
Expand Down
15 changes: 8 additions & 7 deletions _build/data/resources/modjwt.content.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

<!-- jQuery -->
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script>var pageID = [[*id]];</script>

[[$modjwtCssSample]]

Expand All @@ -26,16 +27,16 @@ <h3 class="text-center">ModJWT</h3>
<br />
<div class="text-center" style="border:1px solid #ddd; background:#eee;">

<!-- change #index.php?id=7 to the valid resourceid of Token, but do not remove the hash "#" /-->
<button id="getToken" type="button" class="btn btn-link" value="create" formaction="index.php?id=7" title="Get a new Token">[create]</button>
<!-- change #index.php?id=OfToken to the valid resourceid or URL /-->
<button id="getToken" type="button" class="btn btn-link" value="create" formaction="index.php?id=OfToken" title="Get a new Token">[create]</button>

<!-- change #index.php?id=8 to the valid resourceid of Validate, but do not remove the hash "#" /-->
<button id="valToken" type="button" class="btn btn-link" value="validate" formaction="index.php?id=8" title="Validating Token">[validate]</button>
<!-- change #index.php?id=OfValidate to the valid resourceid or URL /-->
<button id="valToken" type="button" class="btn btn-link" value="validate" formaction="index.php?id=OfValidate" title="Validating Token">[validate]</button>

<!-- change #index.php?id=9 to the valid resourceid of Validate, but do not remove the hash "#" /-->
<button id="cusToken" type="button" class="btn btn-link" value="custom" formaction="index.php?id=9" title="Get custom value">[custom]</button>
<!-- change #index.php?id=OfCustom to the valid resourceid or URL /-->
<button id="cusToken" type="button" class="btn btn-link" value="custom" formaction="index.php?id=OfCustom" title="Get custom value">[custom]</button>

<button id="remToken" type="button" class="btn btn-link" value="destroy" formaction="self" title="Destroying Token" style="color:red">[destroy]</button>
<button id="remToken" type="button" class="btn btn-link" value="destroy" formaction="#self" title="Destroying Token" style="color:red">[destroy]</button>
</div>
<br />
<div class="form-group">
Expand Down
156 changes: 0 additions & 156 deletions _build/data/transport.resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,160 +181,4 @@ function stripPhpTags($filename) {
), '', true, true);
$resources[4]->setContent(file_get_contents($sources['data'].'resources/custom.content.html'));

$resources[5] = $modx->newObject('modResource');
$resources[5]->fromArray(array (
'id' => 5,
'type' => 'document',
'contentType' => 'text/html',
'pagetitle' => 'ModJWT',
'longtitle' => 'ModJWT Sample Page',
'description' => 'Sample page for modJWT a MODx Extra',
'alias' => 'modjwt',
'alias_visible' => true,
'link_attributes' => '',
'published' => true,
'isfolder' => true,
'introtext' => '',
'richtext' => false,
'template' => 0,
'menuindex' => 2,
'searchable' => false,
'cacheable' => true,
'createdby' => 1,
'editedby' => 1,
'deleted' => false,
'deletedon' => 0,
'deletedby' => 0,
'menutitle' => '',
'donthit' => false,
'privateweb' => false,
'privatemgr' => false,
'content_dispo' => 0,
'hidemenu' => true,
'class_key' => 'modDocument',
'context_key' => 'web',
'content_type' => 1,
'hide_children_in_tree' => 0,
'show_in_tree' => 1,
'properties' => NULL,
), '', true, true);
$resources[5]->setContent(file_get_contents($sources['data'].'resources/modjwt.content.html'));

$resources[6] = $modx->newObject('modResource');
$resources[6]->fromArray(array (
'id' => 6,
'type' => 'document',
'contentType' => 'application/json',
'pagetitle' => 'Token',
'longtitle' => 'Issuing Token - JSON',
'description' => 'Make sure content type is JSON',
'alias' => 'token',
'alias_visible' => true,
'link_attributes' => '',
'published' => true,
'isfolder' => true,
'introtext' => '',
'richtext' => false,
'template' => 0,
'menuindex' => 0,
'searchable' => false,
'cacheable' => false,
'createdby' => 1,
'editedby' => 1,
'deleted' => false,
'deletedon' => 0,
'deletedby' => 0,
'menutitle' => '',
'donthit' => false,
'privateweb' => false,
'privatemgr' => false,
'content_dispo' => 0,
'hidemenu' => true,
'class_key' => 'modDocument',
'context_key' => 'web',
'content_type' => 7,
'hide_children_in_tree' => 0,
'show_in_tree' => 1,
'properties' => NULL,
), '', true, true);
$resources[6]->setContent(file_get_contents($sources['data'].'resources/token.content.html'));

$resources[7] = $modx->newObject('modResource');
$resources[7]->fromArray(array (
'id' => 7,
'type' => 'document',
'contentType' => 'application/json',
'pagetitle' => 'Validate',
'longtitle' => 'Validating Token - JSON',
'description' => 'Make sure content type is JSON',
'alias' => 'validate',
'alias_visible' => true,
'link_attributes' => '',
'published' => true,
'isfolder' => true,
'introtext' => '',
'richtext' => false,
'template' => 0,
'menuindex' => 1,
'searchable' => false,
'cacheable' => false,
'createdby' => 1,
'editedby' => 1,
'deleted' => false,
'deletedon' => 0,
'deletedby' => 0,
'menutitle' => '',
'donthit' => false,
'privateweb' => false,
'privatemgr' => false,
'content_dispo' => 0,
'hidemenu' => true,
'class_key' => 'modDocument',
'context_key' => 'web',
'content_type' => 7,
'hide_children_in_tree' => 0,
'show_in_tree' => 1,
'properties' => NULL,
), '', true, true);
$resources[7]->setContent(file_get_contents($sources['data'].'resources/validate.content.html'));

$resources[8] = $modx->newObject('modResource');
$resources[8]->fromArray(array (
'id' => 8,
'type' => 'document',
'contentType' => 'application/json',
'pagetitle' => 'Custom',
'longtitle' => 'Validating Token & output custom value',
'description' => 'Make sure content type is JSON',
'alias' => 'validate',
'alias_visible' => true,
'link_attributes' => '',
'published' => true,
'isfolder' => true,
'introtext' => '',
'richtext' => false,
'template' => 0,
'menuindex' => 1,
'searchable' => false,
'cacheable' => false,
'createdby' => 1,
'editedby' => 1,
'deleted' => false,
'deletedon' => 0,
'deletedby' => 0,
'menutitle' => '',
'donthit' => false,
'privateweb' => false,
'privatemgr' => false,
'content_dispo' => 0,
'hidemenu' => true,
'class_key' => 'modDocument',
'context_key' => 'web',
'content_type' => 7,
'hide_children_in_tree' => 0,
'show_in_tree' => 1,
'properties' => NULL,
), '', true, true);
$resources[8]->setContent(file_get_contents($sources['data'].'resources/custom.content.html'));

return $resources;
69 changes: 0 additions & 69 deletions _build/install.options/user.input.php

This file was deleted.

24 changes: 3 additions & 21 deletions _build/resolvers/resource.resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,6 @@ function checkFields($required, $objectFields) {
'parent' => 'ModJWT',
'template' => 0,
),
4 => array (
'pagetitle' => 'ModJWT',
'parent' => '0',
'template' => 0,
),
5 => array (
'pagetitle' => 'Token',
'parent' => 'ModJWT',
'template' => 0,
),
6 => array (
'pagetitle' => 'Validate',
'parent' => 'ModJWT',
'template' => 0,
),
7 => array (
'pagetitle' => 'Custom',
'parent' => 'ModJWT',
'template' => 0,
),
);

if (is_array($intersects)) {
Expand All @@ -101,7 +81,9 @@ function checkFields($required, $objectFields) {
if (! $resource) {
continue;
}
if ($fields['template'] == 'default') {
if ($fields['template'] == 0) {
$resource->set('template', 0);
} elseif ($fields['template'] == 'default') {
$resource->set('template', $modx->getOption('default_template'));
} else {
$templateObj = $modx->getObject('modTemplate', array('templatename' => $fields['template']));
Expand Down
6 changes: 4 additions & 2 deletions core/components/modjwt/docs/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Changelog for modJWT

modJWT 1.0.0
modJWT 1.0.0-beta
---------------------------------
Initial Version
Initial Version.
See https://github.com/lokamaya/modJWT for more information.

Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
localStorage.setItem("token", _token);
$('#loggerData').text("Token:\n" + _token);
} else {
msgs += " \n - seems you went to the wrong page";
msgs += " \n - Verify URL: " + _actionVal;
msgs += " \n - Go to manager: edit the 'formaction' of blue link above!";
}
} else {
msgs += " \n - unknown error";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@
**/

// Core path
$corePath = $modx->getOption('modjwt.corePath', null, $modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/modjwt/');
$assetsUrl = $modx->getOption('modjwt.assetUrl', null, $modx->getOption('assets_url', null, MODX_ASSETS_URL) . 'components/modjwt/');
$corePath = $modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/modjwt/';
$scriptProperties['corePath'] = $corePath;
$scriptProperties['assetsUrl'] = $assetsUrl;
$scriptProperties['requestType'] = 'decode';

/** @var modJWT $modJWT */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@
$output = '';

// Core path
$corePath = $modx->getOption('modjwt.corePath', null, $modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/modjwt/');
$assetsUrl = $modx->getOption('modjwt.assetUrl', null, $modx->getOption('assets_url', null, MODX_ASSETS_URL) . 'components/modjwt/');
$corePath = $modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/modjwt/';
$scriptProperties['corePath'] = $corePath;
$scriptProperties['assetsUrl'] = $assetsUrl;
$scriptProperties['requestType'] = 'encode';

/** @var modJWT $modJWT */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function decodeJWT() {

$_tokenArray = explode('.', $token);
if (count($_tokenArray) != 3) {
return $this->outputError($this->modx->lexicon('modjwt_error_token_token') . $token, 400);
return $this->outputError($this->modx->lexicon('modjwt_error_token_invalid') . $token, 400);
}

list($headb64, $bodyb64, $cryptob64) = $_tokenArray;
Expand Down

0 comments on commit 537ad11

Please sign in to comment.