#18: Make playlist accessible conditional one line

This commit is contained in:
Kelvin Zhang 2015-11-08 13:45:59 +00:00
parent 8df11e9616
commit f69240064a

View file

@ -63,12 +63,8 @@ class PlaylistsController extends Controller
public function getDownload($id, $extension)
{
$playlist = Playlist::with('tracks', 'user', 'tracks.album')->find($id);
if (!$playlist || (!$playlist->is_public && !Auth::check())) {
if (!$playlist || (!$playlist->is_public && !Auth::check()) || (!$playlist->is_public && ($playlist->user_id !== Auth::user()->id))) {
App::abort(404);
} elseif (!$playlist->is_public && Auth::check()) {
if ($playlist->user_id !== Auth::user()->id) {
App::abort(404);
}
}
$format = null;