From eed2ef5446e3c0d1e37cf68b8bec9a09bf4b6ecf Mon Sep 17 00:00:00 2001 From: riggraz Date: Mon, 23 Sep 2019 15:52:00 +0200 Subject: [PATCH] User email confirmation is now optional --- .env-example | 4 +++- app/models/user.rb | 5 +++-- config/application.rb | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.env-example b/.env-example index db95ec67..57194182 100644 --- a/.env-example +++ b/.env-example @@ -3,4 +3,6 @@ ENVIRONMENT=development POSTGRES_USER=yourusernamehere POSTGRES_PASSWORD=yourpasswordhere -APP_NAME="You App Name Here" \ No newline at end of file +APP_NAME="You App Name Here" + +EMAIL_CONFIRMATION=0 \ No newline at end of file diff --git a/app/models/user.rb b/app/models/user.rb index 6c344094..8f45c831 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,7 +1,8 @@ class User < ApplicationRecord devise :database_authenticatable, :registerable, - :recoverable, :rememberable, :validatable, - :confirmable + :recoverable, :rememberable, :validatable + + self.send(:devise, :confirmable) if Rails.application.email_confirmation? has_many :comments diff --git a/config/application.rb b/config/application.rb index 9181e518..e9e3b3cf 100644 --- a/config/application.rb +++ b/config/application.rb @@ -19,5 +19,9 @@ module App def name ENV["APP_NAME"] end + + def email_confirmation? + ENV["EMAIL_CONFIRMATION"] == "1" + end end end