Commit 2b9e1360b7a945784b7ab0554e9233075f7702e5

Authored by Leandro Santos
2 parents e9c353c4 1323bbe9

Merge branch 'participa/noosfero-remove_token_expired'

app/models/user.rb
@@ -170,11 +170,6 @@ class User < ActiveRecord::Base @@ -170,11 +170,6 @@ class User < ActiveRecord::Base
170 end 170 end
171 end 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 # Activates the user in the database. 173 # Activates the user in the database.
179 def activate 174 def activate
180 return false unless self.person 175 return false unless self.person
lib/noosfero/api/helpers.rb
@@ -23,7 +23,6 @@ require_relative &#39;../../find_by_contents&#39; @@ -23,7 +23,6 @@ require_relative &#39;../../find_by_contents&#39;
23 def current_user 23 def current_user
24 private_token = (params[PRIVATE_TOKEN_PARAM] || headers['Private-Token']).to_s 24 private_token = (params[PRIVATE_TOKEN_PARAM] || headers['Private-Token']).to_s
25 @current_user ||= User.find_by_private_token(private_token) 25 @current_user ||= User.find_by_private_token(private_token)
26 - @current_user = nil if !@current_user.nil? && @current_user.private_token_expired?  
27 @current_user 26 @current_user
28 end 27 end
29 28
test/unit/user_test.rb
@@ -733,17 +733,6 @@ class UserTest &lt; ActiveSupport::TestCase @@ -733,17 +733,6 @@ class UserTest &lt; ActiveSupport::TestCase
733 assert user.private_token, 'token' 733 assert user.private_token, 'token'
734 end 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 protected 736 protected
748 def new_user(options = {}) 737 def new_user(options = {})
749 user = User.new({ :login => 'quire', :email => 'quire@example.com', :password => 'quire', :password_confirmation => 'quire' }.merge(options)) 738 user = User.new({ :login => 'quire', :email => 'quire@example.com', :password => 'quire', :password_confirmation => 'quire' }.merge(options))