accountly 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +9 -0
  3. data/Rakefile +34 -0
  4. data/app/assets/javascripts/accountly/application.js +13 -0
  5. data/app/assets/stylesheets/accountly/application.css +13 -0
  6. data/app/controllers/accountly/account_controller.rb +5 -0
  7. data/app/controllers/accountly/confirmation_controller.rb +18 -0
  8. data/app/controllers/accountly/emails_controller.rb +16 -0
  9. data/app/controllers/accountly/passwords_controller.rb +20 -0
  10. data/app/controllers/accountly/settings_controller.rb +5 -0
  11. data/app/controllers/accountly/usernames_controller.rb +22 -0
  12. data/app/forms/accountly/change_email_form.rb +71 -0
  13. data/app/forms/accountly/password_form.rb +42 -0
  14. data/app/forms/accountly/username_form.rb +49 -0
  15. data/app/helpers/accountly/application_helper.rb +4 -0
  16. data/app/mailers/accountly/account_mailer.rb +14 -0
  17. data/app/models/accountly/update_email_user.rb +27 -0
  18. data/app/views/layouts/accountly/application.html.erb +14 -0
  19. data/config/initializers/fix_active_record_validations_full_messages.rb +28 -0
  20. data/config/locales/de.yml +98 -0
  21. data/config/locales/en.bootstrap.yml +18 -0
  22. data/config/locales/en.yml +98 -0
  23. data/config/routes.rb +14 -0
  24. data/lib/accountly.rb +3 -0
  25. data/lib/accountly/engine.rb +13 -0
  26. data/lib/accountly/version.rb +3 -0
  27. data/lib/generators/accountly/install_generator.rb +78 -0
  28. data/lib/generators/templates/db/migrate/add_new_email_to_users.rb +11 -0
  29. data/lib/generators/templates/views/account_mailer/new_email_request.text.haml +1 -0
  30. data/lib/generators/templates/views/common/_form_errors.html.haml +6 -0
  31. data/lib/generators/templates/views/emails/new.html.haml +19 -0
  32. data/lib/generators/templates/views/passwords/new.html.haml +18 -0
  33. data/lib/generators/templates/views/settings/index.html.haml +10 -0
  34. data/lib/generators/templates/views/usernames/new.html.haml +18 -0
  35. metadata +287 -0
