hero_generator 0.0.1.beta6 → 0.0.1.beta8

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.
@@ -54,7 +54,7 @@ module Hero
54
54
  template "config/initializers/action_mailer.rb", "config/initializers/action_mailer.rb"
55
55
  template "config/initializers/constants.rb", "config/initializers/constants.rb"
56
56
  template "config/initializers/fix_active_record_validations_full_messages.rb", "config/initializers/fix_active_record_validations_full_messages.rb"
57
- template "config/locales/en.yml", "config/locales/en.yml"
57
+ template "config/locales/de.yml", "config/locales/de.yml"
58
58
  end
59
59
 
60
60
  def create_migration
@@ -81,14 +81,15 @@ module Hero
81
81
  route "default_url_options :host => 'localhost:3000'"
82
82
  route "resources #{user_plural_name.to_sym.inspect}"
83
83
  route "resources #{session_plural_name.to_sym.inspect}"
84
- route "get 'log_out' => '#{session_plural_name.to_sym.inspect}#destroy', :as => 'log_out'"
84
+ route "get 'settings' => 'settings#index'"
85
+ route "match 'settings/change_email' => 'settings#change_user_email', :as => 'change_email'"
86
+ route "get 'log_out' => '#{session_plural_name}#destroy', :as => 'log_out'"
85
87
  route "get 'registrieren' => '#{user_plural_name}#new', :as => 'sign_up_form'"
86
88
  route "post 'registrieren' => '#{user_plural_name}#create', :as => 'sign_up'"
87
89
  route "match 'confirm/resend_confirmation' => 'confirmation#resend_signup_token', :as => 'resend_signup_token'"
88
90
  route "match 'confirm/:action(/:token)', :controller => :confirmation, :as => 'confirm'"
89
- route "get 'log_in' => '#{session_plural_name.to_sym.inspect}#new', :as => 'log_in'"
90
- route "post 'log_in' => '#{session_plural_name.to_sym.inspect}#create', :as => 'log_in'"
91
- route "get 'recover_password_auth(/:token)' => 'confirmation#recover_password_auth', :as => 'recover_password_auth'"
91
+ route "get 'log_in' => '#{session_plural_name}#new', :as => 'log_in_link'"
92
+ route "post 'log_in' => '#{session_plural_name}#create', :as => 'log_in'"
92
93
  route "match 'recover_password(/:token)' => 'confirmation#recover_password', :as => 'recover_password'"
93
94
  route "match 'new_email(/:token)' => 'confirmation#new_email', :as => 'new_email'"
94
95
  route "match 'request_password' => 'confirmation#order_new_password', :as => 'order_new_password'"
@@ -1,16 +1,13 @@
1
1
  # Sample localization file for English. Add more files in this directory for other locales.
2
2
  # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
3
 
4
- en:
5
-
4
+ de:
6
5
  activerecord:
7
- errors:
8
-
6
+ errors:
9
7
  full_messages:
10
8
  format: "{{message}}"
11
9
  messages:
12
10
  confirmation: "Passwortwiederholung ist falsch."
13
-
14
11
  models:
15
12
  user:
16
13
  attributes:
@@ -22,9 +19,7 @@ en:
22
19
  invalid: "Die E-Mail hat ein falsches Format."
23
20
  password_digest:
24
21
  blank: "Bitte geben Sie ein Passwort an."
25
-
26
-
27
-
22
+
28
23
  common:
29
24
  button:
30
25
  send: 'Senden'
@@ -44,8 +39,8 @@ en:
44
39
  sessions:
45
40
  new:
46
41
  title: 'Login'
47
- label_email: 'Email'
48
- label_password: 'Password'
42
+ label_email: 'E-Mail'
43
+ label_password: 'Passwort'
49
44
  create:
50
45
  flash:
51
46
  success: "Eingeloggt, hurra!"
@@ -59,7 +54,13 @@ en:
59
54
  title: "Neue E-Mail bestätigen"
60
55
  order_new_password:
61
56
  flash:
62
- success: 'Es wurde eine Email mit Passwort versendet'
57
+ success: 'Bitte prüfen Sie Ihre E-Mails. Dort finden Sie einen Link zum Setzen Ihres Passwortes.'
58
+ recover_password:
59
+ title: "Neues Passwort erstellen"
60
+ label_recover_password: "Neues Passwort"
61
+ label_recover_password_confirmation: "Neues Passwort wiederholen"
62
+ flash:
63
+ success: "Ihr Passwor wurde geändert"
63
64
  registration:
