Skip to content

Commit

Permalink
Handle more permission settings
Browse files Browse the repository at this point in the history
  • Loading branch information
cydrobolt committed Feb 13, 2016
1 parent a36122a commit fabaedb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 6 additions & 1 deletion app/Http/Controllers/Api/ApiLinkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ public static function shortenLink(Request $request) {
$link_ip = $request->ip();
$custom_ending = $request->input('custom_ending');

try {
$formatted_link = LinkFactory::createLink($long_url, $is_secret, $custom_ending, $link_ip, $user->username);
}
catch (\Exception $e) {
abort(400, $e->getMessage());
}

$formatted_link = LinkFactory::createLink($long_url, $is_secret, $custom_ending, $link_ip, $user->username);
return self::encodeResponse($formatted_link, 'shorten', $response_type);
}

Expand Down
4 changes: 4 additions & 0 deletions app/Http/Controllers/LinkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ private function renderError($message) {
}

public function performShorten(Request $request) {
if (env('SETTING_SHORTEN_PERMISSION') && !self::isLoggedIn()) {
return redirect(route('index'))->with('error', 'You must be logged in to shorten links.');
}

$this->request = $request;

$long_url = $request->input('link-url');
Expand Down
4 changes: 2 additions & 2 deletions resources/views/setup.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
<input type='text' class='form-control' name='setting:index_redirect' placeholder='http://your-main-site.com'>
<p class='text-muted'>
If a redirect is enabled, you will need to go to
http://PATHTOPOLR/login before you can access the index
page. Leave the redirect blank to show a generic index page.
http://example.com/login before you can access the index
page.
</p>

<p>URL Ending Base:</p>
Expand Down

0 comments on commit fabaedb

Please sign in to comment.