lobby 0.0.1i → 0.0.2

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.
Files changed (92) hide show
  1. data/Rakefile +1 -1
  2. data/app/controllers/lobby/confirmation_controller.rb +4 -4
  3. data/app/controllers/lobby/confirmation_controller.rb~ +32 -30
  4. data/app/forms/{password_forgotten_form.rb → lobby/password_forgotten_form.rb} +0 -0
  5. data/app/mailers/{confirmation_mailer.rb → lobby/confirmation_mailer.rb} +4 -4
  6. data/app/mailers/lobby/confirmation_mailer.rb~ +30 -0
  7. data/app/models/lobby/auth_user.rb +1 -1
  8. data/app/models/lobby/auth_user.rb~ +100 -0
  9. data/config/locales/en.yml +33 -408
  10. data/config/locales/en.yml~ +6 -379
  11. data/lib/lobby/engine.rb +6 -0
  12. data/lib/lobby/engine.rb~ +7 -0
  13. data/lib/lobby/version.rb +1 -1
  14. data/lib/lobby/version.rb~ +1 -1
  15. data/lib/lobby.rb +1 -2
  16. data/lib/lobby.rb~ +3 -0
  17. metadata +157 -155
  18. data/app/views/layouts/lobby/application.html.erb +0 -14
  19. data/app/views/sessions/new.html.haml +0 -19
  20. data/app/views/sessions/new.html.haml~ +0 -0
  21. data/config/routes.rb~ +0 -23
  22. data/db/migrate/20131205180849_create_users.rb~ +0 -16
  23. data/test/dummy/README.rdoc +0 -28
  24. data/test/dummy/Rakefile +0 -6
  25. data/test/dummy/app/assets/javascripts/application.js +0 -13
  26. data/test/dummy/app/assets/stylesheets/application.css +0 -13
  27. data/test/dummy/app/controllers/application_controller.rb +0 -6
  28. data/test/dummy/app/controllers/application_controller.rb~ +0 -5
  29. data/test/dummy/app/helpers/application_helper.rb +0 -2
  30. data/test/dummy/app/models/user.rb +0 -30
  31. data/test/dummy/app/models/user.rb~ +0 -30
  32. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  33. data/test/dummy/app/views/lobby/common/_form_errors.html.haml +0 -6
  34. data/test/dummy/app/views/lobby/confirmation/new_email_token.html.haml +0 -10
  35. data/test/dummy/app/views/lobby/confirmation/registration.html.haml +0 -15
  36. data/test/dummy/app/views/lobby/confirmation/registration.html.haml~ +0 -15
  37. data/test/dummy/app/views/lobby/confirmation/resend_signup_token.html.haml +0 -17
  38. data/test/dummy/app/views/lobby/confirmation/resend_signup_token.html.haml~ +0 -17
  39. data/test/dummy/app/views/lobby/confirmation/user_email.html.haml +0 -0
  40. data/test/dummy/app/views/lobby/confirmation_mailer/new_email_request.text.haml +0 -1
  41. data/test/dummy/app/views/lobby/confirmation_mailer/registration.text.haml +0 -1
  42. data/test/dummy/app/views/lobby/confirmation_mailer/resend_signup_token.text.haml +0 -1
  43. data/test/dummy/app/views/lobby/confirmation_mailer/send_password_reset.text.haml +0 -1
  44. data/test/dummy/app/views/lobby/password_forgotten/new.html.haml +0 -21
  45. data/test/dummy/app/views/lobby/password_forgotten/new.html.haml~ +0 -21
  46. data/test/dummy/app/views/lobby/password_forgotten/order_new_password.html.haml +0 -13
  47. data/test/dummy/app/views/lobby/password_forgotten/order_new_password.html.haml~ +0 -13
  48. data/test/dummy/app/views/lobby/password_forgotten/recover_password_auth.html.haml +0 -9
  49. data/test/dummy/app/views/lobby/sessions/new.html.haml +0 -12
  50. data/test/dummy/app/views/lobby/sessions/new.html.haml~ +0 -12
  51. data/test/dummy/app/views/lobby/users/new.html.haml +0 -20
  52. data/test/dummy/app/views/lobby/users/new.html.haml~ +0 -20
  53. data/test/dummy/bin/bundle +0 -3
  54. data/test/dummy/bin/rails +0 -4
  55. data/test/dummy/bin/rake +0 -4
  56. data/test/dummy/config/app_config.yml +0 -31
  57. data/test/dummy/config/application.rb +0 -23
  58. data/test/dummy/config/boot.rb +0 -5
  59. data/test/dummy/config/database.yml +0 -25
  60. data/test/dummy/config/environment.rb +0 -5
  61. data/test/dummy/config/environments/development.rb +0 -29
  62. data/test/dummy/config/environments/production.rb +0 -80
  63. data/test/dummy/config/environments/test.rb +0 -36
  64. data/test/dummy/config/initializers/action_mailer.rb +0 -75
  65. data/test/dummy/config/initializers/action_mailer.rb~ +0 -75
  66. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  67. data/test/dummy/config/initializers/constants.rb +0 -1
  68. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  69. data/test/dummy/config/initializers/inflections.rb +0 -16
  70. data/test/dummy/config/initializers/load_app_config.rb +0 -3
  71. data/test/dummy/config/initializers/mime_types.rb +0 -5
  72. data/test/dummy/config/initializers/secret_token.rb +0 -12
  73. data/test/dummy/config/initializers/session_store.rb +0 -3
  74. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  75. data/test/dummy/config/locales/en.yml +0 -23
  76. data/test/dummy/config/routes.rb +0 -4
  77. data/test/dummy/config.ru +0 -4
  78. data/test/dummy/db/development.sqlite3 +0 -0
  79. data/test/dummy/log/development.log +0 -10657
  80. data/test/dummy/public/404.html +0 -58
  81. data/test/dummy/public/422.html +0 -58
  82. data/test/dummy/public/500.html +0 -57
  83. data/test/dummy/public/favicon.ico +0 -0
  84. data/test/dummy/tmp/cache/assets/development/sprockets/14bc37f3a9c398f6798dd6a37b000ced +0 -0
  85. data/test/dummy/tmp/cache/assets/development/sprockets/940a306c051fc9ecf6ca85c072fac574 +0 -0
  86. data/test/dummy/tmp/cache/assets/development/sprockets/959f475481f39907c5c22136d3ad0b02 +0 -0
  87. data/test/dummy/tmp/cache/assets/development/sprockets/c4adbd06827a23aa54492fb7cb615529 +0 -0
  88. data/test/dummy/tmp/cache/assets/development/sprockets/c615a56268b779cf1f55f9134c8ae04e +0 -0
  89. data/test/dummy/tmp/cache/assets/development/sprockets/e4cc9c240851fac0c22ef37d0ee2fb62 +0 -0
  90. data/test/integration/navigation_test.rb +0 -10
  91. data/test/lobby_test.rb +0 -7
  92. data/test/test_helper.rb +0 -15
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
14
14
  rdoc.rdoc_files.include('lib/**/*.rb')
