PeterCoulton-rotten-generators 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/rails_generators/rotten_authentication/lib/insert_commands.rb +74 -0
- data/rails_generators/rotten_authentication/rotten_authentication_generator.rb +102 -0
- data/rails_generators/rotten_authentication/templates/authentication.rb +37 -0
- data/rails_generators/rotten_authentication/templates/fixtures.yml +12 -0
- data/rails_generators/rotten_authentication/templates/migration.rb +15 -0
- data/rails_generators/rotten_authentication/templates/sessions_controller.rb +22 -0
- data/rails_generators/rotten_authentication/templates/sessions_helper.rb +2 -0
- data/rails_generators/rotten_authentication/templates/tests/rspec/sessions_controller.rb +25 -0
- data/rails_generators/rotten_authentication/templates/tests/rspec/user.rb +81 -0
- data/rails_generators/rotten_authentication/templates/tests/rspec/users_controller.rb +24 -0
- data/rails_generators/rotten_authentication/templates/user.rb +38 -0
- data/rails_generators/rotten_authentication/templates/users_controller.rb +16 -0
- data/rails_generators/rotten_authentication/templates/users_helper.rb +2 -0
- data/rails_generators/rotten_authentication/templates/views/haml/login.html.haml +15 -0
- data/rails_generators/rotten_authentication/templates/views/haml/signup.html.haml +24 -0
- data/rotten-generators.gemspec +17 -2
- metadata +17 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.7.0
|
@@ -0,0 +1,74 @@
|
|
1
|
+
Rails::Generator::Commands::Create.class_eval do
|
2
|
+
def route_resource(*resources)
|
3
|
+
resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
|
4
|
+
sentinel = 'ActionController::Routing::Routes.draw do |map|'
|
5
|
+
|
6
|
+
logger.route "map.resource #{resource_list}"
|
7
|
+
unless options[:pretend]
|
8
|
+
gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
9
|
+
"#{match}\n map.resource #{resource_list}\n"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def route_name(name, path, route_options = {})
|
15
|
+
sentinel = 'ActionController::Routing::Routes.draw do |map|'
|
16
|
+
|
17
|
+
logger.route "map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
|
18
|
+
unless options[:pretend]
|
19
|
+
gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
20
|
+
"#{match}\n map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def insert_into(file, line)
|
26
|
+
logger.insert "#{line} into #{file}"
|
27
|
+
unless options[:pretend]
|
28
|
+
gsub_file file, /^(class|module) .+$/ do |match|
|
29
|
+
"#{match}\n #{line}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
Rails::Generator::Commands::Destroy.class_eval do
|
36
|
+
def route_resource(*resources)
|
37
|
+
resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
|
38
|
+
look_for = "\n map.resource #{resource_list}\n"
|
39
|
+
logger.route "map.resource #{resource_list}"
|
40
|
+
unless options[:pretend]
|
41
|
+
gsub_file 'config/routes.rb', /(#{look_for})/mi, ''
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def route_name(name, path, route_options = {})
|
46
|
+
look_for = "\n map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
|
47
|
+
logger.route "map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
|
48
|
+
unless options[:pretend]
|
49
|
+
gsub_file 'config/routes.rb', /(#{look_for})/mi, ''
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def insert_into(file, line)
|
54
|
+
logger.remove "#{line} from #{file}"
|
55
|
+
unless options[:pretend]
|
56
|
+
gsub_file file, "\n #{line}", ''
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
Rails::Generator::Commands::List.class_eval do
|
62
|
+
def route_resource(*resources)
|
63
|
+
resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
|
64
|
+
logger.route "map.resource #{resource_list}"
|
65
|
+
end
|
66
|
+
|
67
|
+
def route_name(name, path, options = {})
|
68
|
+
logger.route "map.#{name} '#{path}', :controller => '{options[:controller]}', :action => '#{options[:action]}'"
|
69
|
+
end
|
70
|
+
|
71
|
+
def insert_into(file, line)
|
72
|
+
logger.insert "#{line} into #{file}"
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/lib/insert_commands.rb")
|
2
|
+
|
3
|
+
class RottenAuthenticationGenerator < Rails::Generator::Base
|
4
|
+
attr_accessor :user_name, :sessions_name
|
5
|
+
|
6
|
+
def initialize(runtime_args, runtime_options = {})
|
7
|
+
super
|
8
|
+
|
9
|
+
@user_name = @args[0] || 'user'
|
10
|
+
@sessions_name = @args[1] || 'sessions'
|
11
|
+
end
|
12
|
+
|
13
|
+
def manifest
|
14
|
+
record do |m|
|
15
|
+
m.directory "app/models"
|
16
|
+
m.directory "app/controllers"
|
17
|
+
m.directory "app/helpers"
|
18
|
+
m.directory "app/views"
|
19
|
+
m.directory "lib"
|
20
|
+
|
21
|
+
m.directory "app/views/#{user_plural_name}"
|
22
|
+
m.template "user.rb", "app/models/#{user_singular_name}.rb"
|
23
|
+
m.template "users_controller.rb", "app/controllers/#{user_plural_name}_controller.rb"
|
24
|
+
m.template "users_helper.rb", "app/helpers/#{user_plural_name}_helper.rb"
|
25
|
+
m.template "views/#{view_language}/signup.html.#{view_language}", "app/views/#{user_plural_name}/new.html.#{view_language}"
|
26
|
+
|
27
|
+
m.directory "app/views/#{sessions_underscore_name}"
|
28
|
+
m.template "sessions_controller.rb", "app/controllers/#{sessions_underscore_name}_controller.rb"
|
29
|
+
m.template "sessions_helper.rb", "app/helpers/#{sessions_underscore_name}_helper.rb"
|
30
|
+
m.template "views/#{view_language}/login.html.#{view_language}", "app/views/#{sessions_underscore_name}/new.html.#{view_language}"
|
31
|
+
|
32
|
+
m.template "authentication.rb", "lib/authentication.rb"
|
33
|
+
m.migration_template "migration.rb", "db/migrate", :migration_file_name => "create_#{user_plural_name}"
|
34
|
+
|
35
|
+
m.route_resources user_plural_name
|
36
|
+
m.route_resources sessions_underscore_name
|
37
|
+
m.route_name :login, 'login', :controller => sessions_underscore_name, :action => 'new'
|
38
|
+
m.route_name :logout, 'logout', :controller => sessions_underscore_name, :action => 'destroy'
|
39
|
+
m.route_name :signup, 'signup', :controller => user_plural_name, :action => 'new'
|
40
|
+
|
41
|
+
m.insert_into "app/controllers/#{application_controller_name}.rb", 'include Authentication'
|
42
|
+
|
43
|
+
m.directory "spec"
|
44
|
+
m.directory "spec/fixtures"
|
45
|
+
m.directory "spec/controllers"
|
46
|
+
m.directory "spec/models"
|
47
|
+
m.template "fixtures.yml", "spec/fixtures/#{user_plural_name}.yml"
|
48
|
+
m.template "tests/rspec/user.rb", "spec/models/#{user_singular_name}_spec.rb"
|
49
|
+
m.template "tests/rspec/users_controller.rb", "spec/controllers/#{user_plural_name}_controller_spec.rb"
|
50
|
+
m.template "tests/rspec/sessions_controller.rb", "spec/controllers/#{sessions_underscore_name}_controller_spec.rb"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def user_singular_name
|
55
|
+
user_name.underscore
|
56
|
+
end
|
57
|
+
|
58
|
+
def user_plural_name
|
59
|
+
user_singular_name.pluralize
|
60
|
+
end
|
61
|
+
|
62
|
+
def user_class_name
|
63
|
+
user_name.camelize
|
64
|
+
end
|
65
|
+
|
66
|
+
def user_plural_class_name
|
67
|
+
user_plural_name.camelize
|
68
|
+
end
|
69
|
+
|
70
|
+
def sessions_underscore_name
|
71
|
+
sessions_name.underscore
|
72
|
+
end
|
73
|
+
|
74
|
+
def sessions_class_name
|
75
|
+
sessions_name.camelize
|
76
|
+
end
|
77
|
+
|
78
|
+
def application_controller_name
|
79
|
+
Rails.version >= '2.3.0' ? 'application_controller' : 'application'
|
80
|
+
end
|
81
|
+
|
82
|
+
protected
|
83
|
+
|
84
|
+
def view_language
|
85
|
+
'haml'
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_framework
|
89
|
+
:rspec
|
90
|
+
end
|
91
|
+
|
92
|
+
def add_options!(opt)
|
93
|
+
end
|
94
|
+
|
95
|
+
def banner
|
96
|
+
<<-EOS
|
97
|
+
Creates user model and controllers to handle registration and authentication.
|
98
|
+
|
99
|
+
USAGE: #{$0} #{spec.name} [user_name] [sessions_controller_name]
|
100
|
+
EOS
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# This module is included in your application controller which makes
|
2
|
+
# several methods available to all controllers and views. Here's a
|
3
|
+
# common example you might add to your application layout file.
|
4
|
+
#
|
5
|
+
# <%% if logged_in? %>
|
6
|
+
# Welcome <%%= current_user.username %>! Not you?
|
7
|
+
# <%%= link_to "Log out", logout_path %>
|
8
|
+
# <%% else %>
|
9
|
+
# <%%= link_to "Sign up", signup_path %> or
|
10
|
+
# <%%= link_to "log in", login_path %>.
|
11
|
+
# <%% end %>
|
12
|
+
#
|
13
|
+
# You can also restrict unregistered users from accessing a controller using
|
14
|
+
# a before filter. For example.
|
15
|
+
#
|
16
|
+
# before_filter :login_required, :except => [:index, :show]
|
17
|
+
module Authentication
|
18
|
+
def self.included(controller)
|
19
|
+
controller.send :helper_method, :current_<%= user_singular_name %>, :logged_in?
|
20
|
+
controller.filter_parameter_logging :password
|
21
|
+
end
|
22
|
+
|
23
|
+
def current_<%= user_singular_name %>
|
24
|
+
@current_<%= user_singular_name %> ||= <%= user_class_name %>.find(session[:<%= user_singular_name %>_id]) if session[:<%= user_singular_name %>_id]
|
25
|
+
end
|
26
|
+
|
27
|
+
def logged_in?
|
28
|
+
current_<%= user_singular_name %>
|
29
|
+
end
|
30
|
+
|
31
|
+
def login_required
|
32
|
+
unless logged_in?
|
33
|
+
flash[:error] = "You must first log in or sign up before accessing this page."
|
34
|
+
redirect_to login_url
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# password: "secret"
|
2
|
+
one:
|
3
|
+
username: foo
|
4
|
+
email: foo@example.com
|
5
|
+
password_hash: 3488f5f7efecab14b91eb96169e5e1ee518a569f
|
6
|
+
password_salt: bef65e058905c379436d80d1a32e7374b139e7b0
|
7
|
+
|
8
|
+
two:
|
9
|
+
username: bar
|
10
|
+
email: bar@example.com
|
11
|
+
password_hash: 3488f5f7efecab14b91eb96169e5e1ee518a569f
|
12
|
+
password_salt: bef65e058905c379436d80d1a32e7374b139e7b0
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Create<%= user_plural_class_name %> < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :<%= user_plural_name %> do |t|
|
4
|
+
t.column :username, :string
|
5
|
+
t.column :email, :string
|
6
|
+
t.column :password_hash, :string
|
7
|
+
t.column :password_salt, :string
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.down
|
13
|
+
drop_table :<%= user_plural_name %>
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class <%= sessions_class_name %>Controller < ApplicationController
|
2
|
+
def new
|
3
|
+
end
|
4
|
+
|
5
|
+
def create
|
6
|
+
<%= user_singular_name %> = <%= user_class_name %>.authenticate(params[:login], params[:password])
|
7
|
+
if <%= user_singular_name %>
|
8
|
+
session[:<%= user_singular_name %>_id] = <%= user_singular_name %>.id
|
9
|
+
flash[:notice] = "Logged in successfully."
|
10
|
+
redirect_to root_url
|
11
|
+
else
|
12
|
+
flash.now[:error] = "Invalid login or password."
|
13
|
+
render :action => 'new'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def destroy
|
18
|
+
session[:<%= user_singular_name %>_id] = nil
|
19
|
+
flash[:notice] = "You have been logged out."
|
20
|
+
redirect_to root_url
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe <%= sessions_class_name %>Controller do
|
4
|
+
fixtures :all
|
5
|
+
integrate_views
|
6
|
+
|
7
|
+
it "new action should render new template" do
|
8
|
+
get :new
|
9
|
+
response.should render_template(:new)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "create action should render new template when authentication is invalid" do
|
13
|
+
<%= user_class_name %>.stubs(:authenticate).returns(nil)
|
14
|
+
post :create
|
15
|
+
response.should render_template(:new)
|
16
|
+
session['<%= user_singular_name %>_id'].should be_nil
|
17
|
+
end
|
18
|
+
|
19
|
+
it "create action should redirect when authentication is valid" do
|
20
|
+
<%= user_class_name %>.stubs(:authenticate).returns(<%= user_class_name %>.first)
|
21
|
+
post :create
|
22
|
+
response.should redirect_to(root_url)
|
23
|
+
session['<%= user_singular_name %>_id'].should == <%= user_class_name %>.first.id
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe <%= user_class_name %> do
|
4
|
+
def new_<%= user_singular_name %>(attributes = {})
|
5
|
+
attributes[:username] ||= 'foo'
|
6
|
+
attributes[:email] ||= 'foo@example.com'
|
7
|
+
attributes[:password] ||= 'abc123'
|
8
|
+
attributes[:password_confirmation] ||= attributes[:password]
|
9
|
+
<%= user_class_name %>.new(attributes)
|
10
|
+
end
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
<%= user_class_name %>.delete_all
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should be valid" do
|
17
|
+
new_<%= user_singular_name %>.should be_valid
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should require username" do
|
21
|
+
new_<%= user_singular_name %>(:username => '').should have(1).error_on(:username)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should require password" do
|
25
|
+
new_<%= user_singular_name %>(:password => '').should have(1).error_on(:password)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should require well formed email" do
|
29
|
+
new_<%= user_singular_name %>(:email => 'foo@bar@example.com').should have(1).error_on(:email)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should validate uniqueness of email" do
|
33
|
+
new_<%= user_singular_name %>(:email => 'bar@example.com').save!
|
34
|
+
new_<%= user_singular_name %>(:email => 'bar@example.com').should have(1).error_on(:email)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should validate uniqueness of username" do
|
38
|
+
new_<%= user_singular_name %>(:username => 'uniquename').save!
|
39
|
+
new_<%= user_singular_name %>(:username => 'uniquename').should have(1).error_on(:username)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should not allow odd characters in username" do
|
43
|
+
new_<%= user_singular_name %>(:username => 'odd ^&(@)').should have(1).error_on(:username)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should validate password is longer than 3 characters" do
|
47
|
+
new_<%= user_singular_name %>(:password => 'bad').should have(1).error_on(:password)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should require matching password confirmation" do
|
51
|
+
new_<%= user_singular_name %>(:password_confirmation => 'nonmatching').should have(1).error_on(:password)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should generate password hash and salt on create" do
|
55
|
+
<%= user_singular_name %> = new_<%= user_singular_name %>
|
56
|
+
<%= user_singular_name %>.save!
|
57
|
+
<%= user_singular_name %>.password_hash.should_not be_nil
|
58
|
+
<%= user_singular_name %>.password_salt.should_not be_nil
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should authenticate by username" do
|
62
|
+
<%= user_singular_name %> = new_<%= user_singular_name %>(:username => 'foobar', :password => 'secret')
|
63
|
+
<%= user_singular_name %>.save!
|
64
|
+
<%= user_class_name %>.authenticate('foobar', 'secret').should == <%= user_singular_name %>
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should authenticate by email" do
|
68
|
+
<%= user_singular_name %> = new_<%= user_singular_name %>(:email => 'foo@bar.com', :password => 'secret')
|
69
|
+
<%= user_singular_name %>.save!
|
70
|
+
<%= user_class_name %>.authenticate('foo@bar.com', 'secret').should == <%= user_singular_name %>
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should not authenticate bad username" do
|
74
|
+
<%= user_class_name %>.authenticate('nonexisting', 'secret').should be_nil
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should not authenticate bad password" do
|
78
|
+
new_<%= user_singular_name %>(:username => 'foobar', :password => 'secret').save!
|
79
|
+
<%= user_class_name %>.authenticate('foobar', 'badpassword').should be_nil
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe <%= user_plural_class_name %>Controller do
|
4
|
+
fixtures :all
|
5
|
+
integrate_views
|
6
|
+
|
7
|
+
it "new action should render new template" do
|
8
|
+
get :new
|
9
|
+
response.should render_template(:new)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "create action should render new template when model is invalid" do
|
13
|
+
<%= user_class_name %>.any_instance.stubs(:valid?).returns(false)
|
14
|
+
post :create
|
15
|
+
response.should render_template(:new)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "create action should redirect when model is valid" do
|
19
|
+
<%= user_class_name %>.any_instance.stubs(:valid?).returns(true)
|
20
|
+
post :create
|
21
|
+
response.should redirect_to(root_url)
|
22
|
+
session['<%= user_singular_name %>_id'].should == assigns['<%= user_singular_name %>'].id
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class <%= user_class_name %> < ActiveRecord::Base
|
2
|
+
# new columns need to be added here to be writable through mass assignment
|
3
|
+
attr_accessible :username, :email, :password, :password_confirmation
|
4
|
+
|
5
|
+
attr_accessor :password
|
6
|
+
before_save :prepare_password
|
7
|
+
|
8
|
+
validates_presence_of :username
|
9
|
+
validates_uniqueness_of :username, :email, :allow_blank => true
|
10
|
+
validates_format_of :username, :with => /^[-\w\._@]+$/i, :allow_blank => true, :message => "should only contain letters, numbers, or .-_@"
|
11
|
+
validates_format_of :email, :with => /^[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}$/i
|
12
|
+
validates_presence_of :password, :on => :create
|
13
|
+
validates_confirmation_of :password
|
14
|
+
validates_length_of :password, :minimum => 4, :allow_blank => true
|
15
|
+
|
16
|
+
# login can be either username or email address
|
17
|
+
def self.authenticate(login, pass)
|
18
|
+
<%= user_singular_name %> = find_by_username(login) || find_by_email(login)
|
19
|
+
return <%= user_singular_name %> if <%= user_singular_name %> && <%= user_singular_name %>.matching_password?(pass)
|
20
|
+
end
|
21
|
+
|
22
|
+
def matching_password?(pass)
|
23
|
+
self.password_hash == encrypt_password(pass)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def prepare_password
|
29
|
+
unless password.blank?
|
30
|
+
self.password_salt = Digest::SHA1.hexdigest([Time.now, rand].join)
|
31
|
+
self.password_hash = encrypt_password(password)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def encrypt_password(pass)
|
36
|
+
Digest::SHA1.hexdigest([pass, password_salt].join)
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class <%= user_plural_class_name %>Controller < ApplicationController
|
2
|
+
def new
|
3
|
+
@<%= user_singular_name %> = <%= user_class_name %>.new
|
4
|
+
end
|
5
|
+
|
6
|
+
def create
|
7
|
+
@<%= user_singular_name %> = <%= user_class_name %>.new(params[:<%= user_singular_name %>])
|
8
|
+
if @<%= user_singular_name %>.save
|
9
|
+
session[:<%= user_singular_name %>_id] = @<%= user_singular_name %>.id
|
10
|
+
flash[:notice] = "Thank you for signing up! You are now logged in."
|
11
|
+
redirect_to root_url
|
12
|
+
else
|
13
|
+
render :action => 'new'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
- title "Log in"
|
2
|
+
|
3
|
+
%p== Don't have an account? #{link_to "Sign up!", signup_path}
|
4
|
+
|
5
|
+
- form_tag <%= sessions_underscore_name %>_path do
|
6
|
+
%p
|
7
|
+
= label_tag :login, "Username or Email Address"
|
8
|
+
%br
|
9
|
+
= text_field_tag :login, params[:login]
|
10
|
+
%p
|
11
|
+
= label_tag :password
|
12
|
+
%br
|
13
|
+
= password_field_tag :password
|
14
|
+
%p
|
15
|
+
= submit_tag "Log in"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
- title "Sign up"
|
2
|
+
|
3
|
+
%p== Already have an account? #{link_to "Log in", login_path}.
|
4
|
+
|
5
|
+
- form_for @<%= user_singular_name %> do |f|
|
6
|
+
= f.error_messages
|
7
|
+
%p
|
8
|
+
= f.label :username
|
9
|
+
%br
|
10
|
+
= f.text_field :username
|
11
|
+
%p
|
12
|
+
= f.label :email, "Email Address"
|
13
|
+
%br
|
14
|
+
= f.text_field :email
|
15
|
+
%p
|
16
|
+
= f.label :password
|
17
|
+
%br
|
18
|
+
= f.password_field :password
|
19
|
+
%p
|
20
|
+
= f.label :password_confirmation, "Confirm Password"
|
21
|
+
%br
|
22
|
+
= f.password_field :password_confirmation
|
23
|
+
%p
|
24
|
+
= f.submit "Sign up"
|
data/rotten-generators.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{rotten-generators}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.7.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Peter Coulton"]
|
9
|
-
s.date = %q{2009-06-
|
9
|
+
s.date = %q{2009-06-25}
|
10
10
|
s.email = %q{peter@petercoulton.com}
|
11
11
|
s.extra_rdoc_files = [
|
12
12
|
"LICENSE",
|
@@ -24,6 +24,21 @@ Gem::Specification.new do |s|
|
|
24
24
|
"features/step_definitions/rotten_steps.rb",
|
25
25
|
"features/support/env.rb",
|
26
26
|
"lib/rotten_generators.rb",
|
27
|
+
"rails_generators/rotten_authentication/lib/insert_commands.rb",
|
28
|
+
"rails_generators/rotten_authentication/rotten_authentication_generator.rb",
|
29
|
+
"rails_generators/rotten_authentication/templates/authentication.rb",
|
30
|
+
"rails_generators/rotten_authentication/templates/fixtures.yml",
|
31
|
+
"rails_generators/rotten_authentication/templates/migration.rb",
|
32
|
+
"rails_generators/rotten_authentication/templates/sessions_controller.rb",
|
33
|
+
"rails_generators/rotten_authentication/templates/sessions_helper.rb",
|
34
|
+
"rails_generators/rotten_authentication/templates/tests/rspec/sessions_controller.rb",
|
35
|
+
"rails_generators/rotten_authentication/templates/tests/rspec/user.rb",
|
36
|
+
"rails_generators/rotten_authentication/templates/tests/rspec/users_controller.rb",
|
37
|
+
"rails_generators/rotten_authentication/templates/user.rb",
|
38
|
+
"rails_generators/rotten_authentication/templates/users_controller.rb",
|
39
|
+
"rails_generators/rotten_authentication/templates/users_helper.rb",
|
40
|
+
"rails_generators/rotten_authentication/templates/views/haml/login.html.haml",
|
41
|
+
"rails_generators/rotten_authentication/templates/views/haml/signup.html.haml",
|
27
42
|
"rails_generators/rotten_controller/rotten_controller_generator.rb",
|
28
43
|
"rails_generators/rotten_controller/templates/controller.rb",
|
29
44
|
"rails_generators/rotten_controller/templates/controller_spec.rb",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: PeterCoulton-rotten-generators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Coulton
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-25 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -34,6 +34,21 @@ files:
|
|
34
34
|
- features/step_definitions/rotten_steps.rb
|
35
35
|
- features/support/env.rb
|
36
36
|
- lib/rotten_generators.rb
|
37
|
+
- rails_generators/rotten_authentication/lib/insert_commands.rb
|
38
|
+
- rails_generators/rotten_authentication/rotten_authentication_generator.rb
|
39
|
+
- rails_generators/rotten_authentication/templates/authentication.rb
|
40
|
+
- rails_generators/rotten_authentication/templates/fixtures.yml
|
41
|
+
- rails_generators/rotten_authentication/templates/migration.rb
|
42
|
+
- rails_generators/rotten_authentication/templates/sessions_controller.rb
|
43
|
+
- rails_generators/rotten_authentication/templates/sessions_helper.rb
|
44
|
+
- rails_generators/rotten_authentication/templates/tests/rspec/sessions_controller.rb
|
45
|
+
- rails_generators/rotten_authentication/templates/tests/rspec/user.rb
|
46
|
+
- rails_generators/rotten_authentication/templates/tests/rspec/users_controller.rb
|
47
|
+
- rails_generators/rotten_authentication/templates/user.rb
|
48
|
+
- rails_generators/rotten_authentication/templates/users_controller.rb
|
49
|
+
- rails_generators/rotten_authentication/templates/users_helper.rb
|
50
|
+
- rails_generators/rotten_authentication/templates/views/haml/login.html.haml
|
51
|
+
- rails_generators/rotten_authentication/templates/views/haml/signup.html.haml
|
37
52
|
- rails_generators/rotten_controller/rotten_controller_generator.rb
|
38
53
|
- rails_generators/rotten_controller/templates/controller.rb
|
39
54
|
- rails_generators/rotten_controller/templates/controller_spec.rb
|