64
65
  flash:
65
66
  success: 'Endlich richtig dabei.'
@@ -67,7 +68,7 @@ en:
67
68
  resend_signup_token:
68
69
  title: "Token nochmal zusenden"
69
70
  flash:
70
- success: "Token wurde nochmal gesendet"
71
+ success: "Der Token wurde nochmal gesendet"
71
72
  error: "Sie sind schon freigeschaltet. Was soll das?"
72
73
 
73
74
  confirmation_mailer:
@@ -38,26 +38,18 @@ class ConfirmationController < ApplicationController
38
38
  # Aufruf des Links, der in der E-Mail steht, wenn man ein neues Passwort anfordert
39
39
  #
40
40
 
41
- def recover_password_auth
42
- @user = User.find_by_password_token( params[:token] ) unless params[:token].nil?
43
- render @user ? :recover_password : :password_token
44
- end
45
-
46
-
47
41
  def recover_password
48
42
  @token = params[:token]
49
43
  @user = User.find_by_password_token( params[:token] ) unless params[:token].nil?
50
44
 
51
45
  if @user
52
- if !params[:recover_password].nil? && params[:recover_password_confirmation] == params[:recover_password]
53
- if @user.confirm_password!(params[:recover_password])
54
- redirect_to( log_in_path, :notice => t( 'confirmation.recover_password.flash_success' ))
55
- else
56
- flash.now[:notice] = t( 'confirmation.recover_password.flash_error' )
46
+ if params[:recover_password]
47
+ if @user.confirm_password!(params[:recover_password], params[:recover_password_confirmation])
48
+ redirect_to( log_in_path, :notice => t( 'confirmation.recover_password.flash.success' ))
57
49
  end
58
50
  end
59
51
  else
60
- redirect_to recover_password_auth_url
52
+ render :password_token
61
53
  end
62
54
  end
63
55
 
@@ -1,23 +1,21 @@
1
1
  class User < ActiveRecord::Base
2
2
  has_secure_password
3
3
 
4
- attr_accessible :email, :password, :password_confirmation, :new_email_confirmation, :set_new_email
4
+ attr_accessible :email, :password, :password_confirmation, :new_email_confirmation, :set_new_email, :recover_password
5
5
 
6
- attr_accessor :update_password, :new_email_confirmation, :set_new_email
6
+ attr_accessor :update_password, :new_email_confirmation, :set_new_email, :recover_password
7
7
 
8
8
  validates_presence_of :email
9
9
  validates_format_of :email, :with => EMAIL_REGEX,
10
10
  :if => :should_validate_email_format?
11
11
  validates_uniqueness_of :email, :unless => :confirmed_duplicate
12
12
 
13
- #validates_presence_of :password, :if => :should_validate_password?
13
+ validates_presence_of :password, :if => :should_validate_password?
14
14
  validates_length_of :password, :if => :should_validate_password_length?,
15
15
  :within => 3..30,
16
16
  :too_short => 'too short message',
17
17
  :too_long => 'too long message'
18
18
 
19
- #validates_confirmation_of :password, :if => :should_validate_password?
20
-
21
19
  #set new email
22
20
  validates_presence_of :new_email, :if => :should_validate_new_email?
23
21
  validates_format_of :new_email, :with => EMAIL_REGEX,
@@ -37,9 +35,16 @@ class User < ActiveRecord::Base
37
35
  update_attribute(:signup_token, nil)
38
36
  end
39
37
 
40
- def confirm_password!(password)
41
- update_attribute(:password, password)
42
- update_attribute(:password_token, nil)
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
43
48
  end
44
49
 
45
50
  def confirm_new_email!
@@ -91,11 +96,11 @@ class User < ActiveRecord::Base
91
96
  end
92
97
 
93
98
  def should_validate_password?
94
- update_password || new_record?
99
+ update_password
95
100
  end
96
101
 
97
102
  def should_validate_password_length?
98
- should_validate_password? && password.present?
103
+ (new_record? || update_password) && password.present?
99
104
  end
100
105
 
101
106
 
@@ -1,12 +1,23 @@
1
- %h1 Recover Password
1
+ %h1
2
+ = t '.title'
3
+
2
4
 
