Commit 1323bbe92bb5a4c73638c347bf5f3d27c8f26a0b
Committed by
Leandro Santos
1 parent
e9c353c4
Exists in
master
and in
17 other branches
api: remove check of expired token
Showing
3 changed files
with
0 additions
and
17 deletions
Show diff stats
app/models/user.rb
| ... | ... | @@ -170,11 +170,6 @@ class User < ActiveRecord::Base |
| 170 | 170 | end |
| 171 | 171 | end |
| 172 | 172 | |
| 173 | - TOKEN_VALIDITY = 2.weeks | |
| 174 | - def private_token_expired? | |
| 175 | - self.private_token.nil? || (self.private_token_generated_at + TOKEN_VALIDITY < DateTime.now) | |
| 176 | - end | |
| 177 | - | |
| 178 | 173 | # Activates the user in the database. |
| 179 | 174 | def activate |
| 180 | 175 | return false unless self.person | ... | ... |
lib/noosfero/api/helpers.rb
| ... | ... | @@ -23,7 +23,6 @@ require_relative '../../find_by_contents' |
| 23 | 23 | def current_user |
| 24 | 24 | private_token = (params[PRIVATE_TOKEN_PARAM] || headers['Private-Token']).to_s |
| 25 | 25 | @current_user ||= User.find_by_private_token(private_token) |
| 26 | - @current_user = nil if !@current_user.nil? && @current_user.private_token_expired? | |
| 27 | 26 | @current_user |
| 28 | 27 | end |
| 29 | 28 | ... | ... |
test/unit/user_test.rb
| ... | ... | @@ -733,17 +733,6 @@ class UserTest < ActiveSupport::TestCase |
| 733 | 733 | assert user.private_token, 'token' |
| 734 | 734 | end |
| 735 | 735 | |
| 736 | - should 'check for private token validity' do | |
| 737 | - user = User.new | |
| 738 | - assert user.private_token_expired? | |
| 739 | - | |
| 740 | - user.generate_private_token! | |
| 741 | - assert !user.private_token_expired? | |
| 742 | - | |
| 743 | - user.private_token_generated_at = DateTime.now - (User::TOKEN_VALIDITY + 1.minute) | |
| 744 | - assert user.private_token_expired? | |
| 745 | - end | |
| 746 | - | |
| 747 | 736 | protected |
| 748 | 737 | def new_user(options = {}) |
| 749 | 738 | user = User.new({ :login => 'quire', :email => 'quire@example.com', :password => 'quire', :password_confirmation => 'quire' }.merge(options)) | ... | ... |