hero_generator 0.0.1.beta8 → 0.0.1.beta9
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/lib/generators/hero/authentication/authentication_generator.rb +3 -2
- data/lib/generators/hero/authentication/templates/controllers/users_controller.rb +1 -1
- data/lib/generators/hero/authentication/templates/helpers/application_helper.rb +2 -0
- data/lib/generators/hero/authentication/templates/models/auth_user.rb +149 -0
- data/lib/generators/hero/authentication/templates/models/user.rb +4 -143
- data/lib/generators/hero/authentication/templates/tests/spec/factories.rb +0 -9
- data/lib/generators/hero/authentication/templates/tests/spec/requests/new_email_request_spec.rb +4 -2
- data/lib/generators/hero/authentication/templates/tests/spec/requests/password_resets_spec.rb +4 -4
- data/lib/generators/hero/authentication/templates/tests/spec/requests/user_confirmation_spec.rb +5 -5
- data/lib/generators/hero/authentication/templates/tests/spec/requests/user_sign_in_spec.rb +1 -1
- data/lib/generators/hero/authentication/templates/tests/spec/requests/user_sign_up_spec.rb +10 -10
- data/lib/generators/hero/authentication/templates/views/confirmation/registration.html.haml +1 -1
- data/lib/generators/hero/authentication/templates/views/confirmation/resend_signup_token.html.haml +2 -2
- metadata +10 -8
@@ -13,6 +13,7 @@ module Hero
|
|
13
13
|
|
14
14
|
|
15
15
|
def create_model_files
|
16
|
+
template "models/auth_user.rb", "app/models/auth_user.rb"
|
16
17
|
template "models/user.rb", "app/models/#{user_singular_name}.rb"
|
17
18
|
template "models/authentication.rb", "app/models/authentication.rb"
|
18
19
|
end
|
@@ -85,9 +86,9 @@ module Hero
|
|
85
86
|
route "match 'settings/change_email' => 'settings#change_user_email', :as => 'change_email'"
|
86
87
|
route "get 'log_out' => '#{session_plural_name}#destroy', :as => 'log_out'"
|
87
88
|
route "get 'registrieren' => '#{user_plural_name}#new', :as => 'sign_up_form'"
|
88
|
-
route "post 'registrieren' => '#{user_plural_name}#create', :as => 'sign_up'"
|
89
|
-
route "match 'confirm/resend_confirmation' => 'confirmation#resend_signup_token', :as => 'resend_signup_token'"
|
89
|
+
route "post 'registrieren' => '#{user_plural_name}#create', :as => 'sign_up'"
|
90
90
|
route "match 'confirm/:action(/:token)', :controller => :confirmation, :as => 'confirm'"
|
91
|
+
route "match 'confirm/resend_confirmation' => 'confirmation#resend_signup_token', :as => 'resend_signup_token'"
|
91
92
|
route "get 'log_in' => '#{session_plural_name}#new', :as => 'log_in_link'"
|
92
93
|
route "post 'log_in' => '#{session_plural_name}#create', :as => 'log_in'"
|
93
94
|
route "match 'recover_password(/:token)' => 'confirmation#recover_password', :as => 'recover_password'"
|
@@ -15,7 +15,7 @@ class UsersController < ApplicationController
|
|
15
15
|
redirect_to root_url, :notice => t( '.users.create.flash.success' )
|
16
16
|
@user.send_registration
|
17
17
|
else
|
18
|
-
|
18
|
+
flash.now[:error] = t( '.users.create.flash.error' )
|
19
19
|
render :new
|
20
20
|
end
|
21
21
|
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
module AuthUser
|
2
|
+
|
3
|
+
def self.included(base)
|
4
|
+
base.has_secure_password
|
5
|
+
base.attr_accessible :email, :password, :password_confirmation, :new_email_confirmation, :set_new_email, :recover_password
|
6
|
+
attr_accessor :update_password, :new_email_confirmation, :set_new_email, :recover_password
|
7
|
+
|
8
|
+
base.validates_presence_of :email
|
9
|
+
base.validates_format_of :email, :with => EMAIL_REGEX,
|
10
|
+
:if => :should_validate_email_format?
|
11
|
+
base.validates_uniqueness_of :email, :unless => :confirmed_duplicate
|
12
|
+
|
13
|
+
base.validates_presence_of :password, :if => :should_validate_password?
|
14
|
+
base.validates_length_of :password, :if => :should_validate_password_length?,
|
15
|
+
:within => 3..30,
|
16
|
+
:too_short => 'too short message',
|
17
|
+
:too_long => 'too long message'
|
18
|
+
|
19
|
+
#set new email
|
20
|
+
base.validates_presence_of :new_email, :if => :should_validate_new_email?
|
21
|
+
base.validates_format_of :new_email, :with => EMAIL_REGEX,
|
22
|
+
:if => :should_validate_new_email_format?
|
23
|
+
|
24
|
+
base.validates_presence_of :new_email_confirmation, :if => :should_validate_new_email?
|
25
|
+
base.validates_confirmation_of :new_email, :if => :should_validate_new_email?
|
26
|
+
base.extend ClassMethods
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
module ClassMethods
|
31
|
+
def confirmed
|
32
|
+
where("confirmed IS NOT NULL")
|
33
|
+
end
|
34
|
+
|
35
|
+
def with_email(email)
|
36
|
+
where(:email => email)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def confirmed_duplicate
|
41
|
+
|
42
|
+
if ((self.class.name.constantize.confirmed.with_email(self.email).count == 0) || (self.class.name.constantize.with_email(self.email).count == 0))
|
43
|
+
true
|
44
|
+
else
|
45
|
+
self.id = self.class.name.constantize.confirmed.with_email(self.email).first.id
|
46
|
+
false
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def new_email=(new_email)
|
51
|
+
self[:new_email] = new_email if self.set_new_email.present?
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
def confirm_signup!
|
56
|
+
update_attribute(:confirmed, Time.now)
|
57
|
+
update_attribute(:signup_token, nil)
|
58
|
+
end
|
59
|
+
|
60
|
+
def confirm_password!(password="", password_confirmation="")
|
61
|
+
self.update_password = true
|
62
|
+
self.password = password
|
63
|
+
self.password_confirmation = password_confirmation
|
64
|
+
if self.save
|
65
|
+
update_attribute(:password, password)
|
66
|
+
update_attribute(:password_token, nil)
|
67
|
+
else
|
68
|
+
false
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def confirm_new_email!
|
73
|
+
update_attribute(:email, new_email)
|
74
|
+
update_attribute(:new_email_token, nil)
|
75
|
+
end
|
76
|
+
|
77
|
+
def confirmed?
|
78
|
+
!self.confirmed.nil?
|
79
|
+
end
|
80
|
+
|
81
|
+
# Wenn der User sich registriert, dann wird ein signup_token für ihn hinterlegt.
|
82
|
+
# Dieser Token wird per Mail verschickt. Der User kann sich nun per Klick auf den
|
83
|
+
# Tokenlink verifizieren. Sollte die Mail nicht mehr erreichbar sein, so kann der User
|
84
|
+
# unter Angabe seiner Email einen neuen signup_Token anfordern. Der alte Token ist
|
85
|
+
# ab diesem Zeitpunkt ungültig.
|
86
|
+
|
87
|
+
# Nach erfolgreicher Verifizierung der Email-Adresse) wird das
|
88
|
+
# Feld confirmed mit einem Datum gefüllt. Ab diesem Zeitpunkt kann keine neuer
|
89
|
+
# Confirmation-Token generiert und verschickt werden.
|
90
|
+
|
91
|
+
|
92
|
+
def should_validate_email_format?
|
93
|
+
email.present?
|
94
|
+
end
|
95
|
+
|
96
|
+
def should_validate_new_email?
|
97
|
+
set_new_email.present?
|
98
|
+
end
|
99
|
+
|
100
|
+
def should_validate_new_email_format?
|
101
|
+
set_new_email.present? && new_email.present?
|
102
|
+
end
|
103
|
+
|
104
|
+
def should_validate_password?
|
105
|
+
update_password
|
106
|
+
end
|
107
|
+
|
108
|
+
def should_validate_password_length?
|
109
|
+
(new_record? || update_password) && password.present?
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
def send_password_reset
|
114
|
+
return unless generate_token(:password_token)
|
115
|
+
tokenmail(:send_password_reset)
|
116
|
+
end
|
117
|
+
|
118
|
+
def send_registration
|
119
|
+
return unless generate_token(:signup_token)
|
120
|
+
tokenmail(:registration)
|
121
|
+
end
|
122
|
+
|
123
|
+
def resend_signup_token
|
124
|
+
return unless (!confirmed? && generate_token(:signup_token))
|
125
|
+
tokenmail(:resend_signup_token)
|
126
|
+
end
|
127
|
+
|
128
|
+
def send_new_email_request
|
129
|
+
return unless (confirmed? && generate_token(:new_email_token))
|
130
|
+
tokenmail(:new_email_request)
|
131
|
+
end
|
132
|
+
|
133
|
+
def send_new_email( new_email )
|
134
|
+
if self.set_new_email.present?
|
135
|
+
if self.save
|
136
|
+
send_new_email_request
|
137
|
+
self.set_new_email = false
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
private
|
143
|
+
|
144
|
+
def generate_token( token )
|
145
|
+
(defined?( token ) && update_attribute( token, SecureRandom.hex(13) ))? true : false
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
|
@@ -1,147 +1,8 @@
|
|
1
1
|
class User < ActiveRecord::Base
|
2
|
-
|
3
|
-
|
4
|
-
attr_accessible :email, :password, :password_confirmation, :new_email_confirmation, :set_new_email, :recover_password
|
5
|
-
|
6
|
-
attr_accessor :update_password, :new_email_confirmation, :set_new_email, :recover_password
|
7
|
-
|
8
|
-
validates_presence_of :email
|
9
|
-
validates_format_of :email, :with => EMAIL_REGEX,
|
10
|
-
:if => :should_validate_email_format?
|
11
|
-
validates_uniqueness_of :email, :unless => :confirmed_duplicate
|
12
|
-
|
13
|
-
validates_presence_of :password, :if => :should_validate_password?
|
14
|
-
validates_length_of :password, :if => :should_validate_password_length?,
|
15
|
-
:within => 3..30,
|
16
|
-
:too_short => 'too short message',
|
17
|
-
:too_long => 'too long message'
|
2
|
+
include AuthUser
|
18
3
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
:if => :should_validate_new_email_format?
|
23
|
-
|
24
|
-
validates_presence_of :new_email_confirmation, :if => :should_validate_new_email?
|
25
|
-
validates_confirmation_of :new_email, :if => :should_validate_new_email?
|
26
|
-
|
27
|
-
|
28
|
-
def new_email=(new_email)
|
29
|
-
self[:new_email] = new_email if self.set_new_email.present?
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
def confirm_signup!
|
34
|
-
update_attribute(:confirmed, Time.now)
|
35
|
-
update_attribute(:signup_token, nil)
|
36
|
-
end
|
37
|
-
|
38
|
-
def confirm_password!(password="", password_confirmation="")
|
39
|
-
self.update_password = true
|
40
|
-
self.password = password
|
41
|
-
self.password_confirmation = password_confirmation
|
42
|
-
if self.save
|
43
|
-
update_attribute(:password, password)
|
44
|
-
update_attribute(:password_token, nil)
|
45
|
-
else
|
46
|
-
false
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def confirm_new_email!
|
51
|
-
update_attribute(:email, new_email)
|
52
|
-
update_attribute(:new_email_token, nil)
|
53
|
-
end
|
54
|
-
|
55
|
-
def confirmed?
|
56
|
-
!self.confirmed.nil?
|
57
|
-
end
|
58
|
-
|
59
|
-
def self.confirmed
|
60
|
-
where("confirmed IS NOT NULL")
|
61
|
-
end
|
62
|
-
|
63
|
-
def self.with_email(email)
|
64
|
-
where(:email => email)
|
65
|
-
end
|
66
|
-
|
67
|
-
# Wenn der User sich registriert, dann wird ein signup_token für ihn hinterlegt.
|
68
|
-
# Dieser Token wird per Mail verschickt. Der User kann sich nun per Klick auf den
|
69
|
-
# Tokenlink verifizieren. Sollte die Mail nicht mehr erreichbar sein, so kann der User
|
70
|
-
# unter Angabe seiner Email einen neuen signup_Token anfordern. Der alte Token ist
|
71
|
-
# ab diesem Zeitpunkt ungültig.
|
72
|
-
|
73
|
-
# Nach erfolgreicher Verifizierung der Email-Adresse) wird das
|
74
|
-
# Feld confirmed mit einem Datum gefüllt. Ab diesem Zeitpunkt kann keine neuer
|
75
|
-
# Confirmation-Token generiert und verschickt werden.
|
76
|
-
|
77
|
-
def confirmed_duplicate
|
78
|
-
if ((User.confirmed.with_email(self.email).count == 0) || (User.with_email(self.email).count == 0))
|
79
|
-
true
|
80
|
-
else
|
81
|
-
self.id = User.confirmed.with_email(self.email).first.id
|
82
|
-
false
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def should_validate_email_format?
|
87
|
-
email.present?
|
88
|
-
end
|
89
|
-
|
90
|
-
def should_validate_new_email?
|
91
|
-
set_new_email.present?
|
92
|
-
end
|
93
|
-
|
94
|
-
def should_validate_new_email_format?
|
95
|
-
set_new_email.present? && new_email.present?
|
96
|
-
end
|
97
|
-
|
98
|
-
def should_validate_password?
|
99
|
-
update_password
|
100
|
-
end
|
101
|
-
|
102
|
-
def should_validate_password_length?
|
103
|
-
(new_record? || update_password) && password.present?
|
104
|
-
end
|
105
|
-
|
106
|
-
|
107
|
-
def send_password_reset
|
108
|
-
if generate_token(:password_token)
|
109
|
-
ConfirmationMailer.send_password_reset( self ).deliver
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def send_registration
|
114
|
-
if generate_token(:signup_token)
|
115
|
-
ConfirmationMailer.registration( self ).deliver
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def resend_signup_token
|
120
|
-
if !confirmed? && generate_token(:signup_token)
|
121
|
-
ConfirmationMailer.resend_signup_token( self ).deliver
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
def send_new_email_request
|
126
|
-
if generate_token(:new_email_token)
|
127
|
-
ConfirmationMailer.new_email_request( self ).deliver
|
128
|
-
end
|
129
|
-
end
|
4
|
+
def tokenmail(request)
|
5
|
+
ConfirmationMailer.send(request, self).deliver
|
6
|
+
end
|
130
7
|
|
131
|
-
def send_new_email( new_email )
|
132
|
-
if self.set_new_email.present?
|
133
|
-
if self.save
|
134
|
-
send_new_email_request
|
135
|
-
self.set_new_email = false
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
private
|
141
|
-
|
142
|
-
def generate_token( token )
|
143
|
-
(defined?( token ) && update_attribute( token, SecureRandom.hex(13) ))? true : false
|
144
|
-
end
|
145
8
|
end
|
146
|
-
|
147
|
-
|
@@ -1,11 +1,3 @@
|
|
1
|
-
#Factory.define :propertyname do |f|
|
2
|
-
# f.p0 "eins"
|
3
|
-
# f.p1 ""
|
4
|
-
# f.p2 ""
|
5
|
-
# f.p3 ""
|
6
|
-
#end
|
7
|
-
|
8
|
-
|
9
1
|
Factory.define :user do |u|
|
10
2
|
|
11
3
|
u.email { Factory.next(:email) }
|
@@ -13,7 +5,6 @@ Factory.define :user do |u|
|
|
13
5
|
u.password_confirmation 'secret'
|
14
6
|
end
|
15
7
|
|
16
|
-
|
17
8
|
Factory.sequence :email do |n|
|
18
9
|
names = %w[ joe bob sue ]
|
19
10
|
"#{names[rand names.count]}#{n}@somewhere.com"
|
data/lib/generators/hero/authentication/templates/tests/spec/requests/new_email_request_spec.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
|
3
4
|
describe "send new email" do
|
4
5
|
|
5
6
|
before(:each) do
|
6
|
-
@user = Factory(:user, :confirmed => Time.now)
|
7
|
+
@user = Factory(:user, :confirmed => Time.now)
|
7
8
|
visit log_in_path
|
8
9
|
fill_in "email", :with => @user.email
|
9
10
|
fill_in "password", :with => @user.password
|
@@ -12,7 +13,7 @@ describe "send new email" do
|
|
12
13
|
|
13
14
|
describe "GET index" do
|
14
15
|
it "send new email request" do
|
15
|
-
visit "/settings
|
16
|
+
visit "/settings"
|
16
17
|
new_email = "neue@example.com"
|
17
18
|
fill_in "user_new_email", :with => new_email
|
18
19
|
fill_in "user_new_email_confirmation", :with => new_email
|
@@ -55,6 +56,7 @@ describe "send new email" do
|
|
55
56
|
@user.new_email_confirmation = "new@email.de"
|
56
57
|
@user.send_new_email_request
|
57
58
|
@user.save
|
59
|
+
@user.email.should_not eq nil
|
58
60
|
|
59
61
|
visit new_email_path
|
60
62
|
fill_in "token", :with => @user.new_email_token
|
data/lib/generators/hero/authentication/templates/tests/spec/requests/password_resets_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe "PasswordResets" do
|
|
8
8
|
fill_in "email", :with => user.email
|
9
9
|
click_button "send_new_password_button"
|
10
10
|
current_path.should eq root_path
|
11
|
-
page.should have_content( I18n.t( "
|
11
|
+
page.should have_content( I18n.t( "confirmation.order_new_password.flash.success" ))
|
12
12
|
last_email.to.should include(user.email)
|
13
13
|
end
|
14
14
|
|
@@ -23,7 +23,7 @@ describe "PasswordResets" do
|
|
23
23
|
|
24
24
|
it "password recovery with password token form" do
|
25
25
|
user = Factory(:user, :password_token => "ein_kleiner_token")
|
26
|
-
visit
|
26
|
+
visit recover_password_path
|
27
27
|
fill_in "token", :with => user.password_token
|
28
28
|
click_button "password_token_button"
|
29
29
|
current_path.should eq recover_password_path
|
@@ -32,7 +32,7 @@ describe "PasswordResets" do
|
|
32
32
|
it "password recovery without valid token leads to token_form" do
|
33
33
|
params = { :token => 'den_token_gibt_es_nicht' }
|
34
34
|
visit recover_password_path
|
35
|
-
current_path.should eq
|
35
|
+
current_path.should eq recover_password_path
|
36
36
|
end
|
37
37
|
|
38
38
|
it "password recovery with valid token leads password recover form and user sets new pw" do
|
@@ -49,7 +49,7 @@ describe "PasswordResets" do
|
|
49
49
|
fill_in "password", :with => "geheim"
|
50
50
|
click_button "log_in_button"
|
51
51
|
current_path.should eq root_path
|
52
|
-
page.should have_content( I18n.t( "
|
52
|
+
page.should have_content( I18n.t( "sessions.create.flash.success" ))
|
53
53
|
end
|
54
54
|
|
55
55
|
|
data/lib/generators/hero/authentication/templates/tests/spec/requests/user_confirmation_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe "UserConfirmation" do
|
|
8
8
|
fill_in "user_password_confirmation", :with => "geheim"
|
9
9
|
click_button "sign_up_button"
|
10
10
|
current_path.should eq root_path
|
11
|
-
page.should have_content( I18n.t( "
|
11
|
+
page.should have_content( I18n.t( "users.create.flash.success" ))
|
12
12
|
last_email.to.should include("test@test.de")
|
13
13
|
end
|
14
14
|
|
@@ -18,7 +18,7 @@ describe "UserConfirmation" do
|
|
18
18
|
fill_in "token", :with => user.signup_token
|
19
19
|
click_button "token_button"
|
20
20
|
current_path.should eq log_in_path
|
21
|
-
page.should have_content( I18n.t( "
|
21
|
+
page.should have_content( I18n.t( "confirmation.registration.flash.success" ))
|
22
22
|
end
|
23
23
|
|
24
24
|
it "user not confirmed with false confirmation token" do
|
@@ -27,7 +27,7 @@ describe "UserConfirmation" do
|
|
27
27
|
fill_in "token", :with => "ein_anderer_token"
|
28
28
|
click_button "token_button"
|
29
29
|
current_path.should eq confirm_path(:action => :registration)
|
30
|
-
page.should have_content( I18n.t( "
|
30
|
+
page.should have_content( I18n.t( "confirmation.registration.flash.error" ))
|
31
31
|
end
|
32
32
|
|
33
33
|
it "user asks for new confirmation token" do
|
@@ -40,7 +40,7 @@ describe "UserConfirmation" do
|
|
40
40
|
click_button "resend_signup_token_button"
|
41
41
|
user = User.find(user.id)
|
42
42
|
last_email.to.should include(user.email)
|
43
|
-
page.should have_content( I18n.t( "
|
43
|
+
page.should have_content( I18n.t( "confirmation.resend_signup_token.flash.success" ))
|
44
44
|
user.signup_token.should_not eq "halloklaus2"
|
45
45
|
end
|
46
46
|
|
@@ -54,7 +54,7 @@ describe "UserConfirmation" do
|
|
54
54
|
click_button "resend_signup_token_button"
|
55
55
|
last_email.should eq nil
|
56
56
|
current_path.should eq log_in_path
|
57
|
-
page.should have_content( I18n.t( "
|
57
|
+
page.should have_content( I18n.t( "confirmation.resend_signup_token.flash.error" ))
|
58
58
|
end
|
59
59
|
|
60
60
|
|
@@ -7,7 +7,7 @@ describe "UserSignIn" do
|
|
7
7
|
fill_in "email", :with => user.email
|
8
8
|
fill_in "password", :with => user.password
|
9
9
|
click_button "log_in_button"
|
10
|
-
page.should have_content( I18n.t( "
|
10
|
+
page.should have_content( I18n.t( "sessions.create.flash.error.not_confirmed" ))
|
11
11
|
current_path.should eq confirm_path(:action => :registration)
|
12
12
|
end
|
13
13
|
end
|
@@ -8,17 +8,17 @@ describe "UserSignUp" do
|
|
8
8
|
fill_in "user_password", :with => "geheim"
|
9
9
|
fill_in "user_password_confirmation", :with => "geheim"
|
10
10
|
click_button "sign_up_button"
|
11
|
-
page.should have_content( I18n.t( "
|
11
|
+
page.should have_content( I18n.t( "users.create.flash.success" ))
|
12
12
|
current_path.should eq root_path
|
13
13
|
end
|
14
14
|
|
15
15
|
[
|
16
|
-
{:email => "test@test.de", :password => "", :password_confirmation => ""},
|
17
|
-
{:email => "test@test.de", :password => "geheim", :password_confirmation => ""},
|
18
|
-
{:email => "test@test.de", :password => "geheim", :password_confirmation => "gehei_"},
|
19
|
-
{:email => "test@test.de", :password => "", :password_confirmation => "geheim"},
|
20
|
-
{:email => "test@test", :password => "geheim", :password_confirmation => "geheim"},
|
21
|
-
{:email => "testtest.de", :password => "geheim", :password_confirmation => "geheim"}
|
16
|
+
{:email => "test@test.de", :password => "", :password_confirmation => "", :errortext => I18n.t( "activerecord.errors.models.user.attributes.password.blank" ) },
|
17
|
+
{:email => "test@test.de", :password => "geheim", :password_confirmation => "", :errortext => I18n.t( "activerecord.errors.messages.confirmation")},
|
18
|
+
{:email => "test@test.de", :password => "geheim", :password_confirmation => "gehei_", :errortext => I18n.t( "activerecord.errors.messages.confirmation")},
|
19
|
+
{:email => "test@test.de", :password => "", :password_confirmation => "geheim", :errortext => I18n.t( "activerecord.errors.models.user.attributes.password.blank")},
|
20
|
+
{:email => "test@test", :password => "geheim", :password_confirmation => "geheim", :errortext => I18n.t( "activerecord.errors.models.user.attributes.email.invalid")},
|
21
|
+
{:email => "testtest.de", :password => "geheim", :password_confirmation => "geheim", :errortext => I18n.t( "activerecord.errors.models.user.attributes.email.invalid")}
|
22
22
|
].each do |u|
|
23
23
|
it "User cannot sign up with wrong parameters" do
|
24
24
|
visit sign_up_form_path
|
@@ -26,7 +26,7 @@ describe "UserSignUp" do
|
|
26
26
|
fill_in "user_password", :with => u[:password]
|
27
27
|
fill_in "user_password_confirmation", :with => u[:password_confirmation]
|
28
28
|
click_button "sign_up_button"
|
29
|
-
page.should have_content(
|
29
|
+
page.should have_content( u[:errortext])
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -38,7 +38,7 @@ describe "UserSignUp" do
|
|
38
38
|
fill_in "user_password", :with => "geheim"
|
39
39
|
fill_in "user_password_confirmation", :with => "geheim"
|
40
40
|
click_button "sign_up_button"
|
41
|
-
page.should have_content( I18n.t( "
|
41
|
+
page.should have_content( I18n.t( "users.create.flash.success" ))
|
42
42
|
end
|
43
43
|
|
44
44
|
it "User cannot sign up with used email-address if confirmed" do
|
@@ -49,7 +49,7 @@ describe "UserSignUp" do
|
|
49
49
|
fill_in "user_password", :with => "geheim"
|
50
50
|
fill_in "user_password_confirmation", :with => "geheim"
|
51
51
|
click_button "sign_up_button"
|
52
|
-
page.should have_content( I18n.t( "
|
52
|
+
page.should have_content( I18n.t( "users.create.flash.error" ))
|
53
53
|
end
|
54
54
|
|
55
55
|
end
|
@@ -6,5 +6,5 @@
|
|
6
6
|
%p
|
7
7
|
= submit_tag t( "common.button.send" ), :id => "token_button"
|
8
8
|
%p
|
9
|
-
= link_to t('confirmation.registration.
|
9
|
+
= link_to t('confirmation.registration.resend_signup_token_link'), resend_signup_token_url, :id => 'resend_signup_token'
|
10
10
|
|
data/lib/generators/hero/authentication/templates/views/confirmation/resend_signup_token.html.haml
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
|
4
4
|
= form_tag resend_signup_token_url do
|
5
5
|
%p
|
6
|
-
= label_tag :email
|
6
|
+
= label_tag :email, t( ".label_email" )
|
7
7
|
%br
|
8
8
|
= text_field_tag :email, params[:email]
|
9
9
|
%p
|
10
|
-
= label_tag :password
|
10
|
+
= label_tag :password, t( ".label_password" )
|
11
11
|
%br
|
12
12
|
= password_field_tag :password
|
13
13
|
%p.button
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hero_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.beta9
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-09 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec-rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &88518190 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '2.6'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *88518190
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bcrypt-ruby
|
27
|
-
requirement: &
|
27
|
+
requirement: &88517940 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.1.2
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *88517940
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rails
|
38
|
-
requirement: &
|
38
|
+
requirement: &88517710 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 3.0.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *88517710
|
47
47
|
description: Write a gem description
|
48
48
|
email:
|
49
49
|
- guido@boyke.de
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- lib/generators/hero/authentication/templates/views/confirmation/order_new_password.html.haml
|
72
72
|
- lib/generators/hero/authentication/templates/views/confirmation/new_email_token.html.haml
|
73
73
|
- lib/generators/hero/authentication/templates/views/confirmation/registration.html.haml
|
74
|
+
- lib/generators/hero/authentication/templates/helpers/application_helper.rb
|
74
75
|
- lib/generators/hero/authentication/templates/tests/spec/requests/user_sign_in_spec.rb
|
75
76
|
- lib/generators/hero/authentication/templates/tests/spec/requests/user_confirmation_spec.rb
|
76
77
|
- lib/generators/hero/authentication/templates/tests/spec/requests/password_resets_spec.rb
|
@@ -86,6 +87,7 @@ files:
|
|
86
87
|
- lib/generators/hero/authentication/templates/mailers/confirmation_mailer.rb
|
87
88
|
- lib/generators/hero/authentication/templates/models/user.rb
|
88
89
|
- lib/generators/hero/authentication/templates/models/authentication.rb
|
90
|
+
- lib/generators/hero/authentication/templates/models/auth_user.rb
|
89
91
|
- lib/generators/hero/authentication/templates/config/initializers/action_mailer.rb
|
90
92
|
- lib/generators/hero/authentication/templates/config/initializers/constants.rb
|
91
93
|
- lib/generators/hero/authentication/templates/config/initializers/fix_active_record_validations_full_messages.rb
|