lobby 0.0.5 → 0.0.6

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 (32) hide show
  1. data/README.rdoc +3 -1
  2. data/config/locales/de.yml +3 -0
  3. data/config/locales/de.yml~ +0 -9
  4. data/config/locales/en.yml +3 -0
  5. data/config/locales/en.yml~ +0 -9
  6. data/lib/lobby/version.rb +1 -1
  7. data/lib/lobby/version.rb~ +1 -1
  8. metadata +2 -26
  9. data/app/controllers/lobby/application_controller.rb~ +0 -6
  10. data/app/controllers/lobby/confirmation_controller.rb~ +0 -46
  11. data/app/controllers/lobby/password_forgotten_controller.rb~ +0 -48
  12. data/app/controllers/lobby/sessions_controller.rb~ +0 -33
  13. data/app/controllers/lobby/users_controller.rb~ +0 -23
  14. data/app/forms/password_forgotten_form.rb~ +0 -5
  15. data/app/mailers/confirmation_mailer.rb~ +0 -28
  16. data/app/mailers/lobby/confirmation_mailer.rb~ +0 -25
  17. data/app/models/auth_user.rb~ +0 -100
  18. data/app/models/authentication.rb~ +0 -13
  19. data/app/models/lobby/auth_user.rb~ +0 -112
  20. data/app/models/password_forgotten_form_abstract.rb~ +0 -45
  21. data/config/routes.rb~ +0 -23
  22. data/lib/generators/lobby/install_generator.rb~ +0 -86
  23. data/lib/generators/lobby/lobby_generator.rb~ +0 -97
  24. data/lib/generators/templates/db/migrate/create_users.rb~ +0 -16
  25. data/lib/generators/templates/views/confirmation/registration.html.haml~ +0 -15
  26. data/lib/generators/templates/views/confirmation/resend_signup_token.html.haml~ +0 -17
  27. data/lib/generators/templates/views/password_forgotten/new.html.haml~ +0 -21
  28. data/lib/generators/templates/views/password_forgotten/order_new_password.html.haml~ +0 -13
  29. data/lib/generators/templates/views/sessions/new.html.haml~ +0 -12
  30. data/lib/generators/templates/views/users/new.html.haml~ +0 -20
  31. data/lib/lobby.rb~ +0 -3
  32. data/lib/lobby/engine.rb~ +0 -21
data/README.rdoc CHANGED
@@ -1,3 +1,5 @@
1
1
  = Lobby
2
2
 
3
- This project rocks and uses MIT-LICENSE.
3
+ Creates Login, Register, Confirmation-Mail, Logout and Password Forgotten
4
+
5
+ This project rocks and uses MIT-LICENSE.
@@ -99,6 +99,9 @@ de:
99
99
 
100
100
 
101
101
  password_forgotten:
102
+ create:
103
+ notice:
104
+ success: "Das neue Password wurde erfolgreich angelegt."
102
105
  recover_password_auth:
103
106
  title: 'Jetzt neues Passwort erstellen'
104
107
  label_token: 'Token'
@@ -110,15 +110,6 @@ de:
110
110
 
111
111
  confirmation_mailer:
112
112
 
113
- new_email_request:
114
- subject: 'Neue E-Mail bestätigen'
115
- body: "Hallo,
116
- um die Änderung Deiner E-Mail-Adress bei XYZ abzuschließen klicke bitte auf folgenden Link:
117
-
118
- %{url}
119
-
120
- Vielen Dank"
121
-
122
113
  registration:
123
114
  subject: 'Bitte Anmeldung bestätigen'
124
115
  body: "Hallo,
@@ -99,6 +99,9 @@ en:
99
99
 
100
100
 
101
101
  password_forgotten:
102
+ create:
103
+ notice:
104
+ success: "New password created."
102
105
  recover_password_auth:
103
106
  title: 'Create new password'
104
107
  label_token: 'Token'
@@ -110,15 +110,6 @@ en:
110
110
 
111
111
  confirmation_mailer:
112
112
 