15
15
  end
16
16
 
17
- APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
18
  load 'rails/tasks/engine.rake'
19
19
 
20
20
 
@@ -6,9 +6,9 @@ module Lobby
6
6
 
7
7
  if @user
8
8
  @user.confirm_signup!
9
- redirect_to log_in_url, flash: { success: t( 'confirmation.registration.flash.success' ) }
9
+ redirect_to log_in_url, flash: { success: t( '.flash.success' ) }
10
10
  else
11
- flash.now[:notice] = t( 'confirmation.registration.flash.error') if params[:token]
11
+ flash.now[:notice] = t( '.flash.error') if params[:token]
12
12
  end
13
13
  end
14
14
 
@@ -21,9 +21,9 @@ module Lobby
21
21
  @user = User.find_by_email(params[:email])
22
22
  if @user && @user.authenticate(params[:password])
23
23
  if @user.resend_signup_token
24
- redirect_to log_in_url, flash: { success: t( 'confirmation.resend_signup_token.flash.success' ) }
24
+ redirect_to log_in_url, flash: { success: t( '.flash.success' ) }
25
25
  else
26
- redirect_to log_in_url, flash: { danger: t( 'confirmation.resend_signup_token.flash.error' ) }
26
+ redirect_to log_in_url, flash: { danger: t( '.flash.error' ) }
27
27
  end
28
28
  end
29
29
  end
@@ -1,44 +1,46 @@
1
- class ConfirmationController < ApplicationController
1
+ module Lobby
2
+ class ConfirmationController < ApplicationController
2
3
 
3
- def registration
4
- @user = User.where( :signup_token => params[:token] ).first unless params[:token].nil?
4
+ def registration
5
+ @user = User.where( :signup_token => params[:token] ).first unless params[:token].nil?
5
6
 
