Refactor authentication token for new study-group-based authorization

This commit is contained in:
Sebastian Serth
2022-09-20 16:24:42 +02:00
committed by Sebastian Serth
parent cb1b163b30
commit 936c11e31f
7 changed files with 30 additions and 12 deletions

View File

@ -6,11 +6,12 @@ class AuthenticationToken < ApplicationRecord
include Creation
belongs_to :study_group, optional: true
def self.generate!(user)
def self.generate!(user, study_group)
create!(
shared_secret: SecureRandom.hex(32),
user: user,
expire_at: 7.days.from_now
expire_at: 7.days.from_now,
study_group: study_group
)
end
end