This commit is contained in:
San Wai Lwin
2018-04-06 18:19:47 +06:30
parent 460ed991af
commit 74aa6caaab
9 changed files with 197 additions and 53 deletions

View File

@@ -16,8 +16,19 @@ class BaseOrigamiController < ActionController::Base
end
def check_user
if current_user.nil?
redirect_to root_path
token_status = false
authenticate_with_http_token do |token, options|
if token
token_status = true
session[:webview] = true
session[:session_token] = token
end
end
if !token_status
if current_user.nil?
redirect_to root_path
end
end
end
@@ -38,13 +49,9 @@ class BaseOrigamiController < ActionController::Base
#check webview
def check_mobile
status = false
authenticate_with_http_token do |token, options|
if token
session[:webview] = true
end
session[:session_token] = token
end
puts "check mobile"
puts session[:session_token]
puts session[:webview]
if session[:webview] && request.user_agent =~ /android|blackberry|iphone|ipad|ipod|iemobile|mobile|webos/i
status = true
end

View File

@@ -3,11 +3,7 @@ class Origami::HomeController < BaseOrigamiController
before_action :set_dining, only: [:show]
def index
@webview = false
if check_mobile
@webview = true
end
@webview = check_mobile
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
@@ -19,10 +15,7 @@ class Origami::HomeController < BaseOrigamiController
# origami table detail
def show
@webview = false
if check_mobile
@webview = true
end
@webview = check_mobile
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')