Permalink
Browse files

Render 'Login as <user email>' button for each user in the database.

  • Loading branch information...
1 parent 7daf24a commit cf209c7db73bb394d325286b20ad2f25c753917f @MitinPavel committed Jun 30, 2012
View
@@ -1,3 +1,4 @@
= TODO
-* Add I18n
+* Add I18n
+* Redirect to a root url of the parent app after a successful login
@@ -3,6 +3,11 @@
module CurrentUser
class SessionsController < ApplicationController
def new
+ @users = ::User.all
+ end
+
+ def create
+ redirect_to '/'
end
end
end
@@ -1,7 +1,7 @@
<h1>Sign In</h1>
<% @users.each do |user| %>
- <% form_tag request.url do %>
+ <%= form_tag key_sign_in_url('1234') do %>
<%= submit_tag "Login as #{user.email}" %>
<% end %>
<% end %>
@@ -2,4 +2,5 @@
mount CurrentUser::Engine => "/current_user"
resource :my_protected_page, :only => :show
+ root :to => 'my_protected_pages#show'
end
@@ -14,7 +14,6 @@ class LoginTest < ActionDispatch::IntegrationTest
assert_equal page.status_code, 200, 'Should respond with the OK http status code'
page.click_link_or_button 'Login as admin@my.app.com'
- page.click_link 'admin@my.app.com'
assert page.has_content?('Welcome admin@my.app.com')
end

0 comments on commit cf209c7

Please sign in to comment.