forked from projects/fipamo
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()
|
||||
{
|
||||
$result = [];
|
||||
//internal check for admin action
|
||||
if (Auth::status()) {
|
||||
$result = [
|
||||
"message" => "Authorized",
|
||||
|
|
|
@ -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":
|
||||
|
|
|
@ -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 %}
|
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
|
||||
* @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;
|
||||
|
|
Loading…
Reference in a new issue