Skip to content

Commit

Permalink
AutoLogin: All responses now update the framework cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
Zapotek committed Jul 9, 2013
1 parent 15921fc commit 8bbb127
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,8 @@
## _Under development_

- `Session#find_login_form` -- Stores cookies set by the page containing the login form.
- Plugins
- AutoLogin -- All responses now update the framework cookies.

## Version 0.4.3 _(July 06, 2013)_

Expand Down
2 changes: 1 addition & 1 deletion plugins/autologin.rb
Expand Up @@ -65,7 +65,7 @@ def run
check_url = res.effective_url
body = if res.redirection?
check_url = to_absolute( res.location )
http.get( check_url, async: false, follow_location: true ).response.body
http.get( check_url, async: false, update_cookies: true, follow_location: true ).response.body
else
res.body
end
Expand Down
4 changes: 3 additions & 1 deletion spec/support/servers/plugins/autologin.rb
Expand Up @@ -14,6 +14,8 @@
end

get '/login' do
cookies[:preserve] = 'this'

<<-HTML
<form method='post' name='login_form' action="/login">
<input name='username' value='' />
Expand All @@ -25,7 +27,7 @@

post '/login' do
if params['username'] == 'john' && params['password'] == 'doe' &&
params['token'] == 'secret!'
params['token'] == 'secret!' && cookies[:preserve] == 'this'
cookies[:success] = true
redirect '/'
else
Expand Down

0 comments on commit 8bbb127

Please sign in to comment.