redsafe 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/models/scarlet_letters.rb +9 -9
- data/lib/redsafe/version.rb +1 -1
- metadata +1 -1
@@ -4,7 +4,6 @@ if Object.const_defined?("DataMapper")
|
|
4
4
|
require 'dm-validations'
|
5
5
|
require 'date'
|
6
6
|
require 'time'
|
7
|
-
require 'DateTime'
|
8
7
|
|
9
8
|
require Pathname(__FILE__).dirname.expand_path + "sl_user.rb"
|
10
9
|
require Pathname(__FILE__).dirname.expand_path + "sl_aah.rb"
|
@@ -53,27 +52,28 @@ class User
|
|
53
52
|
#3. resist: receives the desist string and reviews its integrity
|
54
53
|
|
55
54
|
def self.sist
|
56
|
-
|
55
|
+
const_set(TIME_FMT, '%Y-%m-%dT%H:%M:%SZ')
|
57
56
|
junk = self.random_string(6)
|
58
57
|
t = Time.now.getutc
|
59
|
-
time_str = t.strftime(
|
58
|
+
time_str = t.strftime(TIME_FMT)
|
60
59
|
the_sist_str = time_str + junk
|
61
60
|
return the_sist_str
|
62
61
|
end
|
63
62
|
|
64
63
|
def self.desist( the_sist_str )
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
raise ArgumentError
|
64
|
+
#"0000-00-00T00:00:00Z"
|
65
|
+
const_set(TIME_STR_LEN, 20 )
|
66
|
+
const_set(TIME_VALIDATOR,"/\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ/")
|
67
|
+
timestamp_str = the_sist_str[0...TIME_STR_LEN]
|
68
|
+
raise ArgumentError if timestamp_str.size < TIME_STR_LEN
|
69
|
+
raise ArgumentError unless timestamp_str.match(TIME_VALIDATOR)
|
70
70
|
timestamp = Time.parse(timestamp_str).to_i
|
71
71
|
raise ArgumentError if ts < 0
|
72
72
|
return timestamp, the_sist_str[20..-1]
|
73
73
|
end
|
74
74
|
|
75
75
|
def self.resist(the_sist_str)
|
76
|
-
const_set
|
76
|
+
const_set(TIME_RANGE, 60*60*5)
|
77
77
|
timestamp, junk = self.desist(the_sist_str)
|
78
78
|
now = Time.now.to_i
|
79
79
|
start = now - TIME_RANGE
|
data/lib/redsafe/version.rb
CHANGED