change cloumn auth_token to app_token in employees

This commit is contained in:
Zin Moe
2020-01-14 17:23:52 +06:30
parent 406a18d1d6
commit 93928aedd5
6 changed files with 23 additions and 16 deletions

View File

@@ -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,13 +93,15 @@ 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