6
- if @user
7
- @user.confirm_signup!
8
- redirect_to log_in_url, flash: { success: t( 'confirmation.registration.flash.success' ) }
9
- else
10
- flash.now[:notice] = t( 'confirmation.registration.flash.error') if params[:token]
7
+ if @user
8
+ @user.confirm_signup!
9
+ redirect_to log_in_url, flash: { success: t( '.flash.success' ) }
10
+ else
11
+ flash.now[:notice] = t( 'confirmation.registration.flash.error') if params[:token]
12
+ end
11
13
  end
12
- end
13
14
 
14
- #
15
- # User has lost email with signup token. we send this email again.
16
- #
15
+ #
16
+ # User has lost email with signup token. we send this email again.
17
+ #
17
18
 
18
- def resend_signup_token
19
- flash[:notice] = nil
20
- @user = User.find_by_email(params[:email])
21
- if @user && @user.authenticate(params[:password])
22
- if @user.resend_signup_token
23
- redirect_to log_in_url, flash: { success: t( 'confirmation.resend_signup_token.flash.success' ) }
24
- else
25
- redirect_to log_in_url, flash: { danger: t( 'confirmation.resend_signup_token.flash.error' ) }
19
+ def resend_signup_token
20
+ flash[:notice] = nil
21
+ @user = User.find_by_email(params[:email])
22
+ if @user && @user.authenticate(params[:password])
23
+ if @user.resend_signup_token
24
+ redirect_to log_in_url, flash: { success: t( 'confirmation.resend_signup_token.flash.success' ) }
25
+ else
26
+ redirect_to log_in_url, flash: { danger: t( 'confirmation.resend_signup_token.flash.error' ) }
27
+ end
26
28
  end
27
29
  end
28
- end
29
30
 
30
31
 
31
- def new_email
32
- @user = User.find_by_new_email_token( params[:token] ) unless params[:token].nil?
33
- if @user
34
- if @user.confirm_new_email!
35
- redirect_to( root_url, :notice => t( '.flash.success' ))
32
+ def new_email
33
+ @user = User.find_by_new_email_token( params[:token] ) unless params[:token].nil?
34
+ if @user
35
+ if @user.confirm_new_email!
36
+ redirect_to( root_url, :notice => t( '.flash.success' ))
37
+ else
38
+ flash[:notice] = t( '.flash.error' )
39
+ end
36
40
  else
37
- flash[:notice] = t( '.flash.error' )
41
+ render :new_email_token
38
42
  end
39
- else
40
- render :new_email_token
41
43
  end
42
- end
43
44
 
45
+ end
44
46
  end
@@ -7,24 +7,24 @@ module Lobby
7
7
 
8
8
  def registration( user )
9
9
  @confirmation_url = confirm_url( :registration, user.signup_token )
10
- mail( :to => user.email, :subject => t( 'confirmation_mailer.registration.subject' ))
10
+ mail( :to => user.email, :subject => t( '.subject' ))
11
11
  end
12
12
 
13
13
  def resend_signup_token( user )
14
14
  @user = user
15
15
  @confirmation_url = confirm_url( :registration, @user.signup_token )
16
- mail( :to => user.email, :subject => t( 'confirmation_mailer.resend_signup_token.subject' ))
16
+ mail( :to => user.email, :subject => t( '.subject' ))
17
17
  end
18
18
 
19
19
  def send_password_reset( user )
20
20
  @confirmation_url = recover_password_form_url( :token => user.password_token )
21
- mail( :to => user.email, :subject => t( 'confirmation_mailer.send_password_reset.subject' ))
21
+ mail( :to => user.email, :subject => t( '.subject' ))
22
22
  end
23
23
 
24
24
  def new_email_request( user )
25
25
  @user = user
26
26
  @confirmation_url = new_email_url( @user.new_email_token )
27
- mail( :to => @user.new_email, :subject => t( 'confirmation_mailer.new_email_request.subject' ))
27
+ mail( :to => @user.new_email, :subject => t( '.subject' ))
28
28
  end
29
29
  end
30
30
  end
@@ -0,0 +1,30 @@
1
+ module Lobby
2
+ class ConfirmationMailer < ActionMailer::Base
3
+
4
+ helper :application
5
+
6
+ default :from => APP_CONFIG['registration_mailer']['from']
7
+
8
+ def registration( user )
9
+ @confirmation_url = confirm_url( :registration, user.signup_token )
10
+ mail( :to => user.email, :subject => t( '.subject' ))
11
+ end
12
+
13
+ def resend_signup_token( user )
14
+ @user = user
15
+ @confirmation_url = confirm_url( :registration, @user.signup_token )
16
+ mail( :to => user.email, :subject => t( '.subject' ))
17
+ end
18
+
19
+ def send_password_reset( user )
20
+ @confirmation_url = recover_password_form_url( :token => user.password_token )
21
+ mail( :to => user.email, :subject => t( '.subject' ))
22
+ end
23
+
24
+ def new_email_request( user )
25
+ @user = user
26
+ @confirmation_url = new_email_url( @user.new_email_token )
27
+ mail( :to => @user.new_email, :subject => t( '.subject' ))
28
+ end
29
+ end
30
+ end
@@ -65,7 +65,7 @@ module Lobby
65
65
  # Confirmation-Token generiert und verschickt werden.
