From 57d6d4f545f27efdd5f45dc8bf822b3e57e100e6 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Fri, 18 Oct 2019 09:31:05 +0500 Subject: [PATCH] Add consts User::*_PASSWORD_LENGTH --- app/interactors/authenticate_user_with_omniauth.rb | 2 +- app/models/user.rb | 3 +++ config/initializers/devise.rb | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/interactors/authenticate_user_with_omniauth.rb b/app/interactors/authenticate_user_with_omniauth.rb index 17ea635..e8784a2 100644 --- a/app/interactors/authenticate_user_with_omniauth.rb +++ b/app/interactors/authenticate_user_with_omniauth.rb @@ -28,7 +28,7 @@ private email: context.email, ).lock(true).first_or_initialize do |new_user| new_user.account = Account.new contact_list: ContactList.new - new_user.password = Devise.friendly_token 128 + new_user.password = Devise.friendly_token User::MAX_PASSWORD_LENGTH end end diff --git a/app/models/user.rb b/app/models/user.rb index eafa203..9ba0241 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,6 +1,9 @@ # frozen_string_literal: true class User < ApplicationRecord + MIN_PASSWORD_LENGTH = 8 + MAX_PASSWORD_LENGTH = 128 + devise( :confirmable, :database_authenticatable, diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 8c97ee3..4202134 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -176,7 +176,7 @@ Devise.setup do |config| # ==> Configuration for :validatable # Range for password length. - config.password_length = 8..128 + config.password_length = User::MIN_PASSWORD_LENGTH..User::MAX_PASSWORD_LENGTH # Email regex used to validate email formats. It simply asserts that # one (and only one) @ exists in the given string. This is mainly