somatics3-generators 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +9 -1
- data/VERSION +1 -1
- data/bin/somatics +0 -0
- data/bin/somatify +0 -0
- data/lib/generators/somatics/associated/associated_generator.rb +184 -0
- data/lib/generators/somatics/associated/templates/migration.rb +11 -0
- data/lib/generators/somatics/attributes/attributes_generator.rb +8 -5
- data/lib/generators/somatics/authenticated/authenticated_generator.rb +27 -195
- data/lib/generators/somatics/authenticated/templates/partial_form.html.erb +23 -0
- data/lib/generators/somatics/authenticated_controller/authenticated_controller_generator.rb +14 -299
- data/lib/generators/somatics/authenticated_controller/templates/locales_en.yml +6 -0
- data/lib/generators/somatics/authenticated_controller/templates/locales_zh-TW.yml +6 -0
- data/lib/generators/somatics/authenticated_controller/templates/login.html.erb +10 -8
- data/lib/generators/somatics/authenticated_controller/templates/sessions_controller.rb +11 -43
- data/lib/generators/somatics/install/install_generator.rb +26 -3
- data/lib/generators/somatics/install/templates/config/locales/devise_zh-TW.yml +39 -0
- data/lib/generators/somatics/install/templates/controller_admin.rb +8 -4
- data/lib/generators/somatics/install/templates/helper_admin.rb +39 -3
- data/lib/generators/somatics/install/templates/initializer_paper_trail.rb +2 -0
- data/lib/generators/somatics/install/templates/layout_admin.html.erb +4 -4
- data/lib/generators/somatics/install/templates/lib/active_record/diff.rb +61 -0
- data/lib/generators/somatics/install/templates/lib/tasks/heroku.rake +30 -0
- data/lib/generators/somatics/install/templates/lib/tasks/svn.rake +47 -0
- data/lib/generators/somatics/install/templates/partial_versions.html.erb +56 -0
- data/lib/generators/somatics/install/templates/public/stylesheets/application.css +863 -0
- data/lib/generators/somatics/install/templates/public/stylesheets/somatics/base.css +3 -0
- data/lib/generators/somatics/install/templates/public/themes/default/stylesheets/application.css +951 -0
- data/lib/generators/somatics/install/templates/view_index.html.erb +46 -1
- data/lib/generators/somatics/scaffold/scaffold_generator.rb +0 -1
- data/lib/generators/somatics/scaffold_controller/scaffold_controller_generator.rb +31 -60
- data/lib/generators/somatics/scaffold_controller/templates/controller.rb +4 -21
- data/lib/generators/somatics/scaffold_controller/templates/view_index.html.erb +3 -4
- data/lib/generators/somatics/scaffold_controller/templates/view_show.html.erb +2 -0
- data/lib/generators/somatics/settings/settings_generator.rb +7 -3
- data/lib/generators/somatics/settings_controller/templates/controller.rb +4 -20
- data/lib/generators/somatics/settings_controller/templates/partial_form.html.erb +1 -1
- data/lib/generators/somatics/settings_controller/templates/view_index.html.erb +2 -2
- data/somatics3-generators.gemspec +28 -37
- data/templates/somatics.rb +76 -121
- metadata +70 -64
- data/lib/generators/somatics/authenticated/templates/mailer.rb +0 -25
- data/lib/generators/somatics/authenticated/templates/migration.rb +0 -26
- data/lib/generators/somatics/authenticated/templates/model.rb +0 -83
- data/lib/generators/somatics/authenticated/templates/observer.rb +0 -11
- data/lib/generators/somatics/authenticated/templates/test/mailer_test.rb +0 -31
- data/lib/generators/somatics/authenticated/templates/test/model_functional_test.rb +0 -93
- data/lib/generators/somatics/authenticated/templates/test/sessions_functional_test.rb +0 -82
- data/lib/generators/somatics/authenticated/templates/test/unit_test.rb +0 -164
- data/lib/generators/somatics/authenticated/templates/test/users.yml +0 -60
- data/lib/generators/somatics/authenticated_controller/templates/_model_partial.html.erb +0 -8
- data/lib/generators/somatics/authenticated_controller/templates/activation.erb +0 -3
- data/lib/generators/somatics/authenticated_controller/templates/authenticated_system.rb +0 -189
- data/lib/generators/somatics/authenticated_controller/templates/authenticated_test_helper.rb +0 -10
- data/lib/generators/somatics/authenticated_controller/templates/config/initializers/site_keys.rb +0 -38
- data/lib/generators/somatics/authenticated_controller/templates/controller.rb +0 -55
- data/lib/generators/somatics/authenticated_controller/templates/helper.rb +0 -91
- data/lib/generators/somatics/authenticated_controller/templates/mailer.rb +0 -25
- data/lib/generators/somatics/authenticated_controller/templates/migration.rb +0 -26
- data/lib/generators/somatics/authenticated_controller/templates/model.rb +0 -83
- data/lib/generators/somatics/authenticated_controller/templates/observer.rb +0 -11
- data/lib/generators/somatics/authenticated_controller/templates/session_helper.rb +0 -2
- data/lib/generators/somatics/authenticated_controller/templates/signup.html.erb +0 -19
- data/lib/generators/somatics/authenticated_controller/templates/signup_notification.erb +0 -8
- data/lib/generators/somatics/authenticated_controller/templates/test/mailer_test.rb +0 -31
- data/lib/generators/somatics/authenticated_controller/templates/test/model_functional_test.rb +0 -93
- data/lib/generators/somatics/authenticated_controller/templates/test/sessions_functional_test.rb +0 -82
- data/lib/generators/somatics/authenticated_controller/templates/test/unit_test.rb +0 -164
- data/lib/generators/somatics/authenticated_controller/templates/test/users.yml +0 -60
- data/lib/generators/somatics/scaffold_controller/templates/builder_index.pdf.prawn +0 -25
- data/lib/generators/somatics/settings_controller/templates/builder_index.pdf.prawn +0 -25
- data/lib/generators/somatics/settings_controller/templates/model.rb +0 -54
@@ -0,0 +1,23 @@
|
|
1
|
+
<table width="100%">
|
2
|
+
<tbody>
|
3
|
+
<tr>
|
4
|
+
<td colspan="2"><br/><h3><%%= <%= class_name %>.model_name.human %></h3></td>
|
5
|
+
</tr>
|
6
|
+
<tr>
|
7
|
+
<td><b><%%= <%= class_name %>.human_attribute_name(:name) %></b></td>
|
8
|
+
<td><%%= f.text_field :name %></td>
|
9
|
+
</tr>
|
10
|
+
<tr>
|
11
|
+
<td><b><%%= <%= class_name %>.human_attribute_name(:email) %></b></td>
|
12
|
+
<td><%%= f.text_field :email %></td>
|
13
|
+
</tr>
|
14
|
+
<tr>
|
15
|
+
<td><b><%%= <%= class_name %>.human_attribute_name(:password) %></b></td>
|
16
|
+
<td><%%= f.password_field :password %></td>
|
17
|
+
</tr>
|
18
|
+
<tr>
|
19
|
+
<td><b><%%= <%= class_name %>.human_attribute_name(:password_confirmation) %></b></td>
|
20
|
+
<td><%%= f.password_field :password_confirmation %></td>
|
21
|
+
</tr>
|
22
|
+
</tbody>
|
23
|
+
</table>
|
@@ -1,323 +1,38 @@
|
|
1
1
|
require 'generators/somatics'
|
2
2
|
require 'rails/generators/named_base'
|
3
3
|
require 'rails/generators/resource_helpers'
|
4
|
-
require 'digest/sha1'
|
5
|
-
require 'rails/generators/migration'
|
4
|
+
# require 'digest/sha1'
|
5
|
+
# require 'rails/generators/migration'
|
6
6
|
|
7
7
|
module Somatics
|
8
8
|
module Generators
|
9
9
|
class AuthenticatedControllerGenerator < Rails::Generators::NamedBase
|
10
10
|
extend TemplatePath
|
11
|
-
include Rails::Generators::ResourceHelpers
|
12
|
-
include Rails::Generators::Migration
|
13
|
-
# hook_for :authenticated , :in => :somatics, :as => :scaffold, :default => 'somatics:scaffold' do |instance, command|
|
14
|
-
# instance.invoke command, [ class_name, attributes], {:namespace => 'admin' }
|
15
|
-
# end
|
16
11
|
|
17
|
-
|
18
|
-
class_option :
|
19
|
-
|
12
|
+
class_option :namespace, :banner => "NAME", :type => :string, :default => ''
|
13
|
+
class_option :locales, :type => :array, :banner => "LOCALE LOCALE", :default => %w( en zh-TW ),
|
14
|
+
:desc => "Supported Locales"
|
20
15
|
|
21
|
-
|
22
|
-
|
23
|
-
class_option :aasm, :type => :boolean, :desc => "Works the same as stateful but uses the updated aasm gem"
|
24
|
-
class_option :stateful, :type => :boolean, :desc => "Builds in support for acts_as_state_machine and generatesactivation code."
|
25
|
-
class_option :rspec, :type => :boolean, :desc => "Generate RSpec tests and Stories in place of standard rails tests."
|
26
|
-
class_option :old_passwords, :type => :boolean, :desc => "Use the older password scheme"
|
27
|
-
class_option :include_activation, :type => :boolean, :desc => "Skip the code for a ActionMailer and its respective Activation Code through email"
|
28
|
-
class_option :dump_generator_attrs, :type => :boolean, :desc => "Dump Generator Attrs"
|
29
|
-
|
30
|
-
# Try to be idempotent:
|
31
|
-
# pull in the existing site key if any,
|
32
|
-
# seed it with reasonable defaults otherwise
|
33
|
-
#
|
34
|
-
def load_or_initialize_site_keys
|
35
|
-
case
|
36
|
-
when defined? REST_AUTH_SITE_KEY
|
37
|
-
if (options[:old_passwords]) && ((! REST_AUTH_SITE_KEY.blank?) || (REST_AUTH_DIGEST_STRETCHES != 1))
|
38
|
-
raise "You have a site key, but --old-passwords will overwrite it. If this is really what you want, move the file #{site_keys_file} and re-run."
|
39
|
-
end
|
40
|
-
$rest_auth_site_key_from_generator = REST_AUTH_SITE_KEY
|
41
|
-
$rest_auth_digest_stretches_from_generator = REST_AUTH_DIGEST_STRETCHES
|
42
|
-
when options[:old_passwords]
|
43
|
-
$rest_auth_site_key_from_generator = nil
|
44
|
-
$rest_auth_digest_stretches_from_generator = 1
|
45
|
-
$rest_auth_keys_are_new = true
|
46
|
-
else
|
47
|
-
$rest_auth_site_key_from_generator = make_token
|
48
|
-
$rest_auth_digest_stretches_from_generator = 10
|
49
|
-
$rest_auth_keys_are_new = true
|
50
|
-
end
|
51
|
-
# template 'config/initializers/site_keys.rb', "config/initializers/#{controller_file_name}_site_keys.rb"
|
52
|
-
template 'config/initializers/site_keys.rb'
|
53
|
-
end
|
54
|
-
|
55
|
-
def create_controller_files
|
56
|
-
template 'controller.rb', File.join('app/controllers',"#{options.namespace}", controller_class_path, "#{ controller_file_name }_controller.rb")
|
57
|
-
end
|
58
|
-
|
59
|
-
def generate_lib_files
|
60
|
-
# Check for class naming collisions.
|
61
|
-
class_collisions [], "#{class_name}AuthenticatedSystem", "#{class_name}AuthenticatedTestHelper"
|
62
|
-
|
63
|
-
template 'authenticated_system.rb', File.join('lib', "#{file_name}_authenticated_system.rb")
|
64
|
-
template 'authenticated_test_helper.rb', File.join('lib', "#{file_name}_authenticated_test_helper.rb")
|
16
|
+
def create_sessions_controller
|
17
|
+
template 'sessions_controller.rb', File.join('app/controllers', options.namespace, "#{name}_sessions_controller.rb")
|
65
18
|
end
|
66
19
|
|
67
|
-
def
|
68
|
-
|
20
|
+
def create_login_page
|
21
|
+
template 'login.html.erb', File.join("app/views", options.namespace, "#{name}_sessions", 'new.html.erb')
|
69
22
|
end
|
70
23
|
|
71
|
-
def
|
72
|
-
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
|
-
def generate_sessions_controller
|
77
|
-
|
78
|
-
# Check for class naming collisions.
|
79
|
-
class_collisions sessions_controller_class_path, "#{sessions_controller_class_name}Controller", # Sessions Controller
|
80
|
-
"#{sessions_controller_class_name}Helper"
|
81
|
-
|
82
|
-
template 'sessions_controller.rb', File.join('app/controllers', sessions_controller_class_path, "#{sessions_controller_controller_name}_controller.rb")
|
83
|
-
# template 'session_helper.rb', File.join('app/helpers', sessions_controller_class_path, "#{sessions_controller_controller_name}_helper.rb")
|
84
|
-
# template 'test/sessions_functional_test.rb', File.join('test/functional', sessions_controller_class_path, "#{sessions_controller_file_name}_controller_test.rb")
|
85
|
-
|
86
|
-
# View templates
|
87
|
-
# template 'login.html.erb', File.join('app/views', sessions_controller_class_path, sessions_controller_file_name, "new.html.erb")
|
88
|
-
template 'login.html.erb', File.join('app/views', sessions_controller_file_path, 'new.html.erb')
|
89
|
-
# template 'signup.html.erb', File.join('app/views', controller_class_path, controller_file_name, "signup.html.erb")
|
90
|
-
template 'signup.html.erb', File.join('app/views', controller_file_path, 'new.html.erb')
|
91
|
-
# template '_model_partial.html.erb', File.join('app/views', controller_class_path, controller_file_name, "_#{file_name}_bar.html.erb")
|
92
|
-
template '_model_partial.html.erb', File.join('app/views', sessions_controller_file_path, "_#{file_name}_bar.html.erb")
|
93
|
-
|
94
|
-
end
|
95
|
-
|
96
|
-
def generate_route
|
97
|
-
unless options[:skip_routes]
|
98
|
-
route_config = class_path.collect{|namespace| "namespace :#{namespace} do " }.join(" ")
|
99
|
-
route_config << "\n"
|
100
|
-
route_config << %Q{ match '#{file_name}_signup' => '#{controller_plural_name}#new'}
|
101
|
-
route_config << "\n"
|
102
|
-
route_config << %Q{ match '#{file_name}_register' => '#{controller_plural_name}#create'}
|
103
|
-
route_config << "\n"
|
104
|
-
route_config << %Q{ match '#{file_name}_login' => '#{sessions_controller_controller_name}#new'}
|
105
|
-
route_config << "\n"
|
106
|
-
route_config << %Q{ match '#{file_name}_logout' => '#{sessions_controller_controller_name}#destroy'}
|
107
|
-
route_config << "\n"
|
108
|
-
route_config << " match '/activate/:activation_code' => '#{ controller_plural_name }#activate', :as => :activate, :activation_code => nil"
|
109
|
-
route_config << "\n"
|
110
|
-
route_config << " resource #{ sessions_controller_singular_name.to_sym.inspect }, :only => [:new, :create, :destroy]"
|
111
|
-
route_config << "\n"
|
112
|
-
route_config << " resources #{ controller_plural_name.to_sym.inspect }"
|
113
|
-
route_config << "\n"
|
114
|
-
route_config << " end" * class_path.size
|
115
|
-
route route_config
|
24
|
+
def create_locales
|
25
|
+
options[:locales].each do |locale|
|
26
|
+
template "locales_#{locale}.yml", File.join('config/locales', "#{name}_sessions_#{locale}.yml")
|
116
27
|
end
|
117
28
|
end
|
118
|
-
|
119
|
-
def insert_into_application_controller
|
120
|
-
puts "TODO: include #{class_name}AuthenticatedSystem"
|
121
|
-
puts "TODO: Add require #{class_name}in AuthenticatedSystem"
|
122
|
-
|
123
|
-
|
124
|
-
end
|
125
|
-
|
126
|
-
def dump_generator_attribute_names
|
127
|
-
generator_attribute_names = [
|
128
|
-
:namespace_class,
|
129
|
-
:namespace_name,
|
130
|
-
:table_name,
|
131
|
-
:file_name,
|
132
|
-
:class_name,
|
133
|
-
:sessions_controller_name,
|
134
|
-
:sessions_controller_class_path,
|
135
|
-
:sessions_controller_file_path,
|
136
|
-
# :sessions_controller_class_nesting,
|
137
|
-
# :sessions_controller_class_nesting_depth,
|
138
|
-
:sessions_controller_class_name,
|
139
|
-
:sessions_controller_singular_name,
|
140
|
-
:sessions_controller_plural_name,
|
141
|
-
:sessions_controller_routing_name, # new_session_path
|
142
|
-
:sessions_controller_routing_path, # /session/new
|
143
|
-
:sessions_controller_controller_name, # sessions
|
144
|
-
:sessions_controller_file_name,
|
145
|
-
:sessions_controller_table_name,
|
146
|
-
:controller_name,
|
147
|
-
:controller_class_path,
|
148
|
-
:controller_file_path,
|
149
|
-
# :controller_class_nesting,
|
150
|
-
# :controller_class_nesting_depth,
|
151
|
-
:controller_class_name,
|
152
|
-
:controller_singular_name,
|
153
|
-
:controller_plural_name,
|
154
|
-
:controller_routing_name, # new_user_path
|
155
|
-
:controller_routing_path, # /users/new
|
156
|
-
:controller_controller_name, # users
|
157
|
-
:controller_file_name,
|
158
|
-
:controller_singular_name,
|
159
|
-
:controller_table_name,
|
160
|
-
:controller_plural_name,
|
161
|
-
]
|
162
|
-
|
163
|
-
generator_attribute_names.each do |attr|
|
164
|
-
puts "%-40s %s" % ["#{attr}:", self.send(attr.to_s)] # instance_variable_get("@#{attr.to_s}"
|
165
|
-
end
|
166
29
|
|
167
|
-
|
168
|
-
|
169
|
-
# rails g authenticated FoonParent::Foon SporkParent::Spork -p --force --rspec --dump-generator-attrs
|
170
|
-
# table_name: foon_parent_foons
|
171
|
-
# file_name: foon
|
172
|
-
# class_name: FoonParent::Foon
|
173
|
-
# controller_name: SporkParent::Sporks
|
174
|
-
# controller_class_path: spork_parent
|
175
|
-
# controller_file_path: spork_parent/sporks
|
176
|
-
# controller_class_nesting: SporkParent
|
177
|
-
# controller_class_nesting_depth: 1
|
178
|
-
# controller_class_name: SporkParent::Sporks
|
179
|
-
# controller_singular_name: spork
|
180
|
-
# controller_plural_name: sporks
|
181
|
-
# controller_routing_name: spork
|
182
|
-
# controller_routing_path: spork_parent/spork
|
183
|
-
# controller_controller_name: sporks
|
184
|
-
# controller_file_name: sporks
|
185
|
-
# controller_table_name: sporks
|
186
|
-
# controller_plural_name: sporks
|
187
|
-
# model_controller_name: FoonParent::Foons
|
188
|
-
# model_controller_class_path: foon_parent
|
189
|
-
# model_controller_file_path: foon_parent/foons
|
190
|
-
# model_controller_class_nesting: FoonParent
|
191
|
-
# model_controller_class_nesting_depth: 1
|
192
|
-
# model_controller_class_name: FoonParent::Foons
|
193
|
-
# model_controller_singular_name: foons
|
194
|
-
# model_controller_plural_name: foons
|
195
|
-
# model_controller_routing_name: foon_parent_foons
|
196
|
-
# model_controller_routing_path: foon_parent/foons
|
197
|
-
# model_controller_controller_name: foons
|
198
|
-
# model_controller_file_name: foons
|
199
|
-
# model_controller_singular_name: foons
|
200
|
-
# model_controller_table_name: foons
|
201
|
-
# model_controller_plural_name: foons
|
202
|
-
|
203
|
-
|
204
|
-
protected
|
30
|
+
protected
|
205
31
|
|
206
32
|
def namespace_class
|
207
|
-
options
|
208
|
-
end
|
209
|
-
|
210
|
-
def namespace_name
|
211
|
-
options[:namespace].underscore if options[:namespace].present?
|
212
|
-
end
|
213
|
-
|
214
|
-
def sessions_controller_name
|
215
|
-
file_name + '_sessions'
|
216
|
-
end
|
217
|
-
|
218
|
-
def sessions_controller_class_path
|
219
|
-
controller_class_path
|
220
|
-
end
|
221
|
-
|
222
|
-
def sessions_controller_file_path
|
223
|
-
controller_file_path.singularize + '_sessions'
|
224
|
-
end
|
225
|
-
|
226
|
-
def sessions_controller_singular_name
|
227
|
-
sessions_controller_file_name
|
228
|
-
end
|
229
|
-
|
230
|
-
def sessions_controller_plural_name
|
231
|
-
sessions_controller_file_name.pluralize
|
232
|
-
end
|
233
|
-
|
234
|
-
def sessions_controller_routing_name
|
235
|
-
sessions_controller_routing_path.parameterize.underscore # HACK
|
236
|
-
end
|
237
|
-
|
238
|
-
def sessions_controller_routing_path
|
239
|
-
sessions_controller_file_path.singularize
|
240
|
-
end
|
241
|
-
|
242
|
-
def sessions_controller_class_name
|
243
|
-
controller_class_name.singularize + 'Sessions'
|
244
|
-
end
|
245
|
-
|
246
|
-
def sessions_controller_controller_name
|
247
|
-
sessions_controller_plural_name
|
248
|
-
end
|
249
|
-
|
250
|
-
def sessions_controller_file_name
|
251
|
-
file_name + '_session'
|
252
|
-
end
|
253
|
-
|
254
|
-
def sessions_controller_table_name
|
255
|
-
sessions_controller_plural_name
|
256
|
-
end
|
257
|
-
|
258
|
-
def controller_plural_name
|
259
|
-
plural_name
|
260
|
-
end
|
261
|
-
|
262
|
-
def controller_singular_name
|
263
|
-
singular_name
|
264
|
-
end
|
265
|
-
|
266
|
-
def controller_routing_name
|
267
|
-
controller_routing_path.parameterize.underscore # HACK
|
268
|
-
end
|
269
|
-
|
270
|
-
def controller_routing_path
|
271
|
-
controller_file_path.singularize
|
272
|
-
end
|
273
|
-
|
274
|
-
def controller_controller_name
|
275
|
-
controller_plural_name
|
276
|
-
end
|
277
|
-
|
278
|
-
alias_method :controller_table_name, :controller_plural_name
|
279
|
-
|
280
|
-
def model_class_name
|
281
|
-
class_name unless options[:model].present?
|
282
|
-
options[:model].classify
|
283
|
-
end
|
284
|
-
|
285
|
-
def migration_name
|
286
|
-
"Create#{ class_name.pluralize.gsub(/::/, '') }"
|
33
|
+
options.namespace.camelize
|
287
34
|
end
|
288
35
|
|
289
|
-
def migration_file_name
|
290
|
-
"#{ file_path.gsub(/\//, '_').pluralize }"
|
291
|
-
end
|
292
|
-
|
293
|
-
#
|
294
|
-
# Implement the required interface for Rails::Generators::Migration.
|
295
|
-
# taken from http://github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
|
296
|
-
#
|
297
|
-
def self.next_migration_number(dirname) #:nodoc:
|
298
|
-
if ActiveRecord::Base.timestamped_migrations
|
299
|
-
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
300
|
-
else
|
301
|
-
"%.3d" % (current_migration_number(dirname) + 1)
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
#
|
306
|
-
# !! These must match the corresponding routines in by_password.rb !!
|
307
|
-
#
|
308
|
-
def secure_digest(*args)
|
309
|
-
Digest::SHA1.hexdigest(args.flatten.join('--'))
|
310
|
-
end
|
311
|
-
def make_token
|
312
|
-
secure_digest(Time.now, (1..10).map{ rand.to_s })
|
313
|
-
end
|
314
|
-
def password_digest(password, salt)
|
315
|
-
digest = $rest_auth_site_key_from_generator
|
316
|
-
$rest_auth_digest_stretches_from_generator.times do
|
317
|
-
digest = secure_digest(digest, salt, password, $rest_auth_site_key_from_generator)
|
318
|
-
end
|
319
|
-
digest
|
320
|
-
end
|
321
36
|
end
|
322
37
|
end
|
323
38
|
end
|
@@ -1,20 +1,22 @@
|
|
1
|
-
|
1
|
+
<%%= form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => {:id => 'login-form'}) do |f| %>
|
2
2
|
<p><%%= flash[:error] %></p>
|
3
3
|
<table>
|
4
4
|
<tbody>
|
5
5
|
<tr>
|
6
|
-
<td align="right"><b><%%= <%=
|
7
|
-
<td align="left"><%%=
|
6
|
+
<td align="right"><b><%%= <%= class_name %>.human_attribute_name(:email) %></b></td>
|
7
|
+
<td align="left"><%%= f.text_field :email %></td>
|
8
8
|
</tr>
|
9
9
|
<tr>
|
10
|
-
<td align="right"><b><%%= <%=
|
11
|
-
<td align="left"><%%=
|
10
|
+
<td align="right"><b><%%= <%= class_name %>.human_attribute_name(:password) %></b></td>
|
11
|
+
<td align="left"><%%= f.password_field :password %></td>
|
12
12
|
</tr>
|
13
13
|
<!-- Uncomment this if you want this functionality
|
14
|
+
<%% if devise_mapping.rememberable? -%>
|
14
15
|
<tr>
|
15
|
-
<td align="right"><%%#=
|
16
|
-
<td align="left"><%%#=
|
16
|
+
<td align="right"><%%#= f.label 'remember_me', 'Remember me' %></td>
|
17
|
+
<td align="left"><%%#= f.check_box :remember_me %></td>
|
17
18
|
</tr>
|
19
|
+
<%% end -%>
|
18
20
|
-->
|
19
21
|
<tr>
|
20
22
|
<td align="right"></td>
|
@@ -22,7 +24,7 @@
|
|
22
24
|
</tr>
|
23
25
|
<tr>
|
24
26
|
<td align="left"></td>
|
25
|
-
<td align="right"><%%=
|
27
|
+
<td align="right"><%%= f.submit t('Log_in') %></td>
|
26
28
|
</tr>
|
27
29
|
</tbody>
|
28
30
|
</table>
|
@@ -1,43 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
<%= file_name %> = <%= model_class_name %>.authenticate(params[:login], params[:password])
|
13
|
-
if <%= file_name %>
|
14
|
-
# Protects against session fixation attacks, causes request forgery
|
15
|
-
# protection if user resubmits an earlier form using back
|
16
|
-
# button. Uncomment if you understand the tradeoffs.
|
17
|
-
# reset_session
|
18
|
-
self.current_<%= file_name %> = <%= file_name %>
|
19
|
-
new_cookie_flag = (params[:remember_me] == "1")
|
20
|
-
<%= file_name %>_handle_remember_cookie! new_cookie_flag
|
21
|
-
redirect_back_or_default('/')
|
22
|
-
flash[:notice] = "Logged in successfully"
|
23
|
-
else
|
24
|
-
note_failed_signin
|
25
|
-
@login = params[:login]
|
26
|
-
@remember_me = params[:remember_me]
|
27
|
-
redirect_to :action => 'new'
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def destroy
|
32
|
-
<%= file_name %>_logout_killing_session!
|
33
|
-
flash[:notice] = "You have been logged out."
|
34
|
-
redirect_back_or_default('/')
|
35
|
-
end
|
36
|
-
|
37
|
-
protected
|
38
|
-
# Track failed login attempts
|
39
|
-
def note_failed_signin
|
40
|
-
flash[:error] = "Couldn't log you in as '#{params[:login]}'"
|
41
|
-
logger.warn "Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}"
|
42
|
-
end
|
43
|
-
end
|
1
|
+
class <%= namespace_class %>::<%= class_name %>SessionsController < Devise::SessionsController
|
2
|
+
layout '<%= options.namespace %>'
|
3
|
+
|
4
|
+
def after_sign_in_path_for(resource)
|
5
|
+
<%= options.namespace %>_root_url
|
6
|
+
end
|
7
|
+
|
8
|
+
def after_sign_out_path_for(resource)
|
9
|
+
new_<%= name %>_session_url
|
10
|
+
end
|
11
|
+
end
|