113
- new_email_request:
114
- subject: 'Confirm new email'
115
- body: "Hello,
116
- to complete the change of your e-mail address at XYZ please click on the following link:
117
-
118
- %{url}
119
-
120
- Thank you very much"
121
-
122
113
  registration:
123
114
  subject: 'Please confirm registration'
124
115
  body: "Hello,
data/lib/lobby/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lobby
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -1,3 +1,3 @@
1
1
  module Lobby
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lobby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-11 00:00:00.000000000 Z
12
+ date: 2013-12-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -227,72 +227,48 @@ extensions: []
227
227
  extra_rdoc_files: []
228
228
  files:
229
229
  - app/forms/lobby/password_forgotten_form.rb
230
- - app/forms/password_forgotten_form.rb~
231
230
  - app/mailers/lobby/confirmation_mailer.rb
232
- - app/mailers/lobby/confirmation_mailer.rb~
233
- - app/mailers/confirmation_mailer.rb~
234
231
  - app/assets/stylesheets/lobby/application.css
235
232
  - app/assets/javascripts/lobby/application.js
236
- - app/controllers/lobby/users_controller.rb~
237
233
  - app/controllers/lobby/application_controller.rb
238
234
  - app/controllers/lobby/confirmation_controller.rb
239
- - app/controllers/lobby/password_forgotten_controller.rb~
240
- - app/controllers/lobby/sessions_controller.rb~
241
235
  - app/controllers/lobby/users_controller.rb
242
- - app/controllers/lobby/confirmation_controller.rb~
243
236
  - app/controllers/lobby/sessions_controller.rb
244
- - app/controllers/lobby/application_controller.rb~
245
237
  - app/controllers/lobby/password_forgotten_controller.rb
246
238
  - app/helpers/lobby/application_helper.rb
247
- - app/models/authentication.rb~
248
239
  - app/models/lobby/auth_user.rb
249
- - app/models/lobby/auth_user.rb~
250
240
  - app/models/lobby/authentication.rb
251
241
  - app/models/lobby/password_forgotten_form_abstract.rb
252
- - app/models/auth_user.rb~
253
- - app/models/password_forgotten_form_abstract.rb~
254
242
  - config/locales/de.yml
255
243
  - config/locales/en.yml~
256
244
  - config/locales/en.yml
257
245
  - config/locales/en.bootstrap.yml
258
246
  - config/locales/de.yml~
259
- - config/routes.rb~
260
247
  - config/routes.rb
261
- - lib/lobby/engine.rb~
262
248
  - lib/lobby/engine.rb
263
249
  - lib/lobby/version.rb
264
250
  - lib/lobby/version.rb~
265
251
  - lib/generators/lobby/install_generator.rb
266
- - lib/generators/lobby/lobby_generator.rb~
267
- - lib/generators/lobby/install_generator.rb~
268
252
  - lib/generators/templates/db/migrate/create_users.rb
269
- - lib/generators/templates/db/migrate/create_users.rb~
270
253
  - lib/generators/templates/config/initializers/constants.rb
271
254
  - lib/generators/templates/config/initializers/action_mailer.rb
272
255
  - lib/generators/templates/config/locales/de.yml
273
256
  - lib/generators/templates/config/locales/en.yml
274
257
  - lib/generators/templates/config/config.yml
275
258
  - lib/generators/templates/views/password_forgotten/new.html.haml
276
- - lib/generators/templates/views/password_forgotten/order_new_password.html.haml~
277
259
  - lib/generators/templates/views/password_forgotten/order_new_password.html.haml
278
260
  - lib/generators/templates/views/password_forgotten/recover_password_auth.html.haml
279
- - lib/generators/templates/views/password_forgotten/new.html.haml~
280
261
  - lib/generators/templates/views/confirmation_mailer/resend_signup_token.text.haml
281
262
  - lib/generators/templates/views/confirmation_mailer/send_password_reset.text.haml
282
263
  - lib/generators/templates/views/confirmation_mailer/registration.text.haml
283
264
  - lib/generators/templates/views/confirmation_mailer/new_email_request.text.haml
284
265
  - lib/generators/templates/views/sessions/new.html.haml