66
66
 
67
67
  def tokenmail(request)
68
- Lobby::ConfirmationMailer.send(request, self).deliver
68
+ ConfirmationMailer.send(request, self).deliver
69
69
  end
70
70
 
71
71
  def send_password_reset(with_mail = true)
@@ -0,0 +1,100 @@
1
+ module Lobby
2
+ module AuthUser
3
+
4
+ def self.included(base)
5
+ base.has_secure_password
6
+
7
+ base.validates :email, presence: true
8
+ base.validates :email, format: {with: EMAIL_REGEX, multiline: true}, if: Proc.new { |u| u.email.present? }
9
+ base.validates :email, uniqueness: true, :unless => :confirmed_duplicate, :on => :create, if: Proc.new { |u| u.email.present? }
10
+ base.validates :password, length: { minimum: 5 }, :on => :create, if: Proc.new { |u| u.password.present? }
11
+
12
+ base.extend ClassMethods
13
+ end
14
+
15
+
16
+ module ClassMethods
17
+ def confirmed
18
+ where("confirmed IS NOT NULL")
19
+ end
20
+
21
+ def with_email(email)
22
+ where(:email => email)
23
+ end
24
+
25
+ end
26
+
27
+
28
+ def confirmed_duplicate(test_mail = self.email)
29
+ if ((self.class.name.constantize.confirmed.with_email(test_mail).count == 0) ||
30
+ (self.class.name.constantize.with_email(test_mail).count == 0))
31
+ true
32
+ else
33
+ #self.id = self.class.name.constantize.confirmed.with_email(test_mail).first.id
34
+ false
35
+ end
36
+ end
37
+
38
+ def confirm_signup!
39
+ update_attribute(:confirmed, Time.now)
40
+ update_attribute(:signup_token, nil)
41
+ update_attribute(:active, true)
42
+ end
43
+
44
+ def confirm_new_email!
45
+ update_attribute(:email, new_email)
46
+ update_attribute(:new_email_token, nil)
47
+ end
48
+
49
+ def confirmed?
50
+ !self.confirmed.nil?
51
+ end
52
+
53
+ def active?
54
+ self.active == true
55
+ end
56
+
57
+ # Wenn der User sich registriert, dann wird ein signup_token für ihn hinterlegt.
58
+ # Dieser Token wird per Mail verschickt. Der User kann sich nun per Klick auf den
59
+ # Tokenlink verifizieren. Sollte die Mail nicht mehr erreichbar sein, so kann der User
60
+ # unter Angabe seiner Email einen neuen signup_Token anfordern. Der alte Token ist
61
+ # ab diesem Zeitpunkt ungültig.
62
+
63
+ # Nach erfolgreicher Verifizierung der Email-Adresse) wird das
64
+ # Feld confirmed mit einem Datum gefüllt. Ab diesem Zeitpunkt kann keine neuer
65
+ # Confirmation-Token generiert und verschickt werden.
66
+
67
+ def tokenmail(request)
68
+ Lobby::ConfirmationMailer.send(request, self).deliver
69
+ end
70
+
71
+ def send_password_reset(with_mail = true)
72
+ return unless generate_token(:password_token)
73
+ if with_mail
74
+ tokenmail(:send_password_reset)
75
+ end
76
+ end
77
+
78
+ def send_registration
79
+ return unless generate_token(:signup_token)
80
+ tokenmail(:registration)
81
+ end
82
+
83
+ def resend_signup_token
84
+ return unless (!confirmed? && generate_token(:signup_token))
85
+ tokenmail(:resend_signup_token)
86
+ end
87
+
88
+ def send_new_email_request
89
+ return unless (confirmed? && generate_token(:new_email_token))
90
+ tokenmail(:new_email_request)
91
+ end
92
+
93
+
94
+ private
95
+
96
+ def generate_token( token )
97
+ (defined?( token ) && update_attribute( token, SecureRandom.hex(13) ))? true : false
98
+ end
99
+ end
100
+ end