Revision 11289
Added by Jean-Philippe Lang over 12 years ago
trunk/app/controllers/account_controller.rb | ||
---|---|---|
38 | 38 |
|
39 | 39 |
# Log out current user and redirect to welcome page |
40 | 40 |
def logout |
41 |
logout_user |
|
42 |
redirect_to home_url |
|
41 |
if User.current.anonymous? |
|
42 |
redirect_to home_url |
|
43 |
elsif request.post? |
|
44 |
logout_user |
|
45 |
redirect_to home_url |
|
46 |
end |
|
47 |
# display the logout form |
|
43 | 48 |
end |
44 | 49 |
|
45 | 50 |
# Lets user choose a new password |
trunk/app/views/account/logout.html.erb | ||
---|---|---|
1 |
<%= form_tag(signout_path) do %> |
|
2 |
<p><%= submit_tag l(:label_logout) %></p> |
|
3 |
<% end %> |
|
0 | 4 |
trunk/lib/redmine.rb | ||
---|---|---|
208 | 208 |
menu.push :login, :signin_path, :if => Proc.new { !User.current.logged? } |
209 | 209 |
menu.push :register, :register_path, :if => Proc.new { !User.current.logged? && Setting.self_registration? } |
210 | 210 |
menu.push :my_account, { :controller => 'my', :action => 'account' }, :if => Proc.new { User.current.logged? } |
211 |
menu.push :logout, :signout_path, :if => Proc.new { User.current.logged? } |
|
211 |
menu.push :logout, :signout_path, :html => {:method => 'post'}, :if => Proc.new { User.current.logged? }
|
|
212 | 212 |
end |
213 | 213 |
|
214 | 214 |
Redmine::MenuManager.map :application_menu do |menu| |
trunk/test/functional/account_controller_test.rb | ||
---|---|---|
80 | 80 |
assert_response 302 |
81 | 81 |
end |
82 | 82 |
|
83 |
def test_get_logout_should_not_logout |
|
84 |
@request.session[:user_id] = 2 |
|
85 |
get :logout |
|
86 |
assert_response :success |
|
87 |
assert_template 'logout' |
|
88 |
|
|
89 |
assert_equal 2, @request.session[:user_id] |
|
90 |
end |
|
91 |
|
|
83 | 92 |
def test_logout |
84 | 93 |
@request.session[:user_id] = 2 |
85 |
get :logout
|
|
94 |
post :logout
|
|
86 | 95 |
assert_redirected_to '/' |
87 | 96 |
assert_nil @request.session[:user_id] |
88 | 97 |
end |
... | ... | |
91 | 100 |
@controller.expects(:reset_session).once |
92 | 101 |
|
93 | 102 |
@request.session[:user_id] = 2 |
94 |
get :logout
|
|
103 |
post :logout
|
|
95 | 104 |
assert_response 302 |
96 | 105 |
end |
97 | 106 |
|
trunk/test/functional/welcome_controller_test.rb | ||
---|---|---|
85 | 85 |
:content => %r{warnLeavingUnsaved} |
86 | 86 |
end |
87 | 87 |
|
88 |
def test_logout_link_should_post |
|
89 |
@request.session[:user_id] = 2 |
|
90 |
|
|
91 |
get :index |
|
92 |
assert_select 'a[href=/https/www.redmine.org/logout][data-method=post]', :text => 'Sign out' |
|
93 |
end |
|
94 |
|
|
88 | 95 |
def test_call_hook_mixed_in |
89 | 96 |
assert @controller.respond_to?(:call_hook) |
90 | 97 |
end |
trunk/test/integration/routing/account_test.rb | ||
---|---|---|
25 | 25 |
{ :controller => 'account', :action => 'login' } |
26 | 26 |
) |
27 | 27 |
end |
28 |
assert_routing( |
|
29 |
{ :method => 'get', :path => "/logout" }, |
|
30 |
{ :controller => 'account', :action => 'logout' } |
|
31 |
) |
|
32 | 28 |
["get", "post"].each do |method| |
33 | 29 |
assert_routing( |
30 |
{ :method => method, :path => "/logout" }, |
|
31 |
{ :controller => 'account', :action => 'logout' } |
|
32 |
) |
|
33 |
end |
|
34 |
["get", "post"].each do |method| |
|
35 |
assert_routing( |
|
34 | 36 |
{ :method => method, :path => "/account/register" }, |
35 | 37 |
{ :controller => 'account', :action => 'register' } |
36 | 38 |
) |
Also available in: Unified diff
Use POST instead of GET for logging out (#13022).