Feature #29041 » 29041.patch
app/models/user.rb | ||
---|---|---|
469 | 469 |
if Setting.session_timeout? |
470 | 470 |
scope = scope.where("updated_on > ?", Setting.session_timeout.to_i.minutes.ago) |
471 | 471 |
end |
472 |
scope.update_all(:updated_on => Time.now) == 1 |
|
472 |
last_updated = scope.maximum(:updated_on) |
|
473 |
if last_updated.nil? |
|
474 |
false |
|
475 |
elsif last_updated <= 1.minute.ago |
|
476 |
scope.update_all(:updated_on => Time.now) == 1 |
|
477 |
else |
|
478 |
true |
|
479 |
end |
|
473 | 480 |
end |
474 | 481 | |
475 | 482 |
# Return an array of project ids for which the user has explicitly turned mail notifications on |
test/functional/sessions_controller_test.rb | ||
---|---|---|
45 | 45 |
assert token.updated_on > created |
46 | 46 |
end |
47 | 47 | |
48 |
def test_session_token_should_be_updated_only_once_per_minute |
|
49 |
token = Token.create!(:user_id => 2, :action => 'session', :created_on => 1.second.ago, :updated_on => 1.second.ago) |
|
50 |
updated = token.reload.updated_on |
|
51 | ||
52 |
get :index, :session => { |
|
53 |
:user_id => 2, |
|
54 |
:tk => token.value |
|
55 |
} |
|
56 |
assert_response :success |
|
57 |
token.reload |
|
58 |
assert_equal updated.to_i, token.updated_on.to_i |
|
59 |
end |
|
60 | ||
48 | 61 |
def test_user_session_should_not_be_reset_if_lifetime_and_timeout_disabled |
49 | 62 |
created = 2.years.ago |
50 | 63 |
token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created) |
- « Previous
- 1
- 2
- 3
- 4
- Next »