285
- - lib/generators/templates/views/sessions/new.html.haml~
286
266
  - lib/generators/templates/views/confirmation/registration.html.haml
287
- - lib/generators/templates/views/confirmation/resend_signup_token.html.haml~
288
267
  - lib/generators/templates/views/confirmation/resend_signup_token.html.haml
289
268
  - lib/generators/templates/views/confirmation/new_email_token.html.haml
290
- - lib/generators/templates/views/confirmation/registration.html.haml~
291
269
  - lib/generators/templates/views/common/_form_errors.html.haml
292
270
  - lib/generators/templates/views/users/new.html.haml
293
- - lib/generators/templates/views/users/new.html.haml~
294
271
  - lib/lobby.rb
295
- - lib/lobby.rb~
296
272
  - lib/tasks/lobby_tasks.rake
297
273
  - MIT-LICENSE
298
274
  - Rakefile
@@ -1,6 +0,0 @@
1
- module Lobby
2
- class ApplicationController < ActionController::Base
3
- protect_from_forgery
4
- include Authentication
5
- end
6
- end
@@ -1,46 +0,0 @@
1
- module Lobby
2
- class ConfirmationController < ApplicationController
3
-
4
- def registration
5
- @user = User.where( :signup_token => params[:token] ).first unless params[:token].nil?
6
-
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
13
- end
14
-
15
- #
16
- # User has lost email with signup token. we send this email again.
17
- #
18
-
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
28
- end
29
- end
30
-
31
-
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
40
- else
41
- render :new_email_token
42
- end
43
- end
44
-
45
- end
46
- end
@@ -1,48 +0,0 @@
1
- module Lobby
2
- class PasswordForgottenController < ApplicationController
3
-
4
- before_action :check_token, only: [:new, :create]
5
-
6
- def new
7
- end
8
-
9
- def create
10
- if @password_forgotten_form.submit(password_forgotten_form_params)
11
- flash[:success] = t('.notice.success')
12
- redirect_to log_in_url
13
- else
14
- render "new"
15
- end
16
- end
17
-
18
- def order_new_password
19
- if params[:email]
20
- @user = User.where( :email => params[:email] ).first
21
- if @user && @user.send_password_reset
22
- # nothing special. Send always the same notice. so you can prevent from e-mail-guessing.
23
- else
24
- puts "*******************************"
25
- puts "An non-existing email was given"
26
- puts "*******************************"
27
- end
28
- flash[:success] = t( '.flash.success' )
29
- redirect_to log_in_url
30
- end
31
- end
32
-
33
-
34
- def check_token
35
- @token = params[:token]
36
- @password_forgotten_form = Lobby::PasswordForgottenForm.new(@token)
37
-
38
- if @password_forgotten_form.user.blank?
39
- render :recover_password_auth
40
- false
41
- end
42
- end
43
-
44
- def password_forgotten_form_params
45
- params.require(:password_forgotten_form).permit(:new_password, :new_password_confirmation)
46
- end
47
- end
48
- end
@@ -1,33 +0,0 @@
1
- module Lobby
2
- class SessionsController < ApplicationController
3
- def new
4
- end
5
-
6
- def create
7
- @user = User.where('email = ? OR username = ?', params[:email], params[:email]).first
8
- if @user && @user.authenticate(params[:password])
9
- if @user.confirmed?
10
- if @user.active?
11
- session[:user_id] = @user.id
12
- flash.now[:success] = t( 'sessions.create.flash.success' )
13
- redirect_to root_url
14
- else
15
- flash.now[:danger] = t( 'sessions.create.flash.error.not_active' )
16
- redirect_to log_in_url
17
- end
18
- else
19
- flash.now[:danger] = t( 'sessions.create.flash.error.not_confirmed' )
20
- redirect_to confirm_url( :action => "registration" )
21
- end
22
- else
23
- flash.now[:danger] = t( 'sessions.create.flash.error.wrong_password_or_email' )
24
- render :new
25
- end
26
- end
27
-
28
- def destroy
29
- session[:user_id] = nil
30
- redirect_to root_url, flash: {success: t( 'sessions.destroy.success' ) }
31
- end
32
- end
33
- end
@@ -1,23 +0,0 @@
1
- module Lobby
2
- class UsersController < ApplicationController
3
-
4
- def new
5
- @user = User.new
6
- end
7
-
8
- def create
9
- @user = User.new(user_params)
10
- if @user.save
11
- redirect_to log_in_url, flash: {success: t( '.success' ) }
12
- @user.send_registration
13
- else
14
- render :new
15
- end
16
- end
17
-
18
- def user_params
19
- params.require(:user).permit(:email, :username, :password, :password_confirmation)
20
- end
21
-
22
- end
23
- end
@@ -1,5 +0,0 @@
1
- module Lobby
2
- class PasswordForgottenForm < Lobby::PasswordForgottenFormAbstract
3
- USER_CLASS = "User"
4
- end
5
- end
@@ -1,28 +0,0 @@
1
- class ConfirmationMailer < ActionMailer::Base
2
-
3
- helper :application
4
-
5
- default :from => APP_CONFIG['registration_mailer']['from']
6
-
7
- def registration( user )
8
- @confirmation_url = confirm_url( :registration, user.signup_token )
9
- mail( :to => user.email, :subject => t( 'confirmation_mailer.registration.subject' ))
10
- end
11
-
12
- def resend_signup_token( user )
13
- @user = user
14
- @confirmation_url = confirm_url( :registration, @user.signup_token )
15
- mail( :to => user.email, :subject => t( 'confirmation_mailer.resend_signup_token.subject' ))
16
- end
17
-
18
- def send_password_reset( user )
19
- @confirmation_url = recover_password_form_url( :token => user.password_token )
20
- mail( :to => user.email, :subject => t( 'confirmation_mailer.send_password_reset.subject' ))
21
- end
22
-
23
- def new_email_request( user )
24
- @user = user
25
- @confirmation_url = new_email_url( @user.new_email_token )
26
- mail( :to => @user.new_email, :subject => t( 'confirmation_mailer.new_email_request.subject' ))
27
- end
28
- end
@@ -1,25 +0,0 @@
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
- end
25
- end
@@ -1,100 +0,0 @@
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
- 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
@@ -1,13 +0,0 @@
1
- module Lobby
2
- module Authentication
3
-
4
- def self.included(controller)
5
- controller.send :helper_method, :current_user, :auth_with_username?
6
- end
7
-
8
- def current_user
9
- @current_user ||= User.find(session[:user_id]) if session[:user_id]
10
- end
11
-
12
- end
13
- end
@@ -1,112 +0,0 @@
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_email, :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.validates :username, presence: true
13
- base.validates :username, uniqueness: true, :unless => :confirmed_duplicate_username, :on => :create
14
-
15
- base.extend ClassMethods
16
- end
17
-
18
-
19
- module ClassMethods
20
- def confirmed
21
- where("confirmed IS NOT NULL")
22
- end
23
-
24
- def with_email(email)
25
- where(:email => email)
26
- end
27
-
28
- def with_username(username)
29
- where(:username => username)
30
- end
31
-
32
- end
33
-
34
-
35
- def confirmed_duplicate_email(test_mail = self.email)
36
- if ((self.class.name.constantize.confirmed.with_email(test_mail).count == 0) ||
37
- (self.class.name.constantize.with_email(test_mail).count == 0))
38
- true
39
- else
40
- false
41
- end
42
- end
43
-
44
- def confirm_signup!
45
- update_attribute(:confirmed, Time.now)
46
- update_attribute(:signup_token, nil)
47
- update_attribute(:active, true)
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 active?
60
- self.active == true
61
- end
62
-
63
- # attr_accessible :username
64
-
65
- def confirmed_duplicate_username(test_username = self.username)
66
- if ((User.confirmed.with_username(test_username).count == 0) ||
67
- (User.with_username(test_username).count == 0))
68
- true
69
- else
70
- false
71
- end
72
- end
73
-
74
- # Wenn der User sich registriert, dann wird ein signup_token für ihn hinterlegt.
75
- # Dieser Token wird per Mail verschickt. Der User kann sich nun per Klick auf den
76
- # Tokenlink verifizieren. Sollte die Mail nicht mehr erreichbar sein, so kann der User
77
- # unter Angabe seiner Email einen neuen signup_Token anfordern. Der alte Token ist
78
- # ab diesem Zeitpunkt ungültig.
79
-
80
- # Nach erfolgreicher Verifizierung der Email-Adresse) wird das
81
- # Feld confirmed mit einem Datum gefüllt. Ab diesem Zeitpunkt kann keine neuer
82
- # Confirmation-Token generiert und verschickt werden.
83
-
84
- def tokenmail(request)
85
- ConfirmationMailer.send(request, self).deliver
86
- end
87
-
88
- def send_password_reset(with_mail = true)
89
- return unless generate_token(:password_token)
90
- if with_mail
91
- tokenmail(:send_password_reset)
92
- end
93
- end
94
-
95
- def send_registration
96
- return unless generate_token(:signup_token)
97
- tokenmail(:registration)
98
- end
99
-
100
- def resend_signup_token
101
- return unless (!confirmed? && generate_token(:signup_token))
102
- tokenmail(:resend_signup_token)
103
- end
104
-
105
-
106
- private
107
-
108
- def generate_token( token )
109
- (defined?( token ) && update_attribute( token, SecureRandom.hex(13) ))? true : false
110
- end
111
- end
112
- end
@@ -1,45 +0,0 @@
1
- class PasswordForgottenFormAbstract
2
- include ActiveModel::Model
3
-
4
- attr_accessor :new_password
5
-
6
- validates :new_password, length: { minimum: 5 }
7
- validates :new_password, confirmation: true
8
-
9
- USER_CLASS = "User"
10
-
11
- def user_class
12
- proc{ self.class::USER_CLASS.constantize}.call
13
- end
14
-
15
- def user_object
16
- @user_object ||= (@token.present?)? user_class.where(password_token: @token).first : nil
17
- end
18
-
19
- def initialize(token)
20
- @token = token
21
- end
22
-
23
- def submit(params)
24
- self.new_password = params[:new_password]
25
- self.new_password_confirmation = params[:new_password_confirmation]
26
-
27
- if valid?
28
- user_object.password = new_password
29
- user_object.password_confirmation = new_password_confirmation
30
- user_object.password_token = nil
31
- user_object.save!
32
- true
33
- else
34
- false
35
- end
36
- end
37
-
38
- def method_missing(m, *args, &block)
39
- if m == self.user_class.name.downcase.to_sym
40
- send("user_object")
41
- else
42
- super
43
- end
44
- end
45
- end
data/config/routes.rb~ DELETED
@@ -1,23 +0,0 @@
1
- Lobby::Engine.routes.draw do
2
-
3
- root to: 'sessions#new'
4
-
5
- post 'log_in' => 'sessions#create', as: 'log_in'
6
- get 'log_in' => 'sessions#new', as: 'log_in_link'
7
- match 'confirm/resend_confirmation' => 'confirmation#resend_signup_token', as: 'resend_signup_token', via: [:get, :post]
8
- match 'confirm/:action(/:token)', :controller => :confirmation, as: 'confirm', via: [:get, :post]
9
- post 'register' => 'users#create', as: 'sign_up'
10
- get 'register' => 'users#new', as: 'sign_up_form'
11
- get 'log_out' => 'sessions#destroy', as: 'log_out'
12
-
13
- # forgotten password
14
- get 'recover_password(/:token)' => 'password_forgotten#new', as: 'recover_password_form'
15
- post 'recover_password' => 'password_forgotten#create', as: 'recover_password'
16
- match 'request_password' => 'password_forgotten#order_new_password', as: 'order_new_password', via: [:get, :post]
17
-
18
- match 'new_email(/:token)' => 'confirmation#new_email', as: 'new_email', via: [:get, :post]
19
-
20
- resources :sessions
21
-
22
- default_url_options :host => 'localhost:3000'
23
- end
@@ -1,86 +0,0 @@
1
- require 'rails/generators'
2
- require 'rails/generators/migration'
3
-
4
- module Lobby
5
- class InstallGenerator < Rails::Generators::Base
6
- include Rails::Generators::Migration
7
-
8
- attr_accessor :user_name, :session_name
9
-
10
- argument :user_name, :type => :string, :default => "user"
11
- argument :session_name, :type => :string, :default => "session"
12
-
13
- source_root File.expand_path("../../templates", __FILE__)
14
-
15
- def create_views
16
- directory "views", "app/views/lobby"
17
- end
18
-
19
- def create_locales
20
- template "config/locales/de.yml", "config/locales/de.lobby.yml"
21
- template "config/locales/en.yml", "config/locales/en.lobby.yml"
22
- end
23
-
24
- def create_config_files
25
- template "config/config.yml", "config/app_config.yml"
26
- template "config/locales/en.yml", "config/locales/en.lobby.yml"
27
- end
28
-
29
- def create_config_files
30
- template "config/config.yml", "config/app_config.yml"
31
- template "config/initializers/action_mailer.rb", "config/initializers/action_mailer.rb"
32
- template "config/initializers/constants.rb", "config/initializers/constants.rb"
33
- end
34
-
35
- def create_migration
36
- migration_template 'db/migrate/create_users.rb', "db/migrate/create_#{user_plural_name}.rb"
37
- end
38
-
39
- def setup_routes
40
- route "mount Lobby::Engine => '/', :as => 'lobby_engine'"
41
- end
42
-
43
- private
44
-
45
- def user_singular_name
46
- user_name.underscore
47
- end
48
-
49
- def user_plural_name
50
- user_singular_name.pluralize
51
- end
52
-
53
- def user_class_name
54
- user_name.camelize
55
- end
56
-
57
- def user_plural_class_name
58
- user_plural_name.camelize
59
- end
60
-
61
- def session_singular_name
62
- session_name.underscore
63
- end
64
-
65
- def session_plural_name
66
- session_singular_name.pluralize
67
- end
68
-
69
- def session_class_name
70
- session_name.camelize
71
- end
72
-
73
- def session_plural_class_name
74
- session_plural_name.camelize
75
- end
76
-
77
- def self.next_migration_number(dirname) #:nodoc:
78
- if ActiveRecord::Base.timestamped_migrations
79
- Time.now.utc.strftime("%Y%m%d%H%M%S")
80
- else
81
- "%.3d" % (current_migration_number(dirname) + 1)
82
- end
83
- end
84
-
85
- end
86
- end
@@ -1,97 +0,0 @@
1
- require 'rails/generators'
2
- require 'rails/generators/migration'
3
-
4
- module Lobby
5
- class InstGenerator < Rails::Generators::Base
6
- include Rails::Generators::Migration
7
-
8
- attr_accessor :user_name, :session_name
9
-
10
- argument :user_name, :type => :string, :default => "user"
11
- argument :session_name, :type => :string, :default => "session"
12
-
13
-
14
-
15
- # def create_views
16
- # template "views/confirmation/new_email_token.html.haml", "app/views/confirmation/new_email_token.html.haml"
17
- # template "views/confirmation/order_new_password.html.haml", "app/views/confirmation/order_new_password.html.haml"
18
- # template "views/confirmation/password_token.html.haml", "app/views/confirmation/password_token.html.haml"
19
- # end
20
-
21
- # def create_config_files
22
- # template "config/config.yml", "config/app_config.yml"
23
- # template "config/initializers/action_mailer.rb", "config/initializers/action_mailer.rb"
24
- # template "config/initializers/constants.rb", "config/initializers/constants.rb"
25
- # template "config/initializers/fix_active_record_validations_full_messages.rb", "config/initializers/fix_active_record_validations_full_messages.rb"
26
- # template "config/locales/de.yml", "config/locales/de.yml"
27
- # template "config/locales/de.yml", "config/locales/en.yml"
28
- # end
29
-
30
- def create_migration
31
- migration_template 'db/migrate/create_users.rb', "db/migrate/create_#{user_plural_name}.rb"
32
- end
33
-
34
- # def create_test_files
35
- # template "tests/spec/controllers/sessions_controller_spec.rb", "spec/controllers/sessions_controller_spec.rb"
36
- # template "tests/spec/controllers/users_controller_spec.rb", "spec/controllers/users_controller_spec.rb"
37
- # template "tests/spec/models/user_spec.rb", "spec/models/user_spec.rb"
38
- # template "tests/spec/requests/new_email_request_spec.rb", "spec/requests/new_email_request_spec.rb"
39
- # template "tests/spec/requests/password_resets_spec.rb", "spec/requests/password_resets_spec.rb"
40
- # template "tests/spec/requests/user_confirmation_spec.rb", "spec/requests/user_confirmation_spec.rb"
41
- # template "tests/spec/requests/user_sign_in_spec.rb", "spec/requests/user_sign_in_spec.rb"
42
- # template "tests/spec/requests/user_sign_up_spec.rb", "spec/requests/user_sign_up_spec.rb"
43
- # template "tests/spec/routing/confirmation_mailer_spec.rb", "spec/routing/confirmation_mailer_spec.rb"
44
- # template "tests/spec/support/mailer_macros.rb", "spec/support/mailer_macros.rb"
45
- # template "tests/spec/factories.rb", "spec/factories.rb"
46
- # template "tests/spec/spec_helper.rb", "spec/spec_helper.rb"
47
- # end
48
-
49
-
50
- def self.source_root
51
- @source_root ||= File.join(File.dirname(__FILE__), '../../spec/dummy')
52
- end
53
-
54
- private
55
-
56
- def user_singular_name
57
- user_name.underscore
58
- end
59
-
60
- def user_plural_name
61
- user_singular_name.pluralize
62
- end
63
-
64
- def user_class_name
65
- user_name.camelize
66
- end
67
-
68
- def user_plural_class_name
69
- user_plural_name.camelize
70
- end
71
-
72
- def session_singular_name
73
- session_name.underscore
74
- end
75
-
76
- def session_plural_name
77
- session_singular_name.pluralize
78
- end
79
-
80
- def session_class_name
81
- session_name.camelize
82
- end
83
-
84
- def session_plural_class_name
85
- session_plural_name.camelize
86
- end
87
-
88
- def self.next_migration_number(dirname) #:nodoc:
89
- if ActiveRecord::Base.timestamped_migrations
90
- Time.now.utc.strftime("%Y%m%d%H%M%S")
91
- else
92
- "%.3d" % (current_migration_number(dirname) + 1)
93
- end
94
- end
95
-
96
- end
97
- end
@@ -1,16 +0,0 @@
1
- class CreateUsers < ActiveRecord::Migration
2
- def change
3
- create_table :users do |t|
4
- t.string :email
5
- t.string :password_digest
6
- t.string :signup_token
7
- t.string :password_token
8
- # t.string :new_email
9
- # t.string :new_email_token
10
- t.boolean :active
11
- t.string :username
12
- t.datetime :confirmed, :null => true
13
- t.timestamps
14
- end
15
- end
16
- end
@@ -1,15 +0,0 @@
1
- %main
2
- %page-header
3
- %h1
4
- = t '.title'
5
- .page-main
6
-
7
- = form_tag confirm_path(:registration) do
8
- .row
9
- .col-lg-6
10
- .form-group
11
- = text_field_tag :token
12
- .form-group
13
- = link_to t('confirmation.registration.resend_signup_token_link'), resend_signup_token_url, :id => 'resend_signup_token'
14
- .form-actions
15
- = submit_tag t( "common.button.send" ), :id => "token_button", :class => 'btn btn-primary'
@@ -1,17 +0,0 @@
1
- %main
2
- %page-header
3
- %h1
4
- = t '.title'
5
- .page-main
6
-
7
- = form_tag resend_signup_token_url do
8
- .row
9
- .col-lg-6
10
- .form-group
11
- = label_tag :email, t( ".label_email" )
12
- = text_field_tag :email, params[:email], :class => 'form-control'
13
- .form-group
14
- = label_tag :password, t( ".label_password" )
15
- = password_field_tag :password, nil, :class => 'form-control'
16
- .form-actions
17
- = submit_tag t( "common.button.send" ), :id => "resend_signup_token_button", :class => 'btn btn-primary'
@@ -1,21 +0,0 @@
1
- %main
2
- %page-header
3
- %h1
4
- = t '.title'
5
- .page-main
6
-
7
- = form_for @password_forgotten_form, url: recover_password_path, method: :post do |f|
8
- = hidden_field_tag :token, @token
9
-
10
- = render :partial => "/lobby/common/form_errors", :locals => {:object => @password_forgotten_form}
11
-
12
- .row
13
- .col-lg-6
14
- .form-group
15
- = f.label :new_password, t( '.label_new_password')
16
- = f.password_field :new_password, :class => 'form-control'
17
- .form-group
18
- = f.label :new_password_confirmation, t( '.label_new_password_confirmation')
19
- = f.password_field :new_password_confirmation, :class => 'form-control'
20
- .form-actions
21
- = f.submit t( 'common.button.send' ), :id => 'password_forgotten_form_button', :class => 'btn btn-primary'
@@ -1,13 +0,0 @@
1
- %main
2
- %page-header
3
- %h1
4
- = t '.title'
5
- .page-main
6
-
7
- = form_tag order_new_password_url do
8
- .row
9
- .col-lg-6
10
- .form-group
11
- = text_field_tag :email, nil, placeholder: t( ".label_email" ), :class => 'form-control'
12
- .form-actions
13
- = submit_tag t( 'common.button.send' ), :id => 'send_new_password_button', :class => 'btn btn-primary'
@@ -1,12 +0,0 @@
1
- %h1
2
- = t '.title'
3
- = form_tag log_in_url, :id => "loginform" do
4
- .form-group
5
- = text_field_tag :email, params[:email], :class => "form-control", :placeholder => t( '.label_email' ), :id => 'email'
6
- .form-group
7
- = password_field_tag :password, nil, :class => "form-control", :placeholder => t( '.label_password' ), :id => 'inputPassword'
8
- .form-group
9
- = link_to t( '.password_forgotten_link' ), order_new_password_path, :id => 'password_forgotten_link'
10
-
11
- .form-actions
12
- = submit_tag(t( 'common.button.send' ), :id => 'log_in_button', :class => 'btn btn-primary')
@@ -1,20 +0,0 @@
1
- %h1
2
- = t '.title'
3
-
4
- = form_for @user, :url => sign_up_url do |f|
5
- = render :partial => "common/form_errors", :locals => {:object => @user}
6
-
7
- .form-group
8
- = f.label :username, t( '.label_username')
9
- = f.text_field :username, :class => 'form-control'
10
- .form-group
11
- = f.label :email, t( '.label_email')
12
- = f.text_field :email, :class => 'form-control'
13
- .form-group
14
- = f.label :password, t( '.label_password' )
15
- = f.password_field :password, :class => 'form-control'
16
- .form-group
17
- = f.label :password_confirmation, t( '.label_password_confirmation' )
18
- = f.password_field :password_confirmation, :class => 'form-control'
19
- .form-actions
20
- = submit_tag t( 'common.button.send' ), :id => 'sign_up_button', :class => 'btn btn-primary'
data/lib/lobby.rb~ DELETED
@@ -1,3 +0,0 @@
1
- module Lobby
2
- require "lobby/engine"
3
- end
data/lib/lobby/engine.rb~ DELETED
@@ -1,21 +0,0 @@
1
- module Lobby
2
- class Engine < ::Rails::Engine
3
- isolate_namespace Lobby
4
-
5
- # initializer :append_migrations do |app|
6
- # unless app.root.to_s.match root.to_s
7
- # config.paths["db/migrate"].expanded.each do |expanded_path|
8
- # app.config.paths["db/migrate"] << expanded_path
9
- # end
10
- # end
11
- # end
12
-
13
- config.generators do |g|
14
- g.test_framework :rspec, :view_specs => false
15
- g.integration_tool :rspec
16
- g.fixture_replacement :factory_girl, :dir => 'spec/factories'
17
- end
18
-
19
- config.autoload_paths += Dir["#{config.root}/lib/**/"]
20
- end
21
- end