Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/cydrobolt/polr.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChaoyi Zha <summermontreal@gmail.com>2017-03-21 00:19:28 +0300
committerChaoyi Zha <summermontreal@gmail.com>2017-03-21 00:19:28 +0300
commitfc056a9364b6bcb0116d4407d002f75a768e3152 (patch)
tree9ef977e9bc86cc6af59d9273210895a2307590ec
parente786fc2cc1054bea7eca0b58e2c47dc3bbdd5b54 (diff)
Ignore empty , throw ApiException for all AUTH_ERROR instances
-rw-r--r--app/Factories/LinkFactory.php4
-rw-r--r--app/Http/Middleware/ApiMiddleware.php2
2 files changed, 3 insertions, 3 deletions
diff --git a/app/Factories/LinkFactory.php b/app/Factories/LinkFactory.php
index 21a3bc7..2320613 100644
--- a/app/Factories/LinkFactory.php
+++ b/app/Factories/LinkFactory.php
@@ -55,14 +55,14 @@ class LinkFactory {
looks like a shortened URL.');
}
- if (!$is_secret && (!isset($custom_ending)) && (LinkHelper::longLinkExists($long_url) !== false)) {
+ if (!$is_secret && (!isset($custom_ending) || $custom_ending === '') && (LinkHelper::longLinkExists($long_url) !== false)) {
// if link is not specified as secret, is non-custom, and
// already exists in Polr, lookup the value and return
$existing_link = LinkHelper::longLinkExists($long_url);
return self::formatLink($existing_link);
}
- if (isset($custom_ending)) {
+ if (isset($custom_ending) && $custom_ending !== '') {
// has custom ending
$ending_conforms = LinkHelper::validateEnding($custom_ending);
if (!$ending_conforms) {
diff --git a/app/Http/Middleware/ApiMiddleware.php b/app/Http/Middleware/ApiMiddleware.php
index 6c4e5eb..bbab80c 100644
--- a/app/Http/Middleware/ApiMiddleware.php
+++ b/app/Http/Middleware/ApiMiddleware.php
@@ -33,7 +33,7 @@ class ApiMiddleware {
->first();
if (!$user) {
- abort(401, "Invalid authentication token.");
+ throw new ApiException('AUTH_ERROR', 'Authentication token required.', 401, $response_type);
}
$username = $user->username;
}