Commit 6fff92e984c8977bb1b8d5424e8b81796e2ccb07
1 parent
db7d1549
Exists in
master
and in
4 other branches
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
Showing
4 changed files
with
25 additions
and
3 deletions
Show diff stats
app/models/user.rb
... | ... | @@ -43,7 +43,7 @@ require 'file_size_validator' |
43 | 43 | |
44 | 44 | class User < ActiveRecord::Base |
45 | 45 | devise :database_authenticatable, :token_authenticatable, :lockable, :async, |
46 | - :recoverable, :rememberable, :trackable, :validatable, :omniauthable, :registerable | |
46 | + :recoverable, :rememberable, :trackable, :validatable, :omniauthable, :confirmable, :registerable | |
47 | 47 | |
48 | 48 | attr_accessible :email, :password, :password_confirmation, :remember_me, :bio, :name, :username, |
49 | 49 | :skype, :linkedin, :twitter, :color_scheme_id, :theme_id, :force_random_password, |
... | ... | @@ -398,4 +398,4 @@ class User < ActiveRecord::Base |
398 | 398 | |
399 | 399 | self |
400 | 400 | end |
401 | -end | |
402 | 401 | \ No newline at end of file |
402 | +end | ... | ... |
config/initializers/devise.rb
... | ... | @@ -54,6 +54,8 @@ Devise.setup do |config| |
54 | 54 | # The realm used in Http Basic Authentication. "Application" by default. |
55 | 55 | # config.http_authentication_realm = "Application" |
56 | 56 | |
57 | + config.reconfirmable = true | |
58 | + | |
57 | 59 | # It will change confirmation, password recovery and other workflows |
58 | 60 | # to behave the same regardless if the e-mail provided was right or wrong. |
59 | 61 | # Does not affect registerable. | ... | ... |
... | ... | @@ -0,0 +1,15 @@ |
1 | +class AddConfirmableToUsers < ActiveRecord::Migration | |
2 | + def self.up | |
3 | + add_column :users, :confirmation_token, :string | |
4 | + add_column :users, :confirmed_at, :datetime | |
5 | + add_column :users, :confirmation_sent_at, :datetime | |
6 | + add_column :users, :unconfirmed_email, :string | |
7 | + add_index :users, :confirmation_token, unique: true | |
8 | + User.update_all(confirmed_at: Time.now) | |
9 | + end | |
10 | + | |
11 | + def self.down | |
12 | + remove_column :users, :confirmation_token, :confirmed_at, :confirmation_sent_at | |
13 | + remove_column :users, :unconfirmed_email | |
14 | + end | |
15 | +end | ... | ... |
db/schema.rb
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | # |
12 | 12 | # It's strongly recommended to check this file into your version control system. |
13 | 13 | |
14 | -ActiveRecord::Schema.define(:version => 20131005191208) do | |
14 | +ActiveRecord::Schema.define(:version => 20131009115346) do | |
15 | 15 | |
16 | 16 | create_table "deploy_keys_projects", :force => true do |t| |
17 | 17 | t.integer "deploy_key_id", :null => false |
... | ... | @@ -284,10 +284,15 @@ ActiveRecord::Schema.define(:version => 20131005191208) do |
284 | 284 | t.datetime "password_expires_at" |
285 | 285 | t.integer "created_by_id" |
286 | 286 | t.string "avatar" |
287 | + t.string "confirmation_token" | |
288 | + t.datetime "confirmed_at" | |
289 | + t.datetime "confirmation_sent_at" | |
290 | + t.string "unconfirmed_email" | |
287 | 291 | end |
288 | 292 | |
289 | 293 | add_index "users", ["admin"], :name => "index_users_on_admin" |
290 | 294 | add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token", :unique => true |
295 | + add_index "users", ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true | |
291 | 296 | add_index "users", ["email"], :name => "index_users_on_email", :unique => true |
292 | 297 | add_index "users", ["extern_uid", "provider"], :name => "index_users_on_extern_uid_and_provider", :unique => true |
293 | 298 | add_index "users", ["name"], :name => "index_users_on_name" | ... | ... |