changed auth process to just ask server if session is active

beta
Ro 3 years ago
commit bf383785a0

@ -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

@ -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 if (response.type === API_ACCESS_GOOD) {
: API_STATUS + "?key=" + this.key this.token = response.token;
).then((response) => { } else {
if (response.type === API_ACCESS_GOOD) { //don't set token
this.token = response.token; //console.log("NO TOKEN");
} else { }
//don't set 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