Refactor authentication token for new study-group-based authorization
This commit is contained in:

committed by
Sebastian Serth

parent
cb1b163b30
commit
936c11e31f
@ -6,6 +6,13 @@ FactoryBot.define do
|
||||
shared_secret { SecureRandom.hex(32) }
|
||||
expire_at { 7.days.from_now }
|
||||
|
||||
after(:create) do |auth_token|
|
||||
# Do not change anything if a study group was provided explicitly or user has no study groups
|
||||
next if auth_token.study_group_id.present? || auth_token.user.study_groups.blank?
|
||||
|
||||
auth_token.update!(study_group_id: auth_token.user.study_groups.first.id)
|
||||
end
|
||||
|
||||
trait :invalid do
|
||||
expire_at { 8.days.ago }
|
||||
end
|
||||
|
Reference in New Issue
Block a user