@@ -0,0 +1,20 @@
1
+ Copyright 2013 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,9 @@
1
+ = Accountly
2
+
3
+ Administration for wiki-project.
4
+ *change username
5
+ *change email
6
+ *change password
7
+ *generator for views
8
+
9
+ This project rocks and uses MIT-LICENSE.
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Accountly'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,5 @@
1
+ module Accountly
2
+ class AccountController < ApplicationController
3
+
4
+ end
5
+ end
@@ -0,0 +1,18 @@
1
+ module Accountly
2
+ class ConfirmationController < ApplicationController
3
+
4
+ def new_email
5
+ @user = User.find_by_new_email_token( params[:token] ) unless params[:token].nil?
6
+ if @user
7
+ if @user.confirm_new_email!
8
+ redirect_to( root_url, :notice => t( '.flash.success' ))
9
+ else
10
+ flash[:notice] = t( '.flash.error' )
11
+ end
12
+ else
13
+ render :new_email_token
14
+ end
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ module Accountly
2
+ class EmailsController < AccountController
3
+ def new
4
+ @change_email_form = ChangeEmailForm.new(current_user)
5
+ end
6
+
7
+ def create
8
+ @change_email_form = ChangeEmailForm.new(current_user)
9
+ if @change_email_form.submit( params[:change_email_form] )
10
+ redirect_to settings_url, notice: t( ".flash.success" )
11
+ else
12
+ render "new"
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+ #
2
+ # usecase: if user wants to change his password when he is logged in.
3
+ # he needs his current password to change it.
4
+ #
5
+ module Accountly
6
+ class PasswordsController < AccountController
7
+ def new
8
+ @password_form = PasswordForm.new(current_user)
9
+ end
10
+
11
+ def create
12
+ @password_form = PasswordForm.new(current_user)
13
+ if @password_form.submit( params[:password_form] )
14
+ redirect_to settings_url, notice: t('.notice.success')
15
+ else
16
+ render "new"
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ module Accountly
2
+ class SettingsController < AccountController
3
+
4
+ end
5
+ end
@@ -0,0 +1,22 @@
1
+ #
2
+ # usecase: if user wants to change his username when he is logged in.
3
+ # he needs his current password to change it.
4
+ #
5
+
6
+ module Accountly
7
+ class UsernamesController < AccountController
8
+
9
+ def new
10
+ @username_form = UsernameForm.new(current_user)
11
+ end
12
+
13
+ def create
14
+ @username_form = UsernameForm.new(current_user)
15
+ if @username_form.submit( params[:username_form] )
16
+ redirect_to settings_url, notice: t('.notice.success')
17
+ else
18
+ render "new"
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,71 @@
1
+ module Accountly
2
+ class ChangeEmailForm
3
+ include ActiveModel::Model
4
+
5
+ attr_accessor :password, :new_email, :new_email_confirmation
6
+
7
+ validate :verify_password
8
+ validate :validate_steps_email
9
+
10
+ def initialize(user)
11
+ @user = user
12
+ end
13
+
14
+ def submit(params)
15
+ self.password = params[:password]
16
+ self.new_email = params[:new_email]
17
+ self.new_email_confirmation = params[:new_email_confirmation]
18
+ if valid?
19
+ @user.new_email = new_email
20
+ @user.save!
21
+ @user.send_new_email_request
22
+ true
23
+ else
24
+ false
25
+ end
26
+ end
27
+
28
+ def validate_steps_email
29
+
30
+ if new_email.present?
31
+ if new_email =~ EMAIL_REGEX
32
+ if @user.confirmed_duplicate_email(self.new_email)
33
+ if new_email_confirmation.present?
34
+ if new_email_confirmation == new_email
35
+ true
36
+ else
37
+ error_add :new_email_confirmation, 'confirmation'
38
+ false
39
+ end
40
+ else
41
+ error_add :new_email_confirmation, 'blank'
42
+ false
43
+ end
44
+ else
45
+ error_add :new_email, 'duplicate'
46
+ end
47
+ else
48
+ error_add :new_email, 'invalid'
49
+ false
50
+ end
51
+ else
52
+ error_add :new_email, 'blank'
53
+ false
54
+ end
55
+ end
56
+
57
+ def verify_password
58
+ if password.blank?
59
+ error_add :password, 'blank'
60
+ else
61
+ unless @user.authenticate(password)
62
+ error_add :password, 'invalid'
63
+ end
64
+ end
65
+ end
66
+
67
+ def error_add(attribute, error)
68
+ errors.add attribute, I18n.t("activemodel.errors.models.accountly/change_email_form.attributes.#{attribute}.#{error}")
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,42 @@
1
+ module Accountly
2
+ class PasswordForm
3
+ include ActiveModel::Model
4
+
5
+ attr_accessor :original_password, :new_password
6
+
7
+ validate :verify_original_password
8
+ validates :original_password, presence: true
9
+
10
+ validates :new_password, length: { minimum: 5 }
11
+ validates :new_password, confirmation: true
12
+
13
+
14
+ def initialize(user)
15
+ @user = user
16
+ end
17
+
18
+ def submit(params)
19
+ self.original_password = params[:original_password]
20
+ self.new_password = params[:new_password]
21
+ self.new_password_confirmation = params[:new_password_confirmation]
22
+
23
+ if valid?
24
+ @user.password = new_password
25
+ @user.password_confirmation = new_password_confirmation
26
+ @user.save!
27
+ true
28
+ else
29
+ false
30
+ end
31
+ end
32
+
33
+ def verify_original_password
34
+ if @user.authenticate(original_password)
35
+ true
36
+ else
37
+ errors.add :original_password, I18n.t('activemodel.errors.models.accountly/password_form.attributes.original_password.invalid')
38
+ false
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,49 @@
1
+ module Accountly
2
+ class UsernameForm
3
+ include ActiveModel::Model
4
+
5
+ attr_accessor :original_password, :new_username, :new_username_confirmation
6
+
7
+ validate :verify_original_password, if: Proc.new { |u| u.original_password.present? }
8
+ validates :original_password, presence: true
9
+ validate :verify_unique_username
10
+
11
+ validates :new_username, presence: true
12
+ validates :new_username, length: { minimum: 5 }
13
+ validates :new_username, confirmation: true
14
+
15
+
16
+ def initialize(user)
17
+ @user = user
18
+ end
19
+
20
+ def submit(params)
21
+ self.original_password = params[:original_password]
22
+ self.new_username = params[:new_username]
23
+ self.new_username_confirmation = params[:new_username_confirmation]
24
+
25
+ if valid?
26
+ @user.username = new_username
27
+ @user.save!
28
+ true
29
+ else
30
+ false
31
+ end
32
+ end
33
+
34
+ def verify_unique_username
35
+ unless @user.confirmed_duplicate_username(self.new_username)
36
+ errors.add :new_username, I18n.t('activemodel.errors.models.accountly/username_form.attributes.new_username.duplicate')
37
+ end
38
+ end
39
+
40
+ def verify_original_password
41
+ if @user.authenticate(original_password)
42
+ true
43
+ else
44
+ errors.add :original_password, I18n.t('activemodel.errors.models.accountly/username_form.attributes.original_password.invalid')
45
+ false
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,4 @@
1
+ module Accountly
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,14 @@
1
+ module Accountly
2
+ class AccountMailer < ActionMailer::Base
3
+
4
+ helper :application
5
+
6
+ default :from => APP_CONFIG['registration_mailer']['from']
7
+
8
+ def new_email_request( user )
9
+ @user = user
10
+ @confirmation_url = confirm_new_email_url( @user.new_email_token )
11
+ mail( :to => @user.new_email, :subject => t( '.subject' ))
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,27 @@
1
+ module Accountly
2
+ module UpdateEmailUser
3
+
4
+ def confirm_new_email!
5
+ update_attribute(:email, new_email)
6
+ update_attribute(:new_email_token, nil)
7
+ end
8
+
9
+
10
+ def tokenmail(request)
11
+ AccountMailer.send(request, self).deliver
12
+ end
13
+
14
+
15
+ def send_new_email_request
16
+ return unless (confirmed? && generate_token(:new_email_token))
17
+ tokenmail(:new_email_request)
18
+ end
19
+
20
+
21
+ private
22
+
23
+ def generate_token( token )
24
+ (defined?( token ) && update_attribute( token, SecureRandom.hex(13) ))? true : false
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Accountly</title>
5
+ <%= stylesheet_link_tag "accountly/application", media: "all" %>
6
+ <%= javascript_include_tag "accountly/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,28 @@
1
+ ActiveModel::Errors.class_eval do
2
+ # Remove complicated logic
3
+ def full_messages
4
+ full_messages = []
5
+
6
+ each do |attribute, messages|
7
+ messages = Array.wrap(messages)
8
+ next if messages.empty?
9
+
10
+ if attribute == :base
11
+ messages.each {|m| full_messages << m }
12
+ else
13
+ attr_name = attribute.to_s.gsub('.', '_').humanize
14
+ attr_name = @base.class.human_attribute_name(
15
+ attribute,
16
+ :default => '' # attr_name
17
+ )
18
+
19
+ options = { :default => "%{message}", :attribute => attr_name }
20
+
21
+ messages.each do |m|
22
+ full_messages << I18n.t(:"errors.format", options.merge(:message => m))
23
+ end
24
+ end
25
+ end
26
+ full_messages
27
+ end
28
+ end
@@ -0,0 +1,98 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ de:
5
+ common:
6
+ button:
7
+ send: 'send'
8
+ form:
9
+ error: "error"
10
+
11
+ activemodel:
12
+ errors:
13
+ models:
14
+ accountly:
15
+ change_email_form:
16
+ attributes:
17
+ new_email:
18
+ blank: 'Bitte eine neue E-Mail angeben'
19
+ invalid: "Die E-Mail hat ein falsches Format."
20
+ duplicate: 'Diese E-Mail kann nicht gewählt werden.'
21
+ new_email_confirmation:
22
+ confirmation: 'Die E-Mail-Bestätigung war falsch'
23
+ blank: 'Bitte die E-Mail bestätigen'
24
+ password:
25
+ blank: 'Bitte auch das aktuelle Passwort angeben.'
26
+ invalid: 'Das aktuelle Passwort war nicht korrekt'
27
+ accountly:
28
+ username_form:
29
+ attributes:
30
+ new_username:
31
+ blank: 'Bitte einen Username angeben'
32
+ duplicate: 'Dieser Username kann nicht gewählt werden.'
33
+ too_short: 'Der neue Username ist zu kurz (mind. 5 Zeichen)'
34
+ new_username_confirmation:
35
+ confirmation: 'Die Bestätigung war falsch'
36
+ blank: 'Bitte den Username bestätigen'
37
+ original_password:
38
+ blank: 'Bitte auch das alte Passwort angeben.'
39
+ invalid: 'Das aktuelle Passwort war nicht korrekt'
40
+ password_forgotten_form:
41
+ attributes:
42
+ new_password:
43
+ too_short: 'Das neue Passwort ist zu kurz (mind. 5 Zeichen)'
44
+ new_password_confirmation:
45
+ confirmation: 'Die Passwortbestätigung war falsch.'
46
+ accountly:
47
+ password_form:
48
+ attributes:
49
+ original_password:
50
+ blank: 'Bitte auch das alte Passwort angeben.'
51
+ invalid: 'Das aktuelle Passwort war nicht korrekt'
52
+ new_password:
53
+ too_short: 'Das neue Passwort ist zu kurz (mind. 5 Zeichen)'
54
+ new_password_confirmation:
55
+ confirmation: 'Die Passwortbestätigung war falsch.'
56
+
57
+ accountly:
58
+ confirmation:
59
+ new_email:
60
+ flash:
61
+ success: "Deine neue E-Mail wurde gesetzt."
62
+ passwords:
63
+ new:
64
+ title: 'Passwort ändern'
65
+ label_original_password: 'aktuelles Passwort'
66
+ label_new_password: 'neues Passwort'
67
+ label_new_password_confirmation: 'neues Passwort wiederholen'
68
+ create:
69
+ notice:
70
+ success: "Dein Passwort wurde geändert."
71
+ usernames:
72
+ new:
73
+ title: 'Username ändern'
74
+ label_original_password: 'aktuelles Passwort'
75
+ label_new_username: 'neuer Username'
76
+ label_new_username_confirmation: 'neuen Username wiederholen'
77
+ create:
78
+ notice:
79
+ success: "Dein Username wurde geändert."
80
+ emails:
81
+ new:
82
+ title: "E-Mail ändern"
83
+ label_new_email: "Neue E-Mail"
84
+ label_new_email_confirmation: "E-Mail bestätigen"
85
+ label_password: "Passwort"
86
+ create:
87
+ flash:
88
+ success: 'Ein Bestätigungslink wurde an die neue E-Mail-Adresse versendet.'
89
+
90
+ account_mailer:
91
+ new_email_request:
92
+ subject: 'Neue E-Mail bestätigen'
93
+ body: "Hallo,
94
+ um die Änderung Deiner E-Mail-Adress bei XYZ abzuschließen klicke bitte auf folgenden Link:
95
+
96
+ %{url}
97
+
98
+ Vielen Dank"
@@ -0,0 +1,18 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ helpers:
6
+ actions: "Actions"
7
+ links:
8
+ back: "Back"
9
+ cancel: "Cancel"
10
+ confirm: "Are you sure?"
11
+ destroy: "Delete"
12
+ new: "New"
13
+ edit: "Edit"
14
+ titles:
15
+ edit: "Edit %{model}"
16
+ save: "Save %{model}"
17
+ new: "New %{model}"
18
+ delete: "Delete %{model}"
@@ -0,0 +1,98 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ common:
6
+ button:
7
+ send: 'send'
8
+ form:
9
+ error: "error"
10
+
11
+ activemodel:
12
+ errors:
13
+ models:
14
+ accountly/change_email_form:
15
+ attributes:
16
+ new_email:
17
+ blank: 'Please enter a new e-mail.'
18
+ invalid: "The e-mail has an incorrect format."
19
+ duplicate: 'This e-mail can not be selected.'
20
+ new_email_confirmation:
21
+ confirmation: 'The e-mail confirmation was wrong.'
22
+ blank: 'Please confirm the e-mail.'
23
+ password:
24
+ blank: 'Please also provide the current password.'
25
+ invalid: 'The current password was not correct.'
26
+ accountly/username_form:
27
+ attributes:
28
+ new_username:
29
+ blank: 'Please specify a user name.'
30
+ duplicate: 'This user name can not be selected.'
31
+ too_short: 'The new username is too short (minimum 5 characters).'
32
+ new_username_confirmation:
33
+ confirmation: 'The confirmation was wrong.'
34
+ blank: 'Please confirm the user name.'
35
+ original_password:
36
+ blank: 'Please also provide the old password.'
37
+ invalid: 'The current password was not correct.'
38
+ accountly/password_form:
39
+ attributes:
40
+ original_password:
41
+ blank: 'Please also provide the old password.'
42
+ invalid: 'The current password was not correct.'
43
+ new_password:
44
+ too_short: 'The new password is too short (minimum 5 characters).'
45
+ new_password_confirmation:
46
+ confirmation: 'The password confirmation was wrong.'
47
+
48
+ accountly:
49
+ settings:
50
+ index:
51
+ title: 'Your account'
52
+ current_email: "Your current e-mail is: %{email}"
53
+ link_text:
54
+ change_email: 'change'
55
+ change_password: 'change password'
56
+ confirmation:
57
+ new_email:
58
+ flash:
59
+ success: 'Your new email address is now activated.'
60
+ new_email_token:
61
+ title: "Confirm new email"
62
+ passwords:
63
+ new:
64
+ title: 'Update password'
65
+ label_original_password: 'current password'
66
+ label_new_password: 'new password'
67
+ label_new_password_confirmation: 'confirm new password'
68
+ create:
69
+ notice:
70
+ success: "Your password has been changed."
71
+ usernames:
72
+ new:
73
+ title: 'Update username'
74
+ label_original_password: 'current password'
75
+ label_new_username: 'new username'
76
+ label_new_username_confirmation: 'confirm new username'
77
+ create:
78
+ notice:
79
+ success: "Your username has been changed."
80
+ emails:
81
+ new:
82
+ title: "Update e-mail"
83
+ label_new_email: "new e-mail"
84
+ label_new_email_confirmation: "confirm new e-mail"
85
+ label_password: "password"
86
+ create:
87
+ flash:
88
+ success: 'A confirmation link has been sent to the new email address.'
89
+
90
+ account_mailer:
91
+ new_email_request:
92
+ subject: 'Confirm new email'
93
+ body: "Hello,
94
+ to complete the change of your e-mail address at XYZ please click on the following link:
95
+
96
+ %{url}
97
+
98
+ Thank you very much"
@@ -0,0 +1,14 @@
1
+ Accountly::Engine.routes.draw do
2
+
3
+ root to: 'settings#index'
4
+
5
+ get 'settings' => 'settings#index'
6
+ resources :usernames, :only => [:new, :create]
7
+ resources :passwords, :only => [:new, :create]
8
+ resources :emails, :only => [:new, :create]
9
+ resources :users
10
+
11
+ match 'new_email(/:token)' => 'confirmation#new_email', as: 'confirm_new_email', via: [:get, :post]
12
+
13
+ default_url_options :host => 'localhost:3000'
14
+ end
@@ -0,0 +1,3 @@
1
+ module Accountly
2
+ require "accountly/engine"
3
+ end
@@ -0,0 +1,13 @@
1
+ module Accountly
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Accountly
4
+
5
+ config.generators do |g|
6
+ g.test_framework :rspec, :view_specs => false
7
+ g.integration_tool :rspec
8
+ g.fixture_replacement :factory_girl, :dir => 'spec/factories'
9
+ end
10
+
11
+ config.autoload_paths += Dir["#{config.root}/lib/**/"]
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module Accountly
2
+ VERSION = "0.0.3"
3
+ end
@@ -0,0 +1,78 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+ module Accountly
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
+
12
+ source_root File.expand_path("../../templates", __FILE__)
13
+
14
+ def create_views
15
+ directory "views", "app/views/accountly"
16
+ end
17
+
18
+ def create_locales
19
+ template "config/locales/de.yml", "config/locales/de.accountly.yml"
20
+ template "config/locales/en.yml", "config/locales/en.accountly.yml"
21
+ end
22
+
23
+ def create_config_files
24
+
25
+ end
26
+
27
+ def setup_routes
28
+ route "mount Accountly::Engine => '/account', :as => 'accountly_engine'"
29
+ end
30
+
31
+ def create_migration
32
+ migration_template 'db/migrate/add_new_email_to_users.rb', "db/migrate/add_new_email_to_users.rb"
33
+ end
34
+
35
+ private
36
+
37
+ def user_singular_name
38
+ user_name.underscore
39
+ end
40
+
41
+ def user_plural_name
42
+ user_singular_name.pluralize
43
+ end
44
+
45
+ def user_class_name
46
+ user_name.camelize
47
+ end
48
+
49
+ def user_plural_class_name
50
+ user_plural_name.camelize
51
+ end
52
+
53
+ def session_singular_name
54
+ session_name.underscore
55
+ end
56
+
57
+ def session_plural_name
58
+ session_singular_name.pluralize
59
+ end
60
+
61
+ def session_class_name
62
+ session_name.camelize
63
+ end
64
+
65
+ def session_plural_class_name
66
+ session_plural_name.camelize
67
+ end
68
+
69
+ def self.next_migration_number(dirname) #:nodoc:
70
+ if ActiveRecord::Base.timestamped_migrations
71
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
72
+ else
73
+ "%.3d" % (current_migration_number(dirname) + 1)
74
+ end
75
+ end
76
+
77
+ end
78
+ end
@@ -0,0 +1,11 @@
1
+ class AddNewEmailToUsers < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :users, :new_email, :string, :default => nil
4
+ add_column :users, :new_email_token, :string, :default => nil
5
+ end
6
+
7
+ def self.down
8
+ remove_column :users, :new_email
9
+ remove_column :users, :new_email_token
10
+ end
11
+ end
@@ -0,0 +1 @@
1
+ = t('.body', url: @confirmation_url)
@@ -0,0 +1,6 @@
1
+ - if object.errors.any?
2
+ .alert.alert-danger
3
+ %ul
4
+ - for message in object.errors.full_messages
5
+ %li
6
+ = message
@@ -0,0 +1,19 @@
1
+ %h1
2
+ = t '.title'
3
+
4
+ = form_for @change_email_form, url: emails_path, method: :post do |f|
5
+
6
+ = render :partial => "/accountly/common/form_errors", :locals => {:object => @change_email_form}
7
+
8
+ .form-group
9
+ = f.label :new_email, t( '.label_new_email')
10
+ = f.text_field :new_email, :class => 'form-control'
11
+ .form-group
12
+ = f.label :new_email_confirmation, t( '.label_new_email_confirmation')
13
+ = f.text_field :new_email_confirmation, :class => 'form-control'
14
+ .form-group
15
+ = f.label :password, t( '.label_password')
16
+ = f.password_field :password, :class => 'form-control'
17
+
18
+ .form-actions
19
+ = submit_tag t( 'common.button.send' ), :id => 'change_email_button', :class => 'btn btn-primary'
@@ -0,0 +1,18 @@
1
+ %h1
2
+ = t '.title'
3
+
4
+ = form_for [:account, @password_form], url: passwords_path, method: :post do |f|
5
+
6
+ = render :partial => "/accountly/common/form_errors", :locals => {:object => @password_form}
7
+
8
+ .form-group
9
+ = f.label :original_password, t( '.label_original_password')
10
+ = f.password_field :original_password, :class => 'form-control'
11
+ .form-group
12
+ = f.label :new_password, t( '.label_new_password')
13
+ = f.password_field :new_password, :class => 'form-control'
14
+ .form-group
15
+ = f.label :new_password_confirmation, t( '.label_new_password_confirmation')
16
+ = f.password_field :new_password_confirmation, :class => 'form-control'
17
+ .form-actions
18
+ = submit_tag t( 'common.button.send' ), :id => 'password_form_button', :class => 'btn btn-primary'
@@ -0,0 +1,10 @@
1
+ %h1
2
+ = t '.title'
3
+
4
+ = t('.current_email', :email => current_user.email)
5
+ = "("
6
+ = link_to t( '.link_text.change_email'), new_email_url
7
+ = ")"
8
+ %br
9
+ %br
10
+ = link_to t( '.link_text.change_password'), new_password_url
@@ -0,0 +1,18 @@
1
+ %h1
2
+ = t '.title'
3
+
4
+ = form_for @username_form, url: usernames_path, method: :post do |f|
5
+
6
+ = render :partial => "/accountly/common/form_errors", :locals => {:object => @username_form}
7
+
8
+ .form-group
9
+ = f.label :new_username, t( '.label_new_username')
10
+ = f.text_field :new_username, :class => 'form-control'
11
+ .form-group
12
+ = f.label :new_username_confirmation, t( '.label_new_username_confirmation')
13
+ = f.text_field :new_username_confirmation, :class => 'form-control'
14
+ .form-group
15
+ = f.label :original_password, t( '.label_original_password')
16
+ = f.password_field :original_password, :class => 'form-control'
17
+ .form-actions
18
+ = submit_tag t( 'common.button.send' ), :id => 'username_form_button', :class => 'btn btn-primary'
metadata ADDED
@@ -0,0 +1,287 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: accountly
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Guido Boyke
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-12-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 4.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 4.0.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: haml
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 4.0.4
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 4.0.4
46
+ - !ruby/object:Gem::Dependency
47
+ name: lobby
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - '='
52
+ - !ruby/object:Gem::Version
53
+ version: 0.0.5
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.0.5
62
+ - !ruby/object:Gem::Dependency
63
+ name: sqlite3
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: debugger
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rspec-rails
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 2.14.0
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 2.14.0
110
+ - !ruby/object:Gem::Dependency
111
+ name: factory_girl_rails
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: capybara
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: guard-rspec
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: database_cleaner
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - '='
164
+ - !ruby/object:Gem::Version
165
+ version: 1.0.0.RC1
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - '='
172
+ - !ruby/object:Gem::Version
173
+ version: 1.0.0.RC1
174
+ - !ruby/object:Gem::Dependency
175
+ name: spork-rails
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ - !ruby/object:Gem::Dependency
191
+ name: guard-spork
192
+ requirement: !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
195
+ - - ! '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
198
+ type: :development
199
+ prerelease: false
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ! '>='
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ - !ruby/object:Gem::Dependency
207
+ name: shoulda-matchers
208
+ requirement: !ruby/object:Gem::Requirement
209
+ none: false
210
+ requirements:
211
+ - - ! '>='
212
+ - !ruby/object:Gem::Version
213
+ version: '0'
214
+ type: :development
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ! '>='
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
222
+ description: Lightweight administration on top of lobby-gem
223
+ email:
224
+ - guido.boyke@gboyke.com
225
+ executables: []
226
+ extensions: []
227
+ extra_rdoc_files: []
228
+ files:
229
+ - app/forms/accountly/password_form.rb
230
+ - app/forms/accountly/change_email_form.rb
231
+ - app/forms/accountly/username_form.rb
232
+ - app/mailers/accountly/account_mailer.rb
233
+ - app/views/layouts/accountly/application.html.erb
234
+ - app/assets/stylesheets/accountly/application.css
235
+ - app/assets/javascripts/accountly/application.js
236
+ - app/controllers/accountly/account_controller.rb
237
+ - app/controllers/accountly/settings_controller.rb
238
+ - app/controllers/accountly/confirmation_controller.rb
239
+ - app/controllers/accountly/usernames_controller.rb
240
+ - app/controllers/accountly/emails_controller.rb
241
+ - app/controllers/accountly/passwords_controller.rb
242
+ - app/helpers/accountly/application_helper.rb
243
+ - app/models/accountly/update_email_user.rb
244
+ - config/initializers/fix_active_record_validations_full_messages.rb
245
+ - config/locales/de.yml
246
+ - config/locales/en.yml
247
+ - config/locales/en.bootstrap.yml
248
+ - config/routes.rb
249
+ - lib/accountly/engine.rb
250
+ - lib/accountly/version.rb
251
+ - lib/generators/accountly/install_generator.rb
252
+ - lib/generators/templates/db/migrate/add_new_email_to_users.rb
253
+ - lib/generators/templates/views/usernames/new.html.haml
254
+ - lib/generators/templates/views/emails/new.html.haml
255
+ - lib/generators/templates/views/passwords/new.html.haml
256
+ - lib/generators/templates/views/settings/index.html.haml
257
+ - lib/generators/templates/views/account_mailer/new_email_request.text.haml
258
+ - lib/generators/templates/views/common/_form_errors.html.haml
259
+ - lib/accountly.rb
260
+ - MIT-LICENSE
261
+ - Rakefile
262
+ - README.rdoc
263
+ homepage: http://www.gboyke.com
264
+ licenses: []
265
+ post_install_message:
266
+ rdoc_options: []
267
+ require_paths:
268
+ - lib
269
+ required_ruby_version: !ruby/object:Gem::Requirement
270
+ none: false
271
+ requirements:
272
+ - - ! '>='
273
+ - !ruby/object:Gem::Version
274
+ version: '0'
275
+ required_rubygems_version: !ruby/object:Gem::Requirement
276
+ none: false
277
+ requirements:
278
+ - - ! '>='
279
+ - !ruby/object:Gem::Version
280
+ version: '0'
281
+ requirements: []
282
+ rubyforge_project:
283
+ rubygems_version: 1.8.23
284
+ signing_key:
285
+ specification_version: 3
286
+ summary: Account Administration
287
+ test_files: []