API login/logout with http header token
This commit is contained in:
@@ -10,5 +10,4 @@ class Api::ApiController < ActionController::API
|
||||
return token
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,9 +1,36 @@
|
||||
class Api::AuthenticateController < ActionController::API
|
||||
class Api::AuthenticateController < Api::ApiController
|
||||
skip_before_action :authenticate
|
||||
|
||||
def create
|
||||
emp_id = params[:emp_id]
|
||||
password = params[:password]
|
||||
|
||||
if emp_id && password
|
||||
@employee = Employee.login(emp_id, password)
|
||||
|
||||
if @employee
|
||||
render json: JSON.generate({:status => true, :session_token => @employee.token_session, :name => @employee.name, :role => @employee.role})
|
||||
else
|
||||
render json: JSON.generate({:status => false, :error_message => "Bad Emp_ID or Password."})
|
||||
end
|
||||
else
|
||||
render json: JSON.generate({:status => false, :error_message => "Input Parameters missing."})
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
logout_status = Employee.logout(params[:session_token])
|
||||
if logout_status
|
||||
render json: JSON.generate({:status => true})
|
||||
|
||||
else
|
||||
render json: JSON.generate({:status => false, :error_message => "Session Token Invalid or Missing"})
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def authenticate_params
|
||||
params.permit(:emp_id, :password, :session_token)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class Api::Restaurant::MenuController < ActionController::API
|
||||
class Api::Restaurant::MenuController < Api::ApiController
|
||||
before :authenticate_token
|
||||
|
||||
#Description
|
||||
@@ -7,7 +7,7 @@ class Api::Restaurant::MenuController < ActionController::API
|
||||
def index
|
||||
menu_detail()
|
||||
end
|
||||
|
||||
|
||||
#Description
|
||||
# This API show current order details
|
||||
# Input Params - menu_id
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class Api::Restaurant::RoomsController < ActionController::API
|
||||
class Api::Restaurant::RoomsController < Api::ApiController
|
||||
before_action :set_room, only: [:show]
|
||||
|
||||
def index
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class Api::Restaurant::SeatingsController < ActionController::API
|
||||
class Api::Restaurant::SeatingsController < Api::ApiController
|
||||
before_action :set_table, only: [:show]
|
||||
|
||||
def index
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class Api::Restaurant::TakeawaysController < ActionController::API
|
||||
class Api::Restaurant::TakeawaysController < Api::ApiController
|
||||
def index
|
||||
render json: SeatTable.order("order_by")
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Api::Restaurant::ZonesController < ActionController::API
|
||||
class Api::Restaurant::ZonesController < Api::ApiController
|
||||
|
||||
def index
|
||||
render json: Zone.includes([:tables, :rooms]).where("is_active = true")
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user