diff --git a/.rubocop.yml b/.rubocop.yml index 92c0ca43f..438bcb4ad 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -277,5 +277,3 @@ Style/ModuleFunction: Enabled: false Style/AccessModifierIndentation: Enabled: false -Lint/Loop: - Enabled: false diff --git a/app/models/token.rb b/app/models/token.rb index 518dc66d3..084df589c 100644 --- a/app/models/token.rb +++ b/app/models/token.rb @@ -28,8 +28,11 @@ class Token < ActiveRecord::Base private def generate_token - begin + + loop do self.name = SecureRandom.hex(20) - end while Token.exists?( name: self.name ) + + break if !Token.exists?( name: self.name ) + end end end