modify app_id generator
This commit is contained in:
@@ -41,7 +41,7 @@ class Settings::EmployeesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def change_app_token
|
def change_app_token
|
||||||
@employee.app_token = @employee.generate_app_token #SecureRandom.hex(10)
|
@employee.app_token = @employee.generate_app_token
|
||||||
@employee.save
|
@employee.save
|
||||||
flash[:notice] = 'Auth Token was successfully updated.'
|
flash[:notice] = 'Auth Token was successfully updated.'
|
||||||
redirect_to settings_employee_url(@employee)
|
redirect_to settings_employee_url(@employee)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class Employee < ApplicationRecord
|
|||||||
validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true
|
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
|
validates :password, numericality: true, length: {in: 3..9}, allow_blank: true
|
||||||
|
|
||||||
before_create :generate_app_id, :generate_app_token , if: Proc.new { self.role == "application" }
|
before_save :generate_app_id, :generate_app_token , if: Proc.new { self.role == "application" }
|
||||||
# Employee Image Uploader
|
# Employee Image Uploader
|
||||||
mount_uploader :image_path, EmployeeImageUploader
|
mount_uploader :image_path, EmployeeImageUploader
|
||||||
|
|
||||||
@@ -90,15 +90,14 @@ class Employee < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def generate_app_id
|
def generate_app_id
|
||||||
# return if self.role != 'application'
|
return if self.app_id.present?
|
||||||
self.app_id = SecureRandom.urlsafe_base64(nil, false)
|
self.app_id = SecureRandom.hex(8)
|
||||||
rescue ActiveRecord::RecordNotUnique
|
rescue ActiveRecord::RecordNotUnique
|
||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_app_token
|
def generate_app_token
|
||||||
# return if self.role != 'application'
|
self.app_token = SecureRandom.hex(8)
|
||||||
self.app_token = SecureRandom.hex(10)
|
|
||||||
rescue ActiveRecord::RecordNotUnique
|
rescue ActiveRecord::RecordNotUnique
|
||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -42,17 +42,17 @@ class Printer::PrinterWorker
|
|||||||
end
|
end
|
||||||
|
|
||||||
def print(file_path, printer_destination = nil )
|
def print(file_path, printer_destination = nil )
|
||||||
# if printer_destination.nil?
|
if printer_destination.nil?
|
||||||
# printer_destination = self.printer_destination
|
printer_destination = self.printer_destination
|
||||||
# end
|
end
|
||||||
|
|
||||||
# copy = self.print_copies
|
copy = self.print_copies
|
||||||
# #Print only when printer information is not null
|
#Print only when printer information is not null
|
||||||
# if !self.printer_destination.nil?
|
if !self.printer_destination.nil?
|
||||||
# (1..copy).each do
|
(1..copy).each do
|
||||||
# page = Cups::PrintJob.new(file_path, printer_destination)
|
page = Cups::PrintJob.new(file_path, printer_destination)
|
||||||
# page.print
|
page.print
|
||||||
# end
|
end
|
||||||
# end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user