5
+ - if @user.errors.any?
6
+ .error_messages
7
+ %h2
8
+ = t( 'common.form.error' )
9
+ %ul
10
+ - for message in @user.errors.full_messages
11
+ %li
12
+ = message
13
+
3
14
  = form_tag recover_password_path(@token) do
4
15
  %p
5
- = label_tag :recover_password
16
+ = label_tag :recover_password, t( ".label_recover_password" )
6
17
  %br
7
18
  = password_field_tag :recover_password
8
19
  %p
9
- = label_tag :recover_password_confirmation
20
+ = label_tag :recover_password_confirmation, t( ".label_recover_password_confirmation" )
10
21
  %br
11
22
  = password_field_tag :recover_password_confirmation
12
23
 
@@ -1,7 +1,7 @@
1
1
  %h1
2
2
  = t( 'confirmation.resend_signup_token.title' )
3
3
 
4
- = form_tag resend_signup_token_path do
4
+ = form_tag resend_signup_token_url do
5
5
  %p
6
6
  = label_tag :email
7
7
  %br
@@ -18,8 +18,6 @@
18
18
  = " oder "
19
19
  = link_to "Registrieren?", sign_up_form_path
20
20
 
21
-
22
-
23
21
  - flash.each do |name, msg|
24
22
  %div{:class => "box box-#{name}", :id => "flash_#{name}"}
25
23
  = msg
@@ -3,11 +3,11 @@
3
3
 
4
4
  = form_tag log_in_url do
5
5
  %p
6
- = label_tag t( '.label_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 t( '.label_password' )
10
+ = label_tag :password, t( '.label_password' )
11
11
  %br
12
12
  = password_field_tag :password
13
13
 
@@ -1,6 +1,6 @@
1
1
  %h2 Email
2
2
 
3
- = form_tag(:controller => "settings", :action => "change_user_email") do
3
+ = form_tag change_email_url do
4
4
 
5
5
  - if @user.errors.any?
6
6
  .error_messages
@@ -1,7 +1,6 @@
1
1
  %h1
2
2
  = t '.title'
3
3
 
4
-
5
4
  = form_for @user, :url => sign_up_url do |f|
6
5
  - if @user.errors.any?
7
6
  .error_messages
@@ -12,15 +11,15 @@
12
11
  %li
13
12
  = message
14
13
  %p
15
- = f.label t( '.label_email')
14
+ = f.label :email, t( '.label_email')
16
15
  %br
17
16
  = f.text_field :email
18
17
  %p
19
- = f.label t( '.label_password' )
18
+ = f.label :password, t( '.label_password' )
20
19
  %br
21
20
  = f.password_field :password
22
21
  %p
23
- = f.label t( '.label_password_confirmation' )
22
+ = f.label :password_confirmation, t( '.label_password_confirmation' )
24
23
  %br
25
24
  = f.password_field :password_confirmation
26
25
  %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.beta6
4
+ version: 0.0.1.beta8
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-02 00:00:00.000000000Z
12
+ date: 2012-10-03 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec-rails
16
- requirement: &74047410 !ruby/object:Gem::Requirement
16
+ requirement: &84196390 !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: *74047410
24
+ version_requirements: *84196390
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bcrypt-ruby
27
- requirement: &74047160 !ruby/object:Gem::Requirement
27
+ requirement: &84196140 !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: *74047160
35
+ version_requirements: *84196140
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rails
38
- requirement: &74046930 !ruby/object:Gem::Requirement
38
+ requirement: &84195910 !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: *74046930
46
+ version_requirements: *84195910
47
47
  description: Write a gem description
48
48
  email:
49
49
  - guido@boyke.de
@@ -90,7 +90,7 @@ files:
90
90
  - lib/generators/hero/authentication/templates/config/initializers/constants.rb
91
91
  - lib/generators/hero/authentication/templates/config/initializers/fix_active_record_validations_full_messages.rb
92
92
  - lib/generators/hero/authentication/templates/config/config.yml
93
- - lib/generators/hero/authentication/templates/config/locales/en.yml
93
+ - lib/generators/hero/authentication/templates/config/locales/de.yml
94
94
  - lib/generators/hero/authentication/templates/migrations/create_users.rb
95
95
  - lib/generators/hero/authentication/templates/controllers/confirmation_controller.rb
96
96
  - lib/generators/hero/authentication/templates/controllers/users_controller.rb