changed auth process to just ask server if session is active

pull/84/head
Ro 3 years ago
parent b3c47d6721
commit 183a620b1e

@ -9,6 +9,7 @@ class AuthAPI
public static function status() public static function status()
{ {
$result = []; $result = [];
//internal check for admin action
if (Auth::status()) { if (Auth::status()) {
$result = [ $result = [
"message" => "Authorized", "message" => "Authorized",

@ -19,14 +19,7 @@ class APIControl
$filename = ""; $filename = "";
switch (isset($args["third"]) ? $args["third"] : "none") { switch (isset($args["third"]) ? $args["third"] : "none") {
case "status": case "status":
if (Member::verifyKey($_GET["key"])) {
$result = AuthAPI::status(); $result = AuthAPI::status();
} else {
$result = [
"message" => "Valid key required. API access denied, homie",
"type" => "API_ERROR",
];
}
break; break;
case "page": case "page":

@ -23,5 +23,5 @@
{% endblock %} {% endblock %}
{% block javascripts %} {% block javascripts %}
<script src="/assets/scripts/dash.min.js" type="text/javascript"></script> <script src="/assets/scripts/dash.min.js?" type="text/javascript"></script>
{% endblock %} {% endblock %}

File diff suppressed because one or more lines are too long

@ -11,10 +11,7 @@ export default class NavIndex {
//-------------------------- //--------------------------
constructor() { constructor() {
this.processing = false; this.processing = false;
this.admin = new FipamoAdminAPI( this.admin = new FipamoAdminAPI(null);
null,
"fe79df250470815bf32dcea70221384c89163cad3a827a9c3da25d87159ed55a"
);
this.start(); this.start();
} }
//-------------------------- //--------------------------

@ -19,10 +19,7 @@ export default class PostEditor {
constructor() { constructor() {
this.processing = false; this.processing = false;
let self = this; let self = this;
this.admin = new FipamoAdminAPI( this.admin = new FipamoAdminAPI(null);
null,
"fe79df250470815bf32dcea70221384c89163cad3a827a9c3da25d87159ed55a"
);
this.urlPieces = document.URL.split("/"); this.urlPieces = document.URL.split("/");
this.post = []; this.post = [];
this.postID = null; this.postID = null;

@ -14,10 +14,7 @@ export default class SettingsIndex {
constructor() { constructor() {
this.processing = false; this.processing = false;
this.start(); this.start();
this.admin = new FipamoAdminAPI( this.admin = new FipamoAdminAPI(null);
null,
"fe79df250470815bf32dcea70221384c89163cad3a827a9c3da25d87159ed55a"
);
this.mm = new Maintenance(null, null); this.mm = new Maintenance(null, null);
} }
//-------------------------- //--------------------------

@ -44,28 +44,23 @@ class FipamoAdminAPI {
/** /**
* @constructor * @constructor
* @param {string} baseURL - url of site; uses local when empty * @param {string} baseURL - url of site; uses local when empty
* @param {string} key - user api key
*/ */
constructor(baseURL = null, key = null) { constructor(baseURL = null) {
this.percentComplete = 0; //for later this.percentComplete = 0; //for later
this.token = null;
this.baseURL = null; this.baseURL = null;
this.key = null; this.status = false;
if (key) this.key = key;
if (baseURL) this.baseURL = baseURL; if (baseURL) this.baseURL = baseURL;
//if key is valid, checks to see if a session is active and returns //asks server if a session is active
this._request( this._request(this.baseURL ? this.baseURL + API_STATUS : API_STATUS).then(
this.baseURL (response) => {
? this.baseURL + API_STATUS + "?key=" + this.key
: API_STATUS + "?key=" + this.key
).then((response) => {
if (response.type === API_ACCESS_GOOD) { if (response.type === API_ACCESS_GOOD) {
this.token = response.token; this.token = response.token;
} else { } else {
//don't set token //don't set token
//console.log("NO TOKEN"); //console.log("NO TOKEN");
} }
}); }
);
} }
/** /**
* Promise method for authenticating and starting a session\ * Promise method for authenticating and starting a session\
@ -262,7 +257,7 @@ class FipamoAdminAPI {
} }
if (this.baseURL) { if (this.baseURL) {
data.key = this.key; //data.key = this.key;
data.remote = true; data.remote = true;
} else { } else {
data.remote = false; data.remote = false;

Loading…
Cancel
Save