Commit 8680bb36 authored by PiTrem's avatar PiTrem
Browse files

user devise: add confirmable

parent 329dc759
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable, :trackable, :validatable
has_one :profile, dependent: :destroy
......@@ -75,4 +75,19 @@ Rails.application.configure do
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter =
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { host: ENV['SMTP_HOST']}
config.action_mailer.smtp_settings = {
:address => ENV["SMTP_ADDRESS"],
:port => ENV["SMTP_PORT"],
:user_name => ENV['SMTP_USERNAME'],
:domain => ENV['SMTP_DOMAIN'],
:password => ENV['SMTP_PASSWORD'],
:authentication => ENV['SMTP_AUTH'] && ENV['SMTP_AUTH'].to_sym,
:enable_starttls_auto => ENV['SMTP_TLS'] && ENV['SMTP_TLS'].match(/true/)
:openssl_verify_mode => ENV['SMTP_SSL_MODE'],
......@@ -12,8 +12,8 @@ Devise.setup do |config|
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class
# with default "from" parameter.
config.mailer_sender = ''
config.mailer_sender = ENV['DEVISE_SENDER'] ||
# Configure the class responsible to send e-mails.
# config.mailer = 'Devise::Mailer'
......@@ -107,7 +107,7 @@ Devise.setup do |config|
# able to access the website for two days without confirming their account,
# access will be blocked just in the third day. Default is 0.days, meaning
# the user cannot access the website without confirming their account.
# config.allow_unconfirmed_access_for = 2.days
config.allow_unconfirmed_access_for = 0.days
# A period that the user is allowed to confirm their account before their
# token becomes invalid. For example, if set to 3.days, the user can confirm
class AddConfirmableToDevise < ActiveRecord::Migration
def up
add_column :users, :confirmation_token, :string
add_column :users, :confirmed_at, :datetime
add_column :users, :confirmation_sent_at, :datetime
add_column :users, :unconfirmed_email, :string
add_index :users, :confirmation_token, unique: true
execute("UPDATE users SET confirmed_at = NOW()")
def down
remove_columns :users, :confirmation_token, :confirmed_at, :confirmation_sent_at
remove_columns :users, :unconfirmed_email
......@@ -554,6 +554,10 @@ ActiveRecord::Schema.define(version: 20170215133510) do
t.boolean "is_templates_moderator", default: false, null: false
t.string "type", default: "Person"
t.string "reaction_name_prefix", limit: 3, default: "R"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "unconfirmed_email"
t.hstore "layout", default: {"sample"=>"1", "screen"=>"4", "reaction"=>"2", "wellplate"=>"3", "research_plan"=>"5"}, null: false
namespace :data do
desc "data modifications for 20161201152801_add_confirmable_to_devise"
# confirm existing users (not mandatory)
task ver_20161201152801: :environment do
time_now =
User.all.each do |user|
user.confirmed_at = time_now!
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment