Removed unnecessary code, added authentication for clients controller for admin
This commit is contained in:
parent
fb5a13df14
commit
feb1deba84
|
@ -17,14 +17,14 @@ module Api
|
||||||
|
|
||||||
def restrict_access
|
def restrict_access
|
||||||
authenticate_or_request_with_http_token do |token, options|
|
authenticate_or_request_with_http_token do |token, options|
|
||||||
ApiKey.pluck(:access_token).include?(token)
|
ApiKey.pluck(:access_token).include?(token)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def verify_client
|
def verify_client
|
||||||
site_token = request.headers[:HTTP_X_SITETOKEN]
|
site_token = request.headers[:HTTP_X_SITETOKEN]
|
||||||
site_id = request.headers[:HTTP_X_SITEID]
|
site_id = request.headers[:HTTP_X_SITEID]
|
||||||
client_status = Client.where(site_token: site_token).where(site_id: site_id).present?
|
client_status = Client.where(site_token: site_token).where(site_id: site_id).present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_unauthorized
|
def render_unauthorized
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
class ClientsController < ApplicationController
|
class ClientsController < ApplicationController
|
||||||
before_action :set_client, only: [:show, :edit, :update, :destroy]
|
before_action :set_client, only: [:show, :edit, :update, :destroy]
|
||||||
|
before_filter :authenticate_user!, only: [:new, :edit, :create, :update, :destroy]
|
||||||
|
|
||||||
# GET /clients
|
# GET /clients
|
||||||
# GET /clients.json
|
# GET /clients.json
|
||||||
|
|
|
@ -12,9 +12,7 @@ Mtstore::Application.routes.draw do
|
||||||
scope module: :v1, constraints: ApiConstraints.new(version: 1, default: :true) do
|
scope module: :v1, constraints: ApiConstraints.new(version: 1, default: :true) do
|
||||||
resources :templates
|
resources :templates
|
||||||
resources :extensions
|
resources :extensions
|
||||||
resources :clients do
|
resources :clients
|
||||||
post 'verify_client', on: :collection
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :templates
|
resources :templates
|
||||||
|
|
Loading…
Reference in New Issue