changed auth process to just ask server if session is active
This commit is contained in:
commit
bf383785a0
5 changed files with 20 additions and 31 deletions
|
@ -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 %}
|
8
public/assets/scripts/dash.min.js
vendored
8
public/assets/scripts/dash.min.js
vendored
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
|
|
||||||
: 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…
Reference in a new issue