summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Parecki <aaron@parecki.com>2019-10-19 21:46:02 +0100
committerAaron Parecki <aaron@parecki.com>2019-10-19 21:46:02 +0100
commit6fc7d060cb417e46b74e747aaf88a2c735ca84ec (patch)
tree4505d35b3f10d85016ce1aedca103d84f274ca02
parent873cc81ee7325752c43dd007f723b225758cf9ac (diff)
disable twitter stuff if no twitter client is set
-rw-r--r--controllers/auth.php16
-rw-r--r--views/settings.php12
2 files changed, 23 insertions, 5 deletions
diff --git a/controllers/auth.php b/controllers/auth.php
index 837cbe0..de6c8c5 100644
--- a/controllers/auth.php
+++ b/controllers/auth.php
@@ -256,6 +256,14 @@ $app->post('/auth/reset', function() use($app) {
});
$app->post('/auth/twitter', function() use($app) {
+ if(!Config::$twitterClientID) {
+ $app->response()['Content-type'] = 'application/json';
+ $app->response()->body(json_encode(array(
+ 'result' => 'error'
+ )));
+ return;
+ }
+
if($user=require_login($app, false)) {
$params = $app->request()->params();
// User just auth'd with twitter, store the access token
@@ -284,6 +292,14 @@ function getTwitterLoginURL(&$twitter) {
}
$app->get('/auth/twitter', function() use($app) {
+ if(!Config::$twitterClientID) {
+ $app->response()['Content-type'] = 'application/json';
+ $app->response()->body(json_encode(array(
+ 'result' => 'error'
+ )));
+ return;
+ }
+
$params = $app->request()->params();
if($user=require_login($app, false)) {
diff --git a/views/settings.php b/views/settings.php
index 0f2c5e3..be01303 100644
--- a/views/settings.php
+++ b/views/settings.php
@@ -88,11 +88,11 @@
</div>
-
- <h3>Twitter</h3>
- <p>Connecting a Twitter account will automatically "favorite" and "retweet" tweets on Twitter when you favorite and retweet a Twitter URL in Quill.</p>
- <input type="button" id="twitter-button" value="Checking" class="btn">
-
+ <?php if(!Config::$twitterClientID) ?>
+ <h3>Twitter</h3>
+ <p>Connecting a Twitter account will automatically "favorite" and "retweet" tweets on Twitter when you favorite and retweet a Twitter URL in Quill.</p>
+ <input type="button" id="twitter-button" value="Checking" class="btn">
+ <?php endif ?>
<h3>Backwards Compatibility</h3>
@@ -133,6 +133,7 @@
<script>
$(function(){
+ <?php if(!Config::$twitterClientID): ?>
$.getJSON("/auth/twitter", function(data){
// Check if we're already authorized with twitter
if(data && data.result == 'ok') {
@@ -153,6 +154,7 @@ $(function(){
});
}
});
+ <?php endif ?>
$("#send-html-content").click(function(){
var enabled = $(this).attr("checked") == "checked";