devise register confirmation

Posted by mattherick on Stack Overflow See other posts from Stack Overflow or by mattherick
Published on 2010-05-02T17:33:25Z Indexed on 2010/05/02 17:38 UTC
Read the original article Hit count: 243

Filed under:
|
|

hello!

i have a user and an admin role in my project. i created my authentification with devise, really nice and goot tool for handling the authentification. in my admin role i don´t have any confirmation or something like that. it is really simple and doesn´t make problems. but in my user model i have following things:

model:

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

and few validations, but they aren´t relevant this time.

my migration looks like following one:

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

into my route.rb I added following statements: map.devise_for :admins map.devise_for :users, :path_names => { :sign_up => "register", :sign_in => "login" }

map.root :controller => "main"

and now my problem.. if I register a new user, I fill in all my data in the register form and submit it. After that I get redirected to the controller main with the flash-notice "You have signed up successfully." And I am logged in. But I don´t want to be logged in, because I don´t have confirmed my new user account yet. If I open the console I see the last things in the logs and there I see the confirmation-mail and the text and all stuff, but I am already logged in... I can´t explain why, ... does somebody of you have an idea? If I copy out the confirmation-token from the logs and confirm my account, I can log in, but if I don´t confirm, I also can log in..

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby