mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-17 17:46:22 +00:00
feat: agregada columna token a model rol #13903
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
parent
06ebb63d93
commit
579e177684
3 changed files with 20 additions and 0 deletions
|
@ -14,6 +14,9 @@ class Rol < ApplicationRecord
|
|||
|
||||
validates_inclusion_of :rol, in: ROLES
|
||||
|
||||
encrypts :token
|
||||
before_save :add_token_if_missing!
|
||||
|
||||
def invitade?
|
||||
rol == INVITADE
|
||||
end
|
||||
|
@ -25,4 +28,11 @@ class Rol < ApplicationRecord
|
|||
def self.role?(rol)
|
||||
ROLES.include? rol
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Asegurarse que tenga un token
|
||||
def add_token_if_missing!
|
||||
self.token ||= SecureRandom.hex(64)
|
||||
end
|
||||
end
|
||||
|
|
5
db/migrate/20230731195050_add_token_to_roles.rb
Normal file
5
db/migrate/20230731195050_add_token_to_roles.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class AddTokenToRoles < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :roles, :token, :text
|
||||
end
|
||||
end
|
5
db/migrate/20230731202003_change_token_name.rb
Normal file
5
db/migrate/20230731202003_change_token_name.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class ChangeTokenName < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
rename_column :roles, :token, :token_cyphertext
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue