plataformatec/devise — Issue #1406: Clearing session after sign_in
Author: graffzon
Created: 2011-10-29 11:40:28+00:00
State: open

Hi, guys. I have strange bug. I really don't know is it issue of devise or smth in my project.
I have sign_in form in standart /views/devise/sessions/new - it works good.

But now I need to use sign_in form in index page. I added it to partial:

= form_tag user_session_path do
.loginlogin
= text_field_tag 'user[login]', nil, :size => 13, :placeholder => 'Логин или e-mail'
.underfields
= check_box_tag 'user[dont_remember_me]'
= label_tag 'Чужой компьютер'
.loginpassword
= password_field_tag 'user[password]', nil, :size => 13, :placeholder => 'Пароль'
.underfields{:style => 'margin-top:10px;'}
= link_to "Забыли пароль?", 'user[new_user_password]'
.loginbutton
= submit_tag "Войти", :class => "signinbutton"

Also added following to helper of controller, where I need authorization:

def resource_name
:user
end

def resource
@resource ||= User.new
end

def devise_mapping
@devise_mapping ||= Devise.mappings[:user]
end

But when I trying to authorize - I redirecting back to index page nonauthorized.
I inserted deubgger in devise and see, that request goes ok, in devise it sign_in, current_user give true information. But after that Devise#SessionController making redirect to my root_page and there is NO current_user. Also, certanly, no authorization. Checked - session is empty.

What do you think about that?

Thanks anyway)