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:
parent
e786fc2cc1
commit
fc056a9364
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user