Commit 6fff92e9 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Enable confirmable and reconfirmable modules for User

Now when you want to signup or change existing email you will be forced
to confirm that you really own this email. You get email with link to
follow in order to confirm your email address

Conflicts:
	app/models/user.rb
parent db7d1549
...@@ -43,7 +43,7 @@ require 'file_size_validator' ...@@ -43,7 +43,7 @@ require 'file_size_validator'
class User < ActiveRecord::Base class User < ActiveRecord::Base
devise :database_authenticatable, :token_authenticatable, :lockable, :async, devise :database_authenticatable, :token_authenticatable, :lockable, :async,
:recoverable, :rememberable, :trackable, :validatable, :omniauthable, :registerable :recoverable, :rememberable, :trackable, :validatable, :omniauthable, :confirmable, :registerable
attr_accessible :email, :password, :password_confirmation, :remember_me, :bio, :name, :username, attr_accessible :email, :password, :password_confirmation, :remember_me, :bio, :name, :username,
:skype, :linkedin, :twitter, :color_scheme_id, :theme_id, :force_random_password, :skype, :linkedin, :twitter, :color_scheme_id, :theme_id, :force_random_password,
......
...@@ -54,6 +54,8 @@ Devise.setup do |config| ...@@ -54,6 +54,8 @@ Devise.setup do |config|
# The realm used in Http Basic Authentication. "Application" by default. # The realm used in Http Basic Authentication. "Application" by default.
# config.http_authentication_realm = "Application" # config.http_authentication_realm = "Application"
config.reconfirmable = true
# It will change confirmation, password recovery and other workflows # It will change confirmation, password recovery and other workflows
# to behave the same regardless if the e-mail provided was right or wrong. # to behave the same regardless if the e-mail provided was right or wrong.
# Does not affect registerable. # Does not affect registerable.
......
class AddConfirmableToUsers < ActiveRecord::Migration
def self.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
User.update_all(confirmed_at: Time.now)
end
def self.down
remove_column :users, :confirmation_token, :confirmed_at, :confirmation_sent_at
remove_column :users, :unconfirmed_email
end
end
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20131005191208) do ActiveRecord::Schema.define(:version => 20131009115346) do
create_table "deploy_keys_projects", :force => true do |t| create_table "deploy_keys_projects", :force => true do |t|
t.integer "deploy_key_id", :null => false t.integer "deploy_key_id", :null => false
...@@ -284,10 +284,15 @@ ActiveRecord::Schema.define(:version => 20131005191208) do ...@@ -284,10 +284,15 @@ ActiveRecord::Schema.define(:version => 20131005191208) do
t.datetime "password_expires_at" t.datetime "password_expires_at"
t.integer "created_by_id" t.integer "created_by_id"
t.string "avatar" t.string "avatar"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "unconfirmed_email"
end end
add_index "users", ["admin"], :name => "index_users_on_admin" add_index "users", ["admin"], :name => "index_users_on_admin"
add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token", :unique => true add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token", :unique => true
add_index "users", ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true
add_index "users", ["email"], :name => "index_users_on_email", :unique => true add_index "users", ["email"], :name => "index_users_on_email", :unique => true
add_index "users", ["extern_uid", "provider"], :name => "index_users_on_extern_uid_and_provider", :unique => true add_index "users", ["extern_uid", "provider"], :name => "index_users_on_extern_uid_and_provider", :unique => true
add_index "users", ["name"], :name => "index_users_on_name" add_index "users", ["name"], :name => "index_users_on_name"
......
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