From 42146c14aab2c110fe021347f213ed7469cf03d8 Mon Sep 17 00:00:00 2001 From: Alexis Reigel Date: Wed, 4 Oct 2017 13:57:50 +0200 Subject: ensure_runners_token on read instead of write 1. we don't want to migrate all existing groups 2. we generate the token when showing the runners page, as this is the first time that the token will be used. --- app/models/group.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/group.rb b/app/models/group.rb index c4e68fbadcf..914e5129d2c 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -44,7 +44,13 @@ class Group < Namespace validates :two_factor_grace_period, presence: true, numericality: { greater_than_or_equal_to: 0 } add_authentication_token_field :runners_token - before_save :ensure_runners_token + + # each existing group needs to have a `runners_token`. + # we do this on read since migrating all existing groups is not a feasible + # solution. + def runners_token + ensure_runners_token! + end after_create :post_create_hook after_destroy :post_destroy_hook -- cgit v1.2.1