Merge branch 'foodcourt' of gitlab.com:code2lab/SXRestaurant into foodcourt
This commit is contained in:
@@ -40,8 +40,8 @@ class Settings::EmployeesController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def change_auth_token
|
||||
@employee.auth_token = SecureRandom.hex(10)
|
||||
def change_app_token
|
||||
@employee.app_token = @employee.generate_app_token #SecureRandom.hex(10)
|
||||
@employee.save
|
||||
flash[:notice] = 'Auth Token was successfully updated.'
|
||||
redirect_to settings_employee_url(@employee)
|
||||
@@ -78,6 +78,6 @@ class Settings::EmployeesController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def employee_params
|
||||
params.require(:employee).permit(:name, :role, :is_active, :emp_id, :password,:order_queue_station_id, :image_path, :app_id, :auth_token)
|
||||
params.require(:employee).permit(:name, :role, :is_active, :emp_id, :password,:order_queue_station_id, :image_path, :app_id, :app_token)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,7 +12,7 @@ class Employee < ApplicationRecord
|
||||
validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true
|
||||
validates :password, numericality: true, length: {in: 3..9}, allow_blank: true
|
||||
|
||||
before_create :generate_app_id, :generate_auth_token #, if: Proc.new { self.role == "app" }
|
||||
before_create :generate_app_id, :generate_app_token , if: Proc.new { self.role == "application" }
|
||||
# Employee Image Uploader
|
||||
mount_uploader :image_path, EmployeeImageUploader
|
||||
|
||||
@@ -93,12 +93,16 @@ class Employee < ApplicationRecord
|
||||
end
|
||||
|
||||
def generate_app_id
|
||||
return if self.role != 'app'
|
||||
# return if self.role != 'application'
|
||||
self.app_id = SecureRandom.urlsafe_base64(nil, false)
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
retry
|
||||
end
|
||||
|
||||
def generate_auth_token
|
||||
return if self.role != 'app'
|
||||
self.auth_token = SecureRandom.hex(10)
|
||||
def generate_app_token
|
||||
# return if self.role != 'application'
|
||||
self.app_token = SecureRandom.hex(10)
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
retry
|
||||
end
|
||||
end
|
||||
|
||||
@@ -54,22 +54,22 @@
|
||||
<th><%= t("views.right_panel.detail.employee_photo") %></th>
|
||||
<td><%= image_tag @employee.image_path, :size => '200x200'%></td>
|
||||
</tr>
|
||||
<% if @employee.role == 'app' %>
|
||||
<% if @employee.role == 'application' %>
|
||||
<tr>
|
||||
<th><%= t("views.right_panel.detail.employee_app_id") %></th>
|
||||
<td><%= @employee.app_id %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><%= t("views.right_panel.detail.employee_auth_token") %></th>
|
||||
<td><%= @employee.auth_token %></td>
|
||||
<th><%= t("views.right_panel.detail.employee_app_token") %></th>
|
||||
<td><%= @employee.app_token %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td>
|
||||
<%= link_to t("views.btn.edit"), edit_settings_employee_path(@employee),:class => 'btn btn-primary btn-lg waves-effect' %>
|
||||
<% if @employee.role == 'app' %>
|
||||
<%= link_to t("views.btn.change_auth_token"), settings_change_auth_token_url(id: @employee.id), class: 'btn btn-primary btn-lg waves-effect' %>
|
||||
<% if @employee.role == 'application' %>
|
||||
<%= link_to t("views.btn.change_app_token"), settings_change_app_token_url(id: @employee.id), class: 'btn btn-primary btn-lg waves-effect' %>
|
||||
<% end %>
|
||||
<%if @employee.role != "administrator"%>
|
||||
<button class="delete btn btn-danger btn-sm waves-effect" data-ref="<%=settings_employee_path(@employee)%>" data-method="delete">
|
||||
|
||||
@@ -4,28 +4,28 @@ class ActionController::Base
|
||||
private
|
||||
|
||||
def lookup_domain
|
||||
# if request.subdomains.last && request.subdomains.last != "www" && ENV["SERVER_CODE"] = "cloud"
|
||||
# from = request.host
|
||||
# @license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
|
||||
# if (!@license.nil?)
|
||||
# logger.info "Location - " + @license.dbschema
|
||||
# ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||
# # authenticate_session_token
|
||||
# # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
|
||||
# else
|
||||
# # reconnect_default_db
|
||||
# logger.info 'License is nil'
|
||||
# # redirect_to root_url(:host => request.domain) + "store_error"
|
||||
# render :json => [{ status: false, message: 'Invalid Access!'}]
|
||||
# end
|
||||
# else
|
||||
# # check for license file
|
||||
# if check_license
|
||||
# current_license(ENV["SX_PROVISION_URL"])
|
||||
# else
|
||||
# redirect_to activate_path
|
||||
# end
|
||||
# end
|
||||
if request.subdomains.last && request.subdomains.last != "www" && ENV["SERVER_CODE"] = "cloud"
|
||||
from = request.host
|
||||
@license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
|
||||
if (!@license.nil?)
|
||||
logger.info "Location - " + @license.dbschema
|
||||
ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||
# authenticate_session_token
|
||||
# logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
|
||||
else
|
||||
# reconnect_default_db
|
||||
logger.info 'License is nil'
|
||||
# redirect_to root_url(:host => request.domain) + "store_error"
|
||||
render :json => [{ status: false, message: 'Invalid Access!'}]
|
||||
end
|
||||
else
|
||||
# check for license file
|
||||
if check_license
|
||||
current_license(ENV["SX_PROVISION_URL"])
|
||||
else
|
||||
redirect_to activate_path
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ en:
|
||||
del: "DEL"
|
||||
clr: "CLR"
|
||||
assign: "ASSIGN"
|
||||
change_auth_token: "Change Auth Token"
|
||||
change_app_token: "Change App Token"
|
||||
|
||||
print_order_summary: "Print Order Summary"
|
||||
memeber_card: "Member Card"
|
||||
@@ -680,7 +680,7 @@ en:
|
||||
delete_btn_txt: "to delete "
|
||||
update_btn_txt: "to update "
|
||||
employee_app_id: "App ID"
|
||||
employee_auth_token: "Auth Token"
|
||||
employee_app_token: "App Token"
|
||||
|
||||
helpers:
|
||||
page_entries_info:
|
||||
|
||||
@@ -433,7 +433,7 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
end
|
||||
#employees
|
||||
resources :employees
|
||||
get '/:id/change_auth_token' => 'employees#change_auth_token', as: 'change_auth_token'
|
||||
get '/:id/change_app_token' => 'employees#change_app_token', as: 'change_app_token'
|
||||
|
||||
#menu
|
||||
resources :menus do
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class ChangeColumnAuthTokenToAppToken < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
rename_column :employees, :auth_token, :app_token
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user