Fix coding standards in application
This commit is contained in:
parent
aca19eb51f
commit
e6f6475705
@ -1,26 +1,28 @@
|
||||
class API::ApplicationController < ApplicationController
|
||||
skip_before_filter :verify_authenticity_token
|
||||
skip_before_filter :authenticate!, only: [:cor_preflight]
|
||||
module API
|
||||
class ApplicationController < ::ApplicationController
|
||||
skip_before_filter :verify_authenticity_token
|
||||
skip_before_filter :authenticate!, only: [:cor_preflight]
|
||||
|
||||
before_filter :cor_filter
|
||||
before_filter :cor_filter
|
||||
|
||||
def cor_filter
|
||||
headers['Access-Control-Allow-Origin'] = request.headers['Origin'] ?
|
||||
request.headers['Origin'] :
|
||||
''
|
||||
headers['Access-Control-Allow-Credentials'] = 'true'
|
||||
headers['Access-Control-Expose-Headers'] = 'Content-Length'
|
||||
end
|
||||
def cor_filter
|
||||
headers['Access-Control-Allow-Origin'] = request.headers['Origin'] ?
|
||||
request.headers['Origin'] :
|
||||
''
|
||||
headers['Access-Control-Allow-Credentials'] = 'true'
|
||||
headers['Access-Control-Expose-Headers'] = 'Content-Length'
|
||||
end
|
||||
|
||||
def cor_preflight
|
||||
headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE'
|
||||
headers['Access-Control-Allow-Headers'] =
|
||||
'Content-Type, Content-Length, X-Requested-With'
|
||||
def cor_preflight
|
||||
headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE'
|
||||
headers['Access-Control-Allow-Headers'] =
|
||||
'Content-Type, Content-Length, X-Requested-With'
|
||||
|
||||
head :ok
|
||||
end
|
||||
head :ok
|
||||
end
|
||||
|
||||
def authenticate!
|
||||
head :unauthorized if current_user.nil?
|
||||
def authenticate!
|
||||
head :unauthorized if current_user.nil?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,12 +1,14 @@
|
||||
class API::PlaylistsController < API::ApplicationController
|
||||
respond_to :json
|
||||
module API
|
||||
class PlaylistsController < ApplicationController
|
||||
respond_to :json
|
||||
|
||||
def index
|
||||
@playlists = Playlist.all
|
||||
end
|
||||
def index
|
||||
@playlists = Playlist.all
|
||||
end
|
||||
|
||||
def create
|
||||
@playlist = current_user.playlists.build(params[:playlist].slice(:name))
|
||||
@playlist.save
|
||||
def create
|
||||
@playlist = current_user.playlists.build(params[:playlist].slice(:name))
|
||||
@playlist.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,14 +1,16 @@
|
||||
class API::SessionsController < API::ApplicationController
|
||||
skip_before_filter :authenticate!, only: [:create]
|
||||
module API
|
||||
class SessionsController < ApplicationController
|
||||
skip_before_filter :authenticate!, only: [:create]
|
||||
|
||||
def create
|
||||
user = User.find_by_email(params[:session][:email])
|
||||
def create
|
||||
user = User.find_by_email(params[:session][:email])
|
||||
|
||||
if !user.try(:authenticate?, params[:session][:password])
|
||||
return render json: '', status: :not_found
|
||||
unless user.try(:authenticate?, params[:session][:password])
|
||||
return render json: '', status: :not_found
|
||||
end
|
||||
|
||||
@user = user
|
||||
self.current_user = @user
|
||||
end
|
||||
|
||||
@user = user
|
||||
self.current_user = @user
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +1,9 @@
|
||||
class API::SoundsController < API::ApplicationController
|
||||
# FIXME: add some tests!
|
||||
def show
|
||||
sound = Sound.find params[:id]
|
||||
send_file sound.path, type: sound.mime_type
|
||||
module API
|
||||
class SoundsController < ApplicationController
|
||||
# FIXME: add some tests!
|
||||
def show
|
||||
sound = Sound.find params[:id]
|
||||
send_file sound.path, type: sound.mime_type
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,5 +1,7 @@
|
||||
class API::TracksController < API::ApplicationController
|
||||
def index
|
||||
@tracks = Track.all
|
||||
module API
|
||||
class TracksController < ApplicationController
|
||||
def index
|
||||
@tracks = Track.all
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user