salted_login_generator 1.0.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/templates/README +1 -1
- data/templates/controller.rb +7 -2
- data/templates/controller_test.rb +1 -1
- data/templates/mock_notify.rb +7 -9
- data/templates/user.rb +5 -29
- metadata +3 -3
data/templates/README
CHANGED
@@ -185,7 +185,7 @@ automatically on startup.
|
|
185
185
|
|
186
186
|
== Changelog
|
187
187
|
|
188
|
-
1.0.9 Fixed hardcoded generator name (in controller test) and README
|
188
|
+
1.0.9 Fixed hardcoded generator name (in controller test and schema) and README
|
189
189
|
1.0.8 Generator/schema fixes and some README fixes/improvements
|
190
190
|
1.0.7 Fixed bad bug with missing attr_accessor :new_password in user class
|
191
191
|
1.0.6 Proper delete support and bug fixes
|
data/templates/controller.rb
CHANGED
@@ -69,6 +69,7 @@ class <%= class_name %>Controller < ApplicationController
|
|
69
69
|
when :get
|
70
70
|
@<%= singular_name %> = <%= class_name %>.new
|
71
71
|
render
|
72
|
+
return
|
72
73
|
end
|
73
74
|
|
74
75
|
# Handle the :post
|
@@ -84,7 +85,10 @@ class <%= class_name %>Controller < ApplicationController
|
|
84
85
|
url += "?<%= singular_name %>[id]=#{<%= singular_name %>.id}&key=#{key}"
|
85
86
|
<%= class_name %>Notify.deliver_forgot_password(<%= singular_name %>, url)
|
86
87
|
flash['notice'] = l(:<%= singular_name %>_forgotten_password_emailed, "#{@params['<%= singular_name %>']['email']}")
|
87
|
-
|
88
|
+
unless <%= singular_name %>?
|
89
|
+
redirect_to :action => 'login'
|
90
|
+
return
|
91
|
+
end
|
88
92
|
redirect_back_or_default :action => 'welcome'
|
89
93
|
end
|
90
94
|
rescue
|
@@ -129,7 +133,6 @@ class <%= class_name %>Controller < ApplicationController
|
|
129
133
|
destroy(@<%= singular_name %>)
|
130
134
|
end
|
131
135
|
logout
|
132
|
-
redirect_to :action => 'login'
|
133
136
|
rescue
|
134
137
|
flash.now['message'] = l(:<%= singular_name %>_delete_email_error, "#{@<%= singular_name %>['email']}")
|
135
138
|
redirect_back_or_default :action => 'welcome'
|
@@ -172,6 +175,7 @@ class <%= class_name %>Controller < ApplicationController
|
|
172
175
|
when :get
|
173
176
|
@<%= singular_name %> = <%= class_name %>.new
|
174
177
|
render
|
178
|
+
return
|
175
179
|
end
|
176
180
|
end
|
177
181
|
|
@@ -181,6 +185,7 @@ class <%= class_name %>Controller < ApplicationController
|
|
181
185
|
case @request.method
|
182
186
|
when :get
|
183
187
|
render
|
188
|
+
return
|
184
189
|
end
|
185
190
|
end
|
186
191
|
end
|
@@ -22,7 +22,7 @@ class <%= class_name %>ControllerTest < Test::Unit::TestCase
|
|
22
22
|
|
23
23
|
assert_equal @bob, @response.session["<%= singular_name %>"]
|
24
24
|
|
25
|
-
assert_redirect_url "/bogus/location"
|
25
|
+
assert_redirect_url "http://#{@request.host}/bogus/location"
|
26
26
|
end
|
27
27
|
|
28
28
|
def do_test_signup(bad_password, bad_email)
|
data/templates/mock_notify.rb
CHANGED
@@ -4,15 +4,13 @@ ActionMailer::Base.class_eval {
|
|
4
4
|
@@inject_one_error = false
|
5
5
|
cattr_accessor :inject_one_error
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
deliveries << mail
|
15
|
-
end
|
7
|
+
private
|
8
|
+
def perform_delivery_test(mail)
|
9
|
+
if inject_one_error
|
10
|
+
ActionMailer::Base::inject_one_error = false
|
11
|
+
raise "Failed to send email" if raise_delivery_errors
|
12
|
+
else
|
13
|
+
deliveries << mail
|
16
14
|
end
|
17
15
|
end
|
18
16
|
}
|
data/templates/user.rb
CHANGED
@@ -1,23 +1,5 @@
|
|
1
1
|
require 'digest/sha1'
|
2
2
|
|
3
|
-
ActiveRecord::Validations::ClassMethods.module_eval {
|
4
|
-
public
|
5
|
-
def validate_on_virtual(*methods, &block)
|
6
|
-
methods << block if block_given?
|
7
|
-
write_inheritable_set(:validate_on_virtual, methods)
|
8
|
-
end
|
9
|
-
|
10
|
-
private
|
11
|
-
def validation_method(on)
|
12
|
-
case on
|
13
|
-
when :save then :validate
|
14
|
-
when :create then :validate_on_create
|
15
|
-
when :update then :validate_on_update
|
16
|
-
when :virtual then :validate_on_virtual
|
17
|
-
end
|
18
|
-
end
|
19
|
-
}
|
20
|
-
|
21
3
|
# this model expects a certain database layout and its based on the name/login pattern.
|
22
4
|
class <%= class_name %> < ActiveRecord::Base
|
23
5
|
|
@@ -79,17 +61,11 @@ class <%= class_name %> < ActiveRecord::Base
|
|
79
61
|
@new_password = true
|
80
62
|
end
|
81
63
|
|
82
|
-
def valid?
|
83
|
-
super
|
84
|
-
run_validations(:validate_on_virtual) if virtual_validations?
|
85
|
-
errors.empty?
|
86
|
-
end
|
87
|
-
|
88
64
|
protected
|
89
65
|
|
90
66
|
attr_accessor :password, :password_confirmation
|
91
67
|
|
92
|
-
def
|
68
|
+
def validate_password?
|
93
69
|
@new_password
|
94
70
|
end
|
95
71
|
|
@@ -130,9 +106,9 @@ class <%= class_name %> < ActiveRecord::Base
|
|
130
106
|
validates_uniqueness_of :login, :on => :create
|
131
107
|
validates_uniqueness_of :email, :on => :create
|
132
108
|
|
133
|
-
validates_presence_of :password, :
|
134
|
-
validates_confirmation_of :password, :
|
135
|
-
validates_length_of :password, { :minimum => 5, :
|
136
|
-
validates_length_of :password, { :maximum => 40, :
|
109
|
+
validates_presence_of :password, :if => :validate_password?
|
110
|
+
validates_confirmation_of :password, :if => :validate_password?
|
111
|
+
validates_length_of :password, { :minimum => 5, :if => :validate_password? }
|
112
|
+
validates_length_of :password, { :maximum => 40, :if => :validate_password? }
|
137
113
|
end
|
138
114
|
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.8
|
|
3
3
|
specification_version: 1
|
4
4
|
name: salted_login_generator
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.0
|
7
|
-
date: 2005-
|
6
|
+
version: 1.1.0
|
7
|
+
date: 2005-07-31
|
8
8
|
summary: "[Rails] Login generator with salted passwords."
|
9
9
|
require_paths:
|
10
10
|
- "."
|
@@ -74,5 +74,5 @@ dependencies:
|
|
74
74
|
-
|
75
75
|
- ">="
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: 0.
|
77
|
+
version: 0.13.1
|
78
78
|
version:
|