added AuthenticationToken model, updated some restrictions for the authentication token table, added dependent destroy to the user model for authentication tokens
This commit is contained in:

committed by
Sebastian Serth

parent
fe410a5306
commit
d64daadd21
14
app/models/authentication_token.rb
Normal file
14
app/models/authentication_token.rb
Normal file
@ -0,0 +1,14 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'securerandom'
|
||||
|
||||
class AuthenticationToken < ApplicationRecord
|
||||
include Creation
|
||||
def self.generate!(user)
|
||||
create!(
|
||||
shared_secret: SecureRandom.hex(32),
|
||||
user: user,
|
||||
expire_at: 7.days.from_now
|
||||
)
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user