Class: Token

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/token.rb

Overview

Redmine - project management software Copyright © 2006-2009 Jean-Philippe Lang

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Constant Summary collapse

@@validity_time =
1.day

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.destroy_expiredObject

Delete all expired tokens



36
37
38
# File 'app/models/token.rb', line 36

def self.destroy_expired
  Token.delete_all ["action <> 'feeds' AND created_on < ?", Time.now - @@validity_time]
end

Instance Method Details

#before_createObject



26
27
28
# File 'app/models/token.rb', line 26

def before_create
  self.value = Token.generate_token_value
end

#expired?Boolean

Return true if token has expired

Returns:

  • (Boolean)


31
32
33
# File 'app/models/token.rb', line 31

def expired?
  return Time.now > self.created_on + @@validity_time
end