diff --git a/app/controllers/artist_controller.rb b/app/controllers/artist_controller.rb index 0e28a08..547b086 100644 --- a/app/controllers/artist_controller.rb +++ b/app/controllers/artist_controller.rb @@ -2,34 +2,41 @@ class ArtistController < ApplicationController require 'open-uri' def view + # Dirty auth block START unless request.session['session_id'].nil? or MainController.logged_in request.session['session_id'] redirect_to '/login' + return else if request.session['session_id'].nil? redirect_to '/login' + return end end + # Dirty auth block END if params[:name].nil? - name = '' - else - if request.request_method == 'POST' - redirect_to :action => 'view', :name => params[:name].gsub(' ', '+') - end - name = params[:name].gsub('+', ' ') - end - @artist = Artist.getByName(name) - @albums = [] - @artist.albums.each do |album| - unless album.releases.empty? - tracks = album.tracksInDb() - @albums << { - :object => album, - :tracks => tracks - } - end - end - end - + name = '' + else + if request.request_method == 'POST' + redirect_to :action => 'view', :name => params[:name].gsub(' ', '+') + end + name = params[:name].gsub('+', ' ') + end + @artist = Artist.getByName(name) + if @artist.nil? + render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false + else + @albums = [] + @artist.albums.each do |album| + unless album.releases.empty? + tracks = album.tracksInDb() + @albums << { + :object => album, + :tracks => tracks + } + end + end + end + end def autocomplete autocomplete = Artist.getLastFmAutocomplete(params[:query]) return render :nothing => true if autocomplete.nil?