mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Fix for non-selectable API-code
- Fixed issue where API-code couldn't be selected - Added view to see if the api-key has been fetched or not - Added option to try again with the same email if the previous link has timed-out after a day
This commit is contained in:
@@ -35,11 +35,16 @@ $(document).on("click", "#refresh_all", function(e){
|
||||
to_add.attr("id", response[i]._id);
|
||||
to_add.find(".api_token_name").text(response[i].name);
|
||||
to_add.find(".api_token_usage").text(response[i].usage);
|
||||
to_add.find(".api_token_limit").attr("id", response[i]._id + "-limit");
|
||||
to_add.find(".update_api_token").attr("id", response[i]._id + "-limit");
|
||||
to_add.find(".delete_api_token").attr("id", response[i]._id + "-delete");
|
||||
to_add.find(".delete_api_token").attr("data-id", response[i]._id);
|
||||
to_add.find(".update_api_token").attr("data-id", response[i]._id);
|
||||
$(".channel_things").append(to_add);
|
||||
if(response[i].active) {
|
||||
to_add.find(".check").removeClass("hide");
|
||||
} else {
|
||||
to_add.find(".uncheck").removeClass("hide");
|
||||
}
|
||||
$("#api_keys").append(to_add);
|
||||
}
|
||||
},
|
||||
error: function(err) {
|
||||
@@ -170,7 +175,7 @@ $(document).on("click", ".delete_api_token", function(e) {
|
||||
$("#" + id + "-limit").toggleClass("disabled");
|
||||
}
|
||||
},
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
function loaded() {
|
||||
@@ -191,11 +196,16 @@ function loaded() {
|
||||
to_add.attr("id", response[i]._id);
|
||||
to_add.find(".api_token_name").text(response[i].name);
|
||||
to_add.find(".api_token_usage").text(response[i].usage);
|
||||
to_add.find(".api_token_limit").attr("id", response[i]._id + "-limit");
|
||||
to_add.find(".update_api_token").attr("id", response[i]._id + "-limit");
|
||||
to_add.find(".delete_api_token").attr("id", response[i]._id + "-delete");
|
||||
to_add.find(".delete_api_token").attr("data-id", response[i]._id);
|
||||
to_add.find(".update_api_token").attr("data-id", response[i]._id);
|
||||
$(".channel_things").append(to_add);
|
||||
if(response[i].active) {
|
||||
to_add.find(".check").removeClass("hide");
|
||||
} else {
|
||||
to_add.find(".uncheck").removeClass("hide");
|
||||
}
|
||||
$("#api_keys").append(to_add);
|
||||
}
|
||||
},
|
||||
error: function(err) {
|
||||
|
||||
@@ -18,10 +18,11 @@
|
||||
<div class="row">
|
||||
<div class="col s12 m10">
|
||||
<ul class="tabs tabs_admin">
|
||||
<li class="tab col s3"><a class="active" href="#general">General</a></li>
|
||||
<li class="tab col s2"><a class="active" href="#general">General</a></li>
|
||||
<li class="tab col s2"><a href="#api_keys">API<span class="new admin-panel hide"></span></a></li>
|
||||
<li class="tab col s3"><a href="#thumbnails">Thumbnails<span class="new thumbnails-badge badge admin-panel hide"></span></a></li>
|
||||
<li class="tab col s3"><a href="#descriptions">Descriptions<span class="new descriptions-badge badge admin-panel hide"></span></a></li>
|
||||
<li class="tab col s3"><a href="#names">Names</a></li>
|
||||
<li class="tab col s2"><a href="#names">Names</a></li>
|
||||
</ul>
|
||||
<div id="general" class="col s12">
|
||||
<div class="preloader-wrapper big active">
|
||||
@@ -110,6 +111,9 @@
|
||||
<a href="#" id="get_api_token" class="btn waves-effect purple">GET API</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="api_keys" class="col s12">
|
||||
<div class="row header-api-fields">
|
||||
<div class="col s3">
|
||||
Name
|
||||
@@ -127,11 +131,14 @@
|
||||
<div class="col s3 api_token_usage">
|
||||
</div>
|
||||
<input class="api_token_limit col s1" type="number" />
|
||||
<div class="col s1 api_token_activated">
|
||||
<i class="material-icons check hide">check</i>
|
||||
<i class="material-icons uncheck hide">close</i>
|
||||
</div>
|
||||
<a href="#" class="btn waves-effect green col s2 update_api_token">UPDATE</a>
|
||||
<a href="#" class="btn waves-effect red col s1 delete_api_token">X</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="thumbnails" class="col s12">
|
||||
<div class="row">
|
||||
<div class="input-field col s8 m10">
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
</header>
|
||||
<div id="main-container" class="token-container">
|
||||
<main class="center-align container">
|
||||
<div class="token-info left-align">
|
||||
<div class="token-info left-align select">
|
||||
{{#if activated}}
|
||||
<h1 class="center-align">API-token</h1>
|
||||
<p>Here is your api token</p>
|
||||
|
||||
@@ -893,10 +893,12 @@ try {
|
||||
var id = crypto.createHash('sha256').update(uniqid()).digest('base64');
|
||||
var uniqid_link = crypto.createHash('sha256').update(uniqid()).digest('hex');
|
||||
token_db.collection("api_token").find({name: name}, function(err, results_find) {
|
||||
var token = "";
|
||||
if(results_find.length > 0) {
|
||||
res.send("failed");
|
||||
return;
|
||||
token = results_find[0].token;
|
||||
}
|
||||
token_db.collection("api_links").find({token: token}, function(e, d) {
|
||||
if(results_find.length == 0 || (d.length == 0 && results_find.length > 0 && !results_find[0].active)) {
|
||||
token_db.collection("api_token").insert({name: name, token: id, usage: 0, active: false, limit: 100}, function(err, docs){
|
||||
token_db.collection("api_links").insert({id: uniqid_link, token: id, createdAt: new Date()}, function(err, docs) {
|
||||
let transporter = nodemailer.createTransport(mailconfig);
|
||||
@@ -931,6 +933,11 @@ try {
|
||||
});
|
||||
})
|
||||
});
|
||||
} else {
|
||||
res.send("failed");
|
||||
return;
|
||||
}
|
||||
});
|
||||
})
|
||||
} else {
|
||||
res.send("failed");
|
||||
|
||||
@@ -51,7 +51,7 @@ router.route('/api/apply/:id').get(function(req,res) {
|
||||
token_db.collection('api_links').find({id: id}, function(err, result) {
|
||||
if(result.length == 1) {
|
||||
token_db.collection('api_links').remove({id: id}, function(e,d) {
|
||||
token_db.collection('api_token').update({id: result[0].token}, {$set: {active: true }}, function(e,d) {
|
||||
token_db.collection('api_token').update({token: result[0].token}, {$set: {active: true}}, function(e,d) {
|
||||
var data = {
|
||||
year: year,
|
||||
javascript_file: "token.min.js",
|
||||
|
||||
Reference in New Issue
Block a user