changed auth process to just ask server if session is active

This commit is contained in:
Ro 2021-08-03 14:31:13 -07:00
parent b3c47d6721
commit 183a620b1e
8 changed files with 23 additions and 43 deletions

View file

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

View file

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

View file

@ -23,5 +23,5 @@
{% endblock %}
{% 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 %}

File diff suppressed because one or more lines are too long

View file

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

View file

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

View file

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

View file

@ -44,28 +44,23 @@ class FipamoAdminAPI {
/**
* @constructor
* @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.token = null;
this.baseURL = null;
this.key = null;
if (key) this.key = key;
this.status = false;
if (baseURL) this.baseURL = baseURL;
//if key is valid, checks to see if a session is active and returns
this._request(
this.baseURL
? this.baseURL + API_STATUS + "?key=" + this.key
: API_STATUS + "?key=" + this.key
).then((response) => {
if (response.type === API_ACCESS_GOOD) {
this.token = response.token;
} else {
//don't set token
//console.log("NO TOKEN");
//asks server if a session is active
this._request(this.baseURL ? this.baseURL + API_STATUS : API_STATUS).then(
(response) => {
if (response.type === API_ACCESS_GOOD) {
this.token = response.token;
} else {
//don't set token
//console.log("NO TOKEN");
}
}
});
);
}
/**
* Promise method for authenticating and starting a session\
@ -262,7 +257,7 @@ class FipamoAdminAPI {
}
if (this.baseURL) {
data.key = this.key;
//data.key = this.key;
data.remote = true;
} else {
data.remote = false;