API login/logout with http header token

This commit is contained in:
Min Zeya Phyo
2017-04-15 12:52:40 +06:30
parent 5ca9615e38
commit 355f4fadb0
11 changed files with 67 additions and 86 deletions

View File

@@ -1,28 +1,35 @@
class Api::Restaurant::MenuController < Api::ApiController
before :authenticate_token
#Description
# Pull the default menu details and also other available (active) menus
# Input Params - order_id
def index
menu_detail()
@menu = menu_detail()
end
#Description
# This API show current order details
# Input Params - menu_id
def show
menu_detail(params[:menu_id])
@menu = menu_detail(params[:id])
end
private
def menu_detail
def menu_detail (menu_id)
if (menu_id)
#Pull this menu
menu = Menu.find_by_id(menu_id)
return menu
else
#Pull Default menu
end
end
def menu_params()
params.permit(:id)
end

View File

@@ -1,27 +0,0 @@
class Api::Restaurant::RoomsController < Api::ApiController
before_action :set_room, only: [:show]
def index
render json: Room.active.order("order_by")
end
# Description
# This API full the current status of table and if there is order attached to this table - Order_ID will be return
# Output
# status: {available, cleaning, occupied, reserved}, order_id : <current_order_id>
def show
end
def bill
end
def move
end
private
# Use callbacks to share common setup or constraints between actions.
def set_room
@table = Room.find(params[:id])
end
end

View File

@@ -1,28 +0,0 @@
class Api::Restaurant::SeatingsController < Api::ApiController
before_action :set_table, only: [:show]
def index
render json: Table.active.order("order_by")
end
# Description
# This API full the current status of table and if there is order attached to this table - Order_ID will be return
# Output
# status: {available, cleaning, occupied, reserved}, order_id : <current_order_id>
def show
end
def bill
end
def move
end
private
# Use callbacks to share common setup or constraints between actions.
def set_table
@table = Table.find(params[:id])
end
end

View File

@@ -1,7 +1,16 @@
class Api::Restaurant::ZonesController < Api::ApiController
def index
render json: Zone.includes([:tables, :rooms]).where("is_active = true")
if (params[:filter] && params[:filter] = "all" )
@all_tables = Table.active
@all_rooms = Room.active
else
@zones = Zone.includes([:tables, :rooms]).where("is_active = true")
end
end
private
def zones_params
params.permit(:filter)
end
end

View File

@@ -16,8 +16,11 @@ module TokenVerification
def authenticate_token
authenticate_with_http_token do |token, options|
#@current_user = User.find_by(api_key: token)
@user = Employee.authenticate_token(token)
Rails.logger.debug "token - " + token.to_s
@user = Employee.authenticate_by_token(token)
if @user
return true
#Maybe log - login?
end