tonkapark-clearance 0.6.9.3 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.textile +11 -5
- data/README.textile +38 -37
- data/Rakefile +41 -19
- data/TODO.textile +4 -3
- data/app/controllers/clearance/confirmations_controller.rb +27 -6
- data/app/controllers/clearance/passwords_controller.rb +1 -1
- data/app/controllers/clearance/sessions_controller.rb +1 -1
- data/app/controllers/clearance/users_controller.rb +3 -4
- data/app/models/clearance_mailer.rb +3 -25
- data/app/views/passwords/edit.html.erb +12 -14
- data/app/views/passwords/new.html.erb +9 -10
- data/app/views/sessions/new.html.erb +26 -1
- data/app/views/users/_form.html.erb +13 -0
- data/app/views/users/new.html.erb +5 -3
- data/clearance.gemspec +20 -31
- data/config/clearance_routes.rb +7 -9
- data/generators/clearance/clearance_generator.rb +3 -30
- data/generators/clearance/templates/README +17 -17
- data/generators/clearance/templates/migrations/create_users.rb +0 -3
- data/generators/clearance/templates/migrations/update_users.rb +1 -4
- data/generators/clearance/templates/user.rb +0 -1
- data/generators/clearance_features/clearance_features_generator.rb +4 -4
- data/generators/clearance_features/templates/features/sign_up.feature +17 -0
- data/generators/clearance_views/USAGE +0 -0
- data/generators/clearance_views/clearance_views_generator.rb +27 -0
- data/generators/clearance_views/templates/formtastic/passwords/edit.html.erb +21 -0
- data/generators/clearance_views/templates/formtastic/passwords/new.html.erb +15 -0
- data/generators/clearance_views/templates/formtastic/sessions/new.html.erb +22 -0
- data/generators/clearance_views/templates/formtastic/users/_inputs.html.erb +6 -0
- data/generators/clearance_views/templates/formtastic/users/new.html.erb +10 -0
- data/lib/clearance/authentication.rb +70 -32
- data/lib/clearance/user.rb +87 -32
- data/lib/clearance.rb +0 -1
- data/shoulda_macros/clearance.rb +6 -0
- metadata +23 -32
- data/app/controllers/clearance/invitations_controller.rb +0 -40
- data/app/views/clearance_mailer/invitation.html.erb +0 -3
- data/app/views/invitations/index.html.erb +0 -19
- data/app/views/invitations/new.html.erb +0 -15
- data/app/views/users/_user.html.erb +0 -28
- data/generators/clearance/templates/invitation.rb +0 -4
- data/generators/clearance/templates/migrations/create_invitations.rb +0 -20
- data/generators/clearance/templates/migrations/update_invitations.rb +0 -40
- data/lib/clearance/invitation.rb +0 -87
data/lib/clearance.rb
CHANGED
data/shoulda_macros/clearance.rb
CHANGED
@@ -132,6 +132,12 @@ module Clearance
|
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
|
+
def should_redirect_to_url_already_confirmed
|
136
|
+
should_redirect_to("the already confirmed url") do
|
137
|
+
@controller.send(:url_already_confirmed)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
135
141
|
# VALIDATIONS
|
136
142
|
|
137
143
|
def should_validate_confirmation_of(attribute, opts = {})
|
metadata
CHANGED
@@ -1,34 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tonkapark-clearance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
- Mike Burns
|
9
|
-
- Jason Morrison
|
10
|
-
- Joe Ferris
|
11
|
-
- Eugene Bolshakov
|
12
|
-
- Nick Quaranto
|
13
|
-
- Josh Nichols
|
14
|
-
- Mike Breen
|
15
|
-
- "Marcel G\xC3\xB6rner"
|
16
|
-
- Bence Nagy
|
17
|
-
- Ben Mabey
|
18
|
-
- Eloy Duran
|
19
|
-
- Tim Pope
|
20
|
-
- Mihai Anca
|
21
|
-
- Mark Cornick
|
22
|
-
- Shay Arnett
|
7
|
+
- Matt Anderson
|
23
8
|
autorequire:
|
24
9
|
bindir: bin
|
25
10
|
cert_chain: []
|
26
11
|
|
27
|
-
date: 2009-
|
12
|
+
date: 2009-08-26 22:00:00 -07:00
|
28
13
|
default_executable:
|
29
14
|
dependencies: []
|
30
15
|
|
31
|
-
description: Rails authentication with email & password
|
16
|
+
description: Rails authentication with email & password.
|
32
17
|
email: matt@tonkapark.com
|
33
18
|
executables: []
|
34
19
|
|
@@ -53,7 +38,6 @@ files:
|
|
53
38
|
- app/controllers
|
54
39
|
- app/controllers/clearance
|
55
40
|
- app/controllers/clearance/confirmations_controller.rb
|
56
|
-
- app/controllers/clearance/invitations_controller.rb
|
57
41
|
- app/controllers/clearance/passwords_controller.rb
|
58
42
|
- app/controllers/clearance/sessions_controller.rb
|
59
43
|
- app/controllers/clearance/users_controller.rb
|
@@ -63,7 +47,6 @@ files:
|
|
63
47
|
- app/views/clearance_mailer
|
64
48
|
- app/views/clearance_mailer/change_password.html.erb
|
65
49
|
- app/views/clearance_mailer/confirmation.html.erb
|
66
|
-
- app/views/clearance_mailer/invitation.html.erb
|
67
50
|
- app/views/passwords
|
68
51
|
- app/views/passwords/edit.html.erb
|
69
52
|
- app/views/passwords/new.html.erb
|
@@ -71,10 +54,7 @@ files:
|
|
71
54
|
- app/views/sessions/new.html.erb
|
72
55
|
- app/views/users
|
73
56
|
- app/views/users/new.html.erb
|
74
|
-
- app/views/users/
|
75
|
-
- app/views/invitations
|
76
|
-
- app/views/invitations/new.html.erb
|
77
|
-
- app/views/invitations/index.html.erb
|
57
|
+
- app/views/users/_form.html.erb
|
78
58
|
- config/clearance_routes.rb
|
79
59
|
- generators/clearance
|
80
60
|
- generators/clearance/clearance_generator.rb
|
@@ -86,11 +66,8 @@ files:
|
|
86
66
|
- generators/clearance/templates/migrations
|
87
67
|
- generators/clearance/templates/migrations/create_users.rb
|
88
68
|
- generators/clearance/templates/migrations/update_users.rb
|
89
|
-
- generators/clearance/templates/migrations/create_invitations.rb
|
90
|
-
- generators/clearance/templates/migrations/update_invitations.rb
|
91
69
|
- generators/clearance/templates/README
|
92
70
|
- generators/clearance/templates/user.rb
|
93
|
-
- generators/clearance/templates/invitation.rb
|
94
71
|
- generators/clearance/USAGE
|
95
72
|
- generators/clearance_features
|
96
73
|
- generators/clearance_features/clearance_features_generator.rb
|
@@ -106,19 +83,33 @@ files:
|
|
106
83
|
- generators/clearance_features/templates/features/support
|
107
84
|
- generators/clearance_features/templates/features/support/paths.rb
|
108
85
|
- generators/clearance_features/USAGE
|
86
|
+
- generators/clearance_views
|
87
|
+
- generators/clearance_views/clearance_views_generator.rb
|
88
|
+
- generators/clearance_views/templates
|
89
|
+
- generators/clearance_views/templates/formtastic
|
90
|
+
- generators/clearance_views/templates/formtastic/passwords
|
91
|
+
- generators/clearance_views/templates/formtastic/passwords/edit.html.erb
|
92
|
+
- generators/clearance_views/templates/formtastic/passwords/new.html.erb
|
93
|
+
- generators/clearance_views/templates/formtastic/sessions
|
94
|
+
- generators/clearance_views/templates/formtastic/sessions/new.html.erb
|
95
|
+
- generators/clearance_views/templates/formtastic/users
|
96
|
+
- generators/clearance_views/templates/formtastic/users/new.html.erb
|
97
|
+
- generators/clearance_views/templates/formtastic/users/_inputs.html.erb
|
98
|
+
- generators/clearance_views/USAGE
|
109
99
|
- lib/clearance
|
110
100
|
- lib/clearance/authentication.rb
|
111
101
|
- lib/clearance/extensions
|
112
102
|
- lib/clearance/extensions/errors.rb
|
113
103
|
- lib/clearance/extensions/rescue.rb
|
114
104
|
- lib/clearance/extensions/routes.rb
|
115
|
-
- lib/clearance/invitation.rb
|
116
105
|
- lib/clearance/user.rb
|
117
106
|
- lib/clearance.rb
|
118
107
|
- shoulda_macros/clearance.rb
|
119
108
|
- rails/init.rb
|
120
109
|
has_rdoc: true
|
121
|
-
homepage: http://github.com/
|
110
|
+
homepage: http://github.com/thoughtbot/clearance
|
111
|
+
licenses: []
|
112
|
+
|
122
113
|
post_install_message:
|
123
114
|
rdoc_options: []
|
124
115
|
|
@@ -139,9 +130,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
130
|
requirements: []
|
140
131
|
|
141
132
|
rubyforge_project:
|
142
|
-
rubygems_version: 1.
|
133
|
+
rubygems_version: 1.3.5
|
143
134
|
signing_key:
|
144
135
|
specification_version: 3
|
145
|
-
summary: Rails authentication with email & password.
|
136
|
+
summary: Forked thoughbot/clearance. Rails authentication with email & password.
|
146
137
|
test_files: []
|
147
138
|
|
@@ -1,40 +0,0 @@
|
|
1
|
-
class Clearance::InvitationsController < ApplicationController
|
2
|
-
unloadable
|
3
|
-
|
4
|
-
before_filter :redirect_to_root, :only => [:new, :create], :if => :signed_in?
|
5
|
-
before_filter :admin_only, :only => [:index]
|
6
|
-
|
7
|
-
def index
|
8
|
-
@invitations = ::Invitation.all
|
9
|
-
render :template => 'invitations/index'
|
10
|
-
end
|
11
|
-
|
12
|
-
def new
|
13
|
-
@invitation = ::Invitation.new(params[:invitation])
|
14
|
-
render :template => 'invitations/new'
|
15
|
-
end
|
16
|
-
|
17
|
-
def create
|
18
|
-
@invitation = ::Invitation.new(params[:invitation])
|
19
|
-
@invitation.sender = current_user
|
20
|
-
if @invitation.save
|
21
|
-
if signed_in?
|
22
|
-
::ClearanceMailer.deliver_invitation(@invitation, signup_url(@invitation.token))
|
23
|
-
flash[:notice] = "Thank you, an invitation has been sent."
|
24
|
-
redirect_to root_url
|
25
|
-
else
|
26
|
-
flash[:notice] = "Thank you for your interest, your invitation has been received."
|
27
|
-
redirect_to root_url
|
28
|
-
end
|
29
|
-
else
|
30
|
-
render :action => 'new'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
def admin_only
|
36
|
-
unless current_user.admin?
|
37
|
-
redirect_to root_url
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
<h2>Invitations</h2>
|
2
|
-
|
3
|
-
<table>
|
4
|
-
<tr>
|
5
|
-
<th>Recipient</th>
|
6
|
-
<th>Invited At</th>
|
7
|
-
<th>Redeemed At</th>
|
8
|
-
<th></th>
|
9
|
-
</tr>
|
10
|
-
|
11
|
-
<% @invitations.each do |invite| %>
|
12
|
-
<tr>
|
13
|
-
<td><%= invite.recipient_email %></td>
|
14
|
-
<td><%= invite.invited_at %></td>
|
15
|
-
<td><%= invite.redeemed_at %></td>
|
16
|
-
<td><%= link_to "Redeem Link", signup_url(invite.token) %></td>
|
17
|
-
</tr>
|
18
|
-
<% end %>
|
19
|
-
</table>
|
@@ -1,15 +0,0 @@
|
|
1
|
-
<h2>Request Invitation</h2>
|
2
|
-
|
3
|
-
<% form_for @invitation do |f| %>
|
4
|
-
<%= f.error_messages %>
|
5
|
-
<ul>
|
6
|
-
<li>
|
7
|
-
<%= f.label :recipient_email, "Your Email" %><br />
|
8
|
-
<p class="instructions">This email will be used for your account.</p>
|
9
|
-
<%= f.text_field :recipient_email, {:class => "big"} %>
|
10
|
-
</li>
|
11
|
-
</ul>
|
12
|
-
<p><%= f.submit "Submit" %></p>
|
13
|
-
<% end %>
|
14
|
-
|
15
|
-
|
@@ -1,28 +0,0 @@
|
|
1
|
-
|
2
|
-
<% form_for(@user, :html => {:id => "user_form"}) do |form| %>
|
3
|
-
|
4
|
-
<%= form.error_messages %>
|
5
|
-
|
6
|
-
<ul>
|
7
|
-
<li>
|
8
|
-
<label for="user_email">Email <small>We'll keep it a secret.</small></label>
|
9
|
-
<%= form.text_field :email, {:class => "big"} %>
|
10
|
-
</li>
|
11
|
-
|
12
|
-
<li>
|
13
|
-
<%= form.label :password %>
|
14
|
-
<%= form.password_field :password, {:class => "big"} %>
|
15
|
-
</li>
|
16
|
-
|
17
|
-
<li>
|
18
|
-
<%= form.label :password_confirmation, "Confirm password" %>
|
19
|
-
<%= form.password_field :password_confirmation, {:class => "big"} %>
|
20
|
-
</li>
|
21
|
-
|
22
|
-
<% if @user.new_record? %>
|
23
|
-
<%= form.hidden_field :invitation_token %>
|
24
|
-
<% end %>
|
25
|
-
|
26
|
-
<li class="submit"><%= form.submit button_name, :disable_with => 'Please wait...' %> | <% if @user.new_record? %><%= link_to 'Cancel', root_url %><% else %><%= link_to 'Sign In', signin_path %><% end %></li>
|
27
|
-
</ul>
|
28
|
-
<% end %>
|
@@ -1,20 +0,0 @@
|
|
1
|
-
class ClearanceCreateInvitations < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table(:invitations) do |t|
|
4
|
-
t.integer :sender_id
|
5
|
-
t.string :recipient_email
|
6
|
-
t.string :token
|
7
|
-
t.datetime :invited_at
|
8
|
-
t.datetime :redeemed_at
|
9
|
-
t.timestamps
|
10
|
-
end
|
11
|
-
|
12
|
-
add_index :invitations, [:id, :token]
|
13
|
-
add_index :invitations, :recipient_email
|
14
|
-
add_index :invitations, :token
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.down
|
18
|
-
drop_table :invitations
|
19
|
-
end
|
20
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
class ClearanceUpdateUsers < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
<%
|
4
|
-
existing_columns = ActiveRecord::Base.connection.columns(:users).collect { |each| each.name }
|
5
|
-
columns = [
|
6
|
-
[:sender_id, 't.integer :sender_id'],
|
7
|
-
[:recipient_email, 't.string :recipient_email, :limit => 128'],
|
8
|
-
[:token, 't.string :token, :limit => 128'],
|
9
|
-
[:invited_at, 't.datetime :invited_at'],
|
10
|
-
[:redeemed_at, 't.datetime :redeemed_at']
|
11
|
-
].delete_if {|c| existing_columns.include?(c.first.to_s)}
|
12
|
-
-%>
|
13
|
-
change_table(:users) do |t|
|
14
|
-
<% columns.each do |c| -%>
|
15
|
-
<%= c.last %>
|
16
|
-
<% end -%>
|
17
|
-
end
|
18
|
-
|
19
|
-
<%
|
20
|
-
existing_indexes = ActiveRecord::Base.connection.indexes(:users)
|
21
|
-
index_names = existing_indexes.collect { |each| each.name }
|
22
|
-
new_indexes = [
|
23
|
-
[:index_invitations_on_id_and_token, 'add_index :invitations, [:id, :token]'],
|
24
|
-
[:index_invitations_on_email, 'add_index :invitations, :recipient_email'],
|
25
|
-
[:index_invitations_on_token, 'add_index :invitations, :token']
|
26
|
-
].delete_if { |each| index_names.include?(each.first.to_s) }
|
27
|
-
-%>
|
28
|
-
<% new_indexes.each do |each| -%>
|
29
|
-
<%= each.last %>
|
30
|
-
<% end -%>
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.down
|
34
|
-
change_table(:invitations) do |t|
|
35
|
-
<% unless columns.empty? -%>
|
36
|
-
t.remove <%= columns.collect { |each| ":#{each.first}" }.join(',') %>
|
37
|
-
<% end -%>
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
data/lib/clearance/invitation.rb
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
module Clearance
|
2
|
-
module Invitation
|
3
|
-
|
4
|
-
def self.included(model)
|
5
|
-
model.extend(ClassMethods)
|
6
|
-
|
7
|
-
model.send(:include, InstanceMethods)
|
8
|
-
model.send(:include, AttrAccessible)
|
9
|
-
model.send(:include, AttrAccessor)
|
10
|
-
model.send(:include, Validations)
|
11
|
-
model.send(:include, Callbacks)
|
12
|
-
end
|
13
|
-
|
14
|
-
module AttrAccessible
|
15
|
-
def self.included(model)
|
16
|
-
model.class_eval do
|
17
|
-
attr_accessible :recipient_email
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
module AttrAccessor
|
23
|
-
def self.included(model)
|
24
|
-
model.class_eval do
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
module Validations
|
31
|
-
def self.included(model)
|
32
|
-
model.class_eval do
|
33
|
-
validates_presence_of :recipient_email
|
34
|
-
validates_format_of :recipient_email, :with => %r{.+@.+\..+}
|
35
|
-
|
36
|
-
validate :recipient_is_not_registered
|
37
|
-
validate :sender_has_invitations, :if => :sender
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
module Callbacks
|
43
|
-
def self.included(model)
|
44
|
-
model.class_eval do
|
45
|
-
before_create :generate_token
|
46
|
-
before_create :decrement_sender_count, :if => :sender
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
module InstanceMethods
|
52
|
-
|
53
|
-
def redeemed!
|
54
|
-
self.redeemed_at = Time.now.utc
|
55
|
-
self.save!
|
56
|
-
end
|
57
|
-
|
58
|
-
def self.find_redeemable(invitation_code)
|
59
|
-
self.find(:first, :conditions => {:redeemed_at => nil, :token => invitation_code})
|
60
|
-
end
|
61
|
-
|
62
|
-
protected
|
63
|
-
|
64
|
-
def recipient_is_not_registered
|
65
|
-
errors.add :recipient_email, 'is already registered' if ::User.find_by_email(recipient_email)
|
66
|
-
end
|
67
|
-
|
68
|
-
def sender_has_invitations
|
69
|
-
unless sender.invitation_limit > 0
|
70
|
-
errors.add_to_base 'You have reached your limit of invitations to send.'
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def generate_token
|
75
|
-
self.token = Digest::SHA1.hexdigest([Time.now, rand].join)
|
76
|
-
end
|
77
|
-
|
78
|
-
def decrement_sender_count
|
79
|
-
sender.decrement! :invitation_limit
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
module ClassMethods
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
end
|