5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-17 17:16:22 +00:00

feat: agregada columna token a model rol #13903
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
jazzari 2023-07-31 17:32:14 -03:00
parent 06ebb63d93
commit 579e177684
3 changed files with 20 additions and 0 deletions

View file

@ -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

View file

@ -0,0 +1,5 @@
class AddTokenToRoles < ActiveRecord::Migration[6.1]
def change
add_column :roles, :token, :text
end
end

View file

@ -0,0 +1,5 @@
class ChangeTokenName < ActiveRecord::Migration[6.1]
def change
rename_column :roles, :token, :token_cyphertext
end
end