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.
- data/Rakefile +1 -1
- data/app/controllers/lobby/confirmation_controller.rb +4 -4
- data/app/controllers/lobby/confirmation_controller.rb~ +32 -30
- data/app/forms/{password_forgotten_form.rb → lobby/password_forgotten_form.rb} +0 -0
- data/app/mailers/{confirmation_mailer.rb → lobby/confirmation_mailer.rb} +4 -4
- data/app/mailers/lobby/confirmation_mailer.rb~ +30 -0
- data/app/models/lobby/auth_user.rb +1 -1
- data/app/models/lobby/auth_user.rb~ +100 -0
- data/config/locales/en.yml +33 -408
- data/config/locales/en.yml~ +6 -379
- data/lib/lobby/engine.rb +6 -0
- data/lib/lobby/engine.rb~ +7 -0
- data/lib/lobby/version.rb +1 -1
- data/lib/lobby/version.rb~ +1 -1
- data/lib/lobby.rb +1 -2
- data/lib/lobby.rb~ +3 -0
- metadata +157 -155
- data/app/views/layouts/lobby/application.html.erb +0 -14
- data/app/views/sessions/new.html.haml +0 -19
- data/app/views/sessions/new.html.haml~ +0 -0
- data/config/routes.rb~ +0 -23
- data/db/migrate/20131205180849_create_users.rb~ +0 -16
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/Rakefile +0 -6
- data/test/dummy/app/assets/javascripts/application.js +0 -13
- data/test/dummy/app/assets/stylesheets/application.css +0 -13
- data/test/dummy/app/controllers/application_controller.rb +0 -6
- data/test/dummy/app/controllers/application_controller.rb~ +0 -5
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/models/user.rb +0 -30
- data/test/dummy/app/models/user.rb~ +0 -30
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/app/views/lobby/common/_form_errors.html.haml +0 -6
- data/test/dummy/app/views/lobby/confirmation/new_email_token.html.haml +0 -10
- data/test/dummy/app/views/lobby/confirmation/registration.html.haml +0 -15
- data/test/dummy/app/views/lobby/confirmation/registration.html.haml~ +0 -15
- data/test/dummy/app/views/lobby/confirmation/resend_signup_token.html.haml +0 -17
- data/test/dummy/app/views/lobby/confirmation/resend_signup_token.html.haml~ +0 -17
- data/test/dummy/app/views/lobby/confirmation/user_email.html.haml +0 -0
- data/test/dummy/app/views/lobby/confirmation_mailer/new_email_request.text.haml +0 -1
- data/test/dummy/app/views/lobby/confirmation_mailer/registration.text.haml +0 -1
- data/test/dummy/app/views/lobby/confirmation_mailer/resend_signup_token.text.haml +0 -1
- data/test/dummy/app/views/lobby/confirmation_mailer/send_password_reset.text.haml +0 -1
- data/test/dummy/app/views/lobby/password_forgotten/new.html.haml +0 -21
- data/test/dummy/app/views/lobby/password_forgotten/new.html.haml~ +0 -21
- data/test/dummy/app/views/lobby/password_forgotten/order_new_password.html.haml +0 -13
- data/test/dummy/app/views/lobby/password_forgotten/order_new_password.html.haml~ +0 -13
- data/test/dummy/app/views/lobby/password_forgotten/recover_password_auth.html.haml +0 -9
- data/test/dummy/app/views/lobby/sessions/new.html.haml +0 -12
- data/test/dummy/app/views/lobby/sessions/new.html.haml~ +0 -12
- data/test/dummy/app/views/lobby/users/new.html.haml +0 -20
- data/test/dummy/app/views/lobby/users/new.html.haml~ +0 -20
- data/test/dummy/bin/bundle +0 -3
- data/test/dummy/bin/rails +0 -4
- data/test/dummy/bin/rake +0 -4
- data/test/dummy/config/app_config.yml +0 -31
- data/test/dummy/config/application.rb +0 -23
- data/test/dummy/config/boot.rb +0 -5
- data/test/dummy/config/database.yml +0 -25
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -29
- data/test/dummy/config/environments/production.rb +0 -80
- data/test/dummy/config/environments/test.rb +0 -36
- data/test/dummy/config/initializers/action_mailer.rb +0 -75
- data/test/dummy/config/initializers/action_mailer.rb~ +0 -75
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/constants.rb +0 -1
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/load_app_config.rb +0 -3
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/secret_token.rb +0 -12
- data/test/dummy/config/initializers/session_store.rb +0 -3
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -23
- data/test/dummy/config/routes.rb +0 -4
- data/test/dummy/config.ru +0 -4
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/log/development.log +0 -10657
- data/test/dummy/public/404.html +0 -58
- data/test/dummy/public/422.html +0 -58
- data/test/dummy/public/500.html +0 -57
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/14bc37f3a9c398f6798dd6a37b000ced +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/940a306c051fc9ecf6ca85c072fac574 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/959f475481f39907c5c22136d3ad0b02 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c4adbd06827a23aa54492fb7cb615529 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c615a56268b779cf1f55f9134c8ae04e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e4cc9c240851fac0c22ef37d0ee2fb62 +0 -0
- data/test/integration/navigation_test.rb +0 -10
- data/test/lobby_test.rb +0 -7
- 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("../
|
|
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( '
|
|
9
|
+
redirect_to log_in_url, flash: { success: t( '.flash.success' ) }
|
|
10
10
|
else
|
|
11
|
-
flash.now[:notice] = t( '
|
|
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( '
|
|
24
|
+
redirect_to log_in_url, flash: { success: t( '.flash.success' ) }
|
|
25
25
|
else
|
|
26
|
-
redirect_to log_in_url, flash: { danger: t( '
|
|
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
|
-
|
|
1
|
+
module Lobby
|
|
2
|
+
class ConfirmationController < ApplicationController
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
def registration
|
|
5
|
+
@user = User.where( :signup_token => params[:token] ).first unless params[:token].nil?
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
16
|
-
|
|
15
|
+
#
|
|
16
|
+
# User has lost email with signup token. we send this email again.
|
|
17
|
+
#
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
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
|
|
File without changes
|
|
@@ -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( '
|
|
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( '
|
|
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( '
|
|
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( '
|
|
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
|
-
|
|
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
|