Confirmation of registration

I have a user and admin role in my project. I created my authentication using Devise.

In my role as an administrator, I have no confirmation. In my User model, I have the following:

devise :database_authenticatable, :confirmable, :recoverable,
       :rememberable, :trackable, :validatable, :timeoutable, :registerable

# Setup accessible (or protected) attributes for your model
attr_accessible :email, :username, :prename, :surname, :phone, :street, :number, :location,
                :password, :password_confirmation

My migration looks like this:

class DeviseCreateUsers < ActiveRecord::Migration
  def self.up
    create_table(:users) do |t|
      t.database_authenticatable :null => false
      t.confirmable
      t.recoverable
      t.rememberable
      t.trackable
      t.timeoutable
      t.validateable
      t.string  :username
      t.string  :prename
      t.string  :surname
      t.string  :phone
      t.string  :street
      t.integer :number
      t.string  :location

      t.timestamps
    end

    add_index :users, :email,                :unique => true
    add_index :users, :confirmation_token,   :unique => true
    add_index :users, :reset_password_token, :unique => true
    add_index :users, :username,             :unique => true
    add_index :users, :prename,              :unique => false
    add_index :users, :surname,              :unique => false
    add_index :users, :phone,                :unique => false
    add_index :users, :street,               :unique => false
    add_index :users, :number,               :unique => false
    add_index :users, :location,             :unique => false
  end

  def self.down
    drop_table :users
  end
end

In my .rb routes, I added the following statements:

map.devise_for :admins
map.devise_for :users, :path_names => { :sign_up => "register", :sign_in => "login" }

map.root :controller => "main"

After registering the user, I was redirected to the controller mainwith a flash notification, "You have successfully registered," and I logged in. But I do not want you to log in because I have not verified my new user account yet.

If I open the console, I see a confirmation email in the logs, but I’m already logged in. I can’t explain why. Does anyone have an idea?

, , , .

+5
1

config/initializers/devise.rb , , , .

config.confirm_within = 2.days

0, .

+8

All Articles