1
0
mirror of https://github.com/cydrobolt/polr.git synced 2024-11-09 11:42:28 +01:00

Ignore empty , throw ApiException for all AUTH_ERROR instances

This commit is contained in:
Chaoyi Zha 2017-03-20 17:19:28 -04:00
parent e786fc2cc1
commit fc056a9364
2 changed files with 3 additions and 3 deletions

View File

@ -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) {

View File

@ -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;
}