mtdevise 5.0.0 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +20 -20
  3. data/README.md +90 -90
  4. data/Rakefile +33 -33
  5. data/app/assets/config/mtdevise_manifest.js +2 -2
  6. data/app/assets/javascripts/mtdevise/application.js +2 -2
  7. data/app/assets/stylesheets/mtdevise/application.scss +2 -2
  8. data/app/controllers/mtdevise/account/dashboard_controller.rb +14 -14
  9. data/app/controllers/mtdevise/account/users_controller.rb +32 -32
  10. data/app/controllers/mtdevise/accounts_controller.rb +63 -63
  11. data/app/controllers/mtdevise/application_controller.rb +63 -63
  12. data/app/controllers/mtdevise/dashboard_controller.rb +14 -14
  13. data/app/controllers/mtdevise/welcome_controller.rb +11 -11
  14. data/app/extenders/controllers/application_controller_extender.rb +8 -8
  15. data/app/extenders/mtdevise/constraints/subdomain_required.rb +11 -11
  16. data/app/helpers/mtdevise/application_helper.rb +24 -24
  17. data/app/jobs/mtdevise/application_job.rb +3 -3
  18. data/app/mailers/mtdevise/application_mailer.rb +7 -7
  19. data/app/models/concerns/mtdevise/user_storage.rb +12 -12
  20. data/app/models/mtdevise/account.rb +47 -47
  21. data/app/models/mtdevise/application_record.rb +4 -4
  22. data/app/models/mtdevise/member.rb +8 -8
  23. data/app/models/mtdevise/user.rb +18 -18
  24. data/app/views/devise/confirmations/new.html.erb +23 -23
  25. data/app/views/devise/mailer/confirmation_instructions.html.erb +2 -2
  26. data/app/views/devise/mailer/reset_password_instructions.html.erb +4 -4
  27. data/app/views/devise/mailer/unlock_instructions.html.erb +3 -3
  28. data/app/views/devise/passwords/edit.html.erb +28 -28
  29. data/app/views/devise/passwords/new.html.erb +23 -23
  30. data/app/views/devise/registrations/edit.html.erb +18 -18
  31. data/app/views/devise/registrations/new.html.erb +31 -31
  32. data/app/views/devise/sessions/new.html.erb +31 -31
  33. data/app/views/devise/shared/_links.html.erb +21 -21
  34. data/app/views/devise/unlocks/new.html.erb +25 -25
  35. data/app/views/layouts/mtdevise/accounts.html.erb +15 -15
  36. data/app/views/layouts/mtdevise/accountsindex.html.erb +15 -15
  37. data/app/views/layouts/mtdevise/application.html.erb +15 -15
  38. data/app/views/layouts/mtdevise/dashboard.html.erb +16 -16
  39. data/app/views/layouts/mtdevise/signin.html.erb +15 -15
  40. data/app/views/layouts/mtdevise/signup.html.erb +15 -15
  41. data/app/views/layouts/mtdevise/useredit.html.erb +15 -15
  42. data/app/views/layouts/mtdevise/welcome.html.erb +15 -15
  43. data/app/views/mtdevise/account/dashboard/index.html.erb +1 -1
  44. data/app/views/mtdevise/account/sessions/new.html.erb +15 -15
  45. data/app/views/mtdevise/account/users/_form.html.erb +11 -11
  46. data/app/views/mtdevise/account/users/new.html.erb +5 -5
  47. data/app/views/mtdevise/accounts/index.html.erb +30 -30
  48. data/app/views/mtdevise/accounts/new.html.erb +80 -80
  49. data/app/views/mtdevise/dashboard/index.html.erb +1 -1
  50. data/app/views/mtdevise/welcome/index.html.erb +18 -18
  51. data/app/views/shared/_flash.html.erb +10 -10
  52. data/app/views/shared/_header.html.erb +19 -19
  53. data/app/views/shared/_validation.html.erb +10 -10
  54. data/config/initializers/assets.rb +2 -2
  55. data/config/initializers/devise.rb +279 -279
  56. data/config/initializers/devise/strategies/subdomain.rb +26 -26
  57. data/config/locales/devise.en.yml +60 -60
  58. data/config/routes.rb +22 -22
  59. data/db/migrate/20150426071228_create_mtdevise_accounts.rb +11 -11
  60. data/db/migrate/20150426115631_add_owner_id_to_mtdevise_accounts.rb +7 -7
  61. data/db/migrate/20150426115910_create_mtdevise_users.rb +12 -12
  62. data/db/migrate/20150426143800_add_devise_to_mtdevise_users.rb +50 -50
  63. data/db/migrate/20150427200506_add_subdomain_to_mtdevise_accounts.rb +8 -8
  64. data/db/migrate/20150428110406_create_mtdevise_members.rb +12 -12
  65. data/db/migrate/20150504181830_add_confirmed_at_to_users.rb +10 -10
  66. data/db/migrate/20150719125100_add_authentication_token_to_mtdevise_users.rb +8 -8
  67. data/db/migrate/20151231043439_add_firstname_to_mtdevise_accounts.rb +9 -9
  68. data/lib/generators/mtdevise/views_generator.rb +60 -60
  69. data/lib/mtdevise.rb +4 -4
  70. data/lib/mtdevise/active_record_extensions.rb +15 -15
  71. data/lib/mtdevise/engine.rb +51 -51
  72. data/lib/mtdevise/scoped_to.rb +9 -9
  73. data/lib/mtdevise/version.rb +3 -3
  74. data/lib/tasks/mtdevise_tasks.rake +4 -4
  75. data/lib/templates/erb/scaffold/_form.html.erb +15 -15
  76. metadata +50 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27fbbfcf0b33c244b5d68cc0a2e7edd9b837211b
4
- data.tar.gz: 6c3c945267c93d6bf255d88cc0abab1658643ce0
3
+ metadata.gz: 2a7cf896f2a8269a1269c450148a1d56d42621b2
4
+ data.tar.gz: 87e8012b40c394b133ef4f7cca7cef4529603712
5
5
  SHA512:
6
- metadata.gz: 1f6d706ef1d32e6a9bdf41618e34efd1bcb6d98d809ffb5e4a441ae03de86602f8e369e7c31c362172bad8f43e7c28d6dbf2a3a85a1f469f83cc1a951552f4b3
7
- data.tar.gz: 4ac947930f5fec097f6bf34a40113fc08f8142c929da50af55d1fb367fa747d03277e5afd249c23be7d6b80cd3100ddc2d731f3be2ae1a0829c11907c77ec8ad
6
+ metadata.gz: f21e675c15e514064dd10e448a4fa726f6304adc624e04542a45e6f45b80d7dba1134e335b49deddaeff55d1ecd741463fbda72072ef909cfa6a0e1e6c9807c0
7
+ data.tar.gz: 995a8050786b47a68801d4e0ab93e3e02d67a0ae58178988c7f3aad94b7678a0c823ff0ccbd0229dd35c7df000ae207765bd8d45a09d65e7546b767dba5fbb1a
@@ -1,20 +1,20 @@
1
- Copyright 2016-2017 BradPotts - PHCNetworks
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.
1
+ Copyright 2016-2017 BradPotts - PHCNetworks
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.
data/README.md CHANGED
@@ -1,90 +1,90 @@
1
- [![security](https://hakiri.io/github/PHCNetworks/multi-tenancy-devise/master.svg)](https://hakiri.io/github/PHCNetworks/multi-tenancy-devise/master)
2
- [![Code Climate](https://codeclimate.com/github/PHCNetworks/multi-tenancy-devise/badges/gpa.svg)](https://codeclimate.com/github/PHCNetworks/multi-tenancy-devise)
3
- [![Dependency Status](https://gemnasium.com/badges/github.com/PHCNetworks/multi-tenancy-devise.svg)](https://gemnasium.com/github.com/PHCNetworks/multi-tenancy-devise)
4
- [![Gem Version](https://badge.fury.io/rb/mtdevise.svg)](https://badge.fury.io/rb/mtdevise)
5
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/PHCNetworks/multi-tenancy-devise/blob/master/MIT-LICENSE)
6
-
7
- ### Mtdevise(5)(MultiTenancyDevise) Documentation
8
- PHC mtdevise gem adds multi-tenant and account management features to rails Devise gem. Plataformatec Devise and required custom Bootstrap Devise views included.
9
-
10
- * Multi-tenancy using subdomain scoping and account_id column.
11
- * Adds basecamp style logins to devise authentication gem.
12
- * Welcome, Dashboard with custom Devise views included.
13
- * Highly customizable views and layouts using standard bootstrap 3 code.
14
- * Central login screen for all tenants (users) or logins through a subdomain.
15
- * Mis-Spelling and redirect to welcome screen if subdomain none-existent.
16
- * Compatible with postgre, mysql and sqlite (for dev environments).
17
-
18
- #### Step 1 - Add user model to your app (Must be Done First!!)
19
- Generate a user.rb file in your mainapp and add the code below
20
-
21
- rails g model User
22
- include Mtdevise::UserStorage
23
-
24
- #### Step 2 - Add Mtdevise to your gemfile and run command
25
-
26
- gem 'mtdevise', '~> 5.0'
27
- bundle exec install
28
-
29
- #### Step 3 - Add and migrate mtdevise database tables
30
-
31
- rake railties:install:migrations
32
- rake db:migrate
33
-
34
- #### Step 4 - Configure ActionMailer
35
- * Mailer functions are required in order for mtdevise to operate.
36
- * Mailer is used for confirmation and password reset functions.
37
-
38
- #### Step 5 - Mount the Engine in your Routes File
39
- Add this line at the end of the routes file.
40
-
41
- mount Mtdevise::Engine, :at => '/'
42
-
43
- #### Step 6 - Constrain the routs you want secured
44
- All the routes you want to have multi-tenacy login functions goes in between the constraints block.
45
-
46
- constraints(Mtdevise::Constraints::SubdomainRequired) do
47
- # Routes Requiring Security & Multi-Tenancy Routes
48
- end
49
-
50
- #### Step 7 - Modifications to MainApp Controllers & Database
51
- Your app needs modification to [controllers (example)](https://github.com/PHCNetworks/multi-tenancy-devise/wiki/Scoped-Controller-Example)
52
- Any corresponding db database tables must have an accounts_id column
53
-
54
- accounts_id
55
-
56
- #### Step 8 - Add mtdevise extension to models
57
- Add the mtdevise extension to the top of all models for the routes configured in the previous step.
58
-
59
- def self.scoped_to(account)
60
- where(:account_id => account.id)
61
- end
62
-
63
- #### Step 9 - Configure scopes in your controller
64
- Scope your controllers. Examples on github wiki or multi-tenant starter app.
65
-
66
- .scoped_to(current_account)
67
-
68
- #### Step 10 - Environment (ENV) Variables
69
- Set a sent from email address for confirmation and password reset emails [more info here.](https://github.com/PHCNetworks/multi-tenancy-devise/wiki/ENV---Environment-Variables) .
70
-
71
- PHC_MTDEVISE_SENDER = no_reply@example.com
72
-
73
- ### Additional Information
74
-
75
- #### Views - Mtdevise Views Can be Customized
76
- Once installed views can be generated and customized to your apps needs.
77
-
78
- rails generate mtdevise:views
79
- rake assets:clobber
80
- rake assets:precompile
81
-
82
- #### Having troubles ?
83
- [Multi-Tenant Starter App](https://github.com/PHCNetworks/multi-tenancy-starter-devise)
84
- [Documentation (Github Wiki)](https://github.com/PHCNetworks/multi-tenancy-devise/wiki)
85
- [Environment Variables](https://github.com/PHCNetworks/multi-tenancy-devise/wiki/ENV---Environment-Variables)
86
- [Issues & Bug Reports](https://github.com/PHCNetworks/multi-tenancy-devise/issues)
87
- [Past Security Patch Notes](https://github.com/PHCNetworks/multi-tenancy-devise/wiki/Critical-Security-Updates)
88
- [Managed by PHCNetworks](http://phcnetworks.net)
89
-
90
- [![Circle CI](https://circleci.com/gh/PHCNetworks/multi-tenancy-devise/tree/master.svg?style=svg)](https://circleci.com/gh/PHCNetworks/multi-tenancy-devise/tree/master)
1
+ [![security](https://hakiri.io/github/PHCNetworks/multi-tenancy-devise/master.svg)](https://hakiri.io/github/PHCNetworks/multi-tenancy-devise/master)
2
+ [![Code Climate](https://codeclimate.com/github/PHCNetworks/multi-tenancy-devise/badges/gpa.svg)](https://codeclimate.com/github/PHCNetworks/multi-tenancy-devise)
3
+ [![Dependency Status](https://gemnasium.com/badges/github.com/PHCNetworks/multi-tenancy-devise.svg)](https://gemnasium.com/github.com/PHCNetworks/multi-tenancy-devise)
4
+ [![Gem Version](https://badge.fury.io/rb/mtdevise.svg)](https://badge.fury.io/rb/mtdevise)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/PHCNetworks/multi-tenancy-devise/blob/master/MIT-LICENSE)
6
+
7
+ ### MTDevise(5) Rails 5.1 Multi-Tenancy Engine Documentation
8
+ PHC MTDevise(5) Rails 5.1 engine adds multi-tenant and account management features to rails Devise gem. Plataformatec Devise and required custom Bootstrap Devise views included.
9
+
10
+ * Multi-tenancy using subdomain scoping and account_id column.
11
+ * Adds basecamp style logins to devise authentication gem.
12
+ * Welcome, Dashboard with custom Devise views included.
13
+ * Highly customizable views and layouts using standard bootstrap 3 code.
14
+ * Central login screen for all tenants (users) or logins through a subdomain.
15
+ * Mis-Spelling and redirect to welcome screen if subdomain none-existent.
16
+ * Compatible with postgre, mysql and sqlite (for dev environments).
17
+
18
+ #### Step 1 - Add user model to your app (Must be Done First!!)
19
+ Generate a user.rb file in your mainapp and add the code below
20
+
21
+ rails g model User
22
+ include Mtdevise::UserStorage
23
+
24
+ #### Step 2 - Add Mtdevise to your gemfile and run command
25
+
26
+ gem 'mtdevise', '~> 5.0'
27
+ bundle exec install
28
+
29
+ #### Step 3 - Add and migrate mtdevise database tables
30
+
31
+ rake railties:install:migrations
32
+ rake db:migrate
33
+
34
+ #### Step 4 - Configure ActionMailer
35
+ * Mailer functions are required in order for mtdevise to operate.
36
+ * Mailer is used for confirmation and password reset functions.
37
+
38
+ #### Step 5 - Mount the Engine in your Routes File
39
+ Add this line at the end of the routes file.
40
+
41
+ mount Mtdevise::Engine, :at => '/'
42
+
43
+ #### Step 6 - Constrain the routs you want secured
44
+ All the routes you want to have multi-tenacy login functions goes in between the constraints block.
45
+
46
+ constraints(Mtdevise::Constraints::SubdomainRequired) do
47
+ # Routes Requiring Security & Multi-Tenancy Routes
48
+ end
49
+
50
+ #### Step 7 - Modifications to MainApp Controllers & Database
51
+ Your app needs modification to [controllers (example)](https://github.com/PHCNetworks/multi-tenancy-devise/wiki/Scoped-Controller-Example)
52
+ Any corresponding db database tables must have an accounts_id column
53
+
54
+ accounts_id
55
+
56
+ #### Step 8 - Add mtdevise extension to models
57
+ Add the mtdevise extension to the top of all models for the routes configured in the previous step.
58
+
59
+ def self.scoped_to(account)
60
+ where(:account_id => account.id)
61
+ end
62
+
63
+ #### Step 9 - Configure scopes in your controller
64
+ Scope your controllers. Examples on github wiki or multi-tenant starter app.
65
+
66
+ .scoped_to(current_account)
67
+
68
+ #### Step 10 - Environment (ENV) Variables
69
+ Set a sent from email address for confirmation and password reset emails [more info here.](https://github.com/PHCNetworks/multi-tenancy-devise/wiki/ENV---Environment-Variables) .
70
+
71
+ PHC_MTDEVISE_SENDER = no_reply@example.com
72
+
73
+ ### Additional Information
74
+
75
+ #### Views - Mtdevise Views Can be Customized
76
+ Once installed views can be generated and customized to your apps needs.
77
+
78
+ rails generate mtdevise:views
79
+ rake assets:clobber
80
+ rake assets:precompile
81
+
82
+ #### Having troubles ?
83
+ [Multi-Tenant Starter App](https://github.com/PHCNetworks/multi-tenancy-starter-devise)
84
+ [Documentation (Github Wiki)](https://github.com/PHCNetworks/multi-tenancy-devise/wiki)
85
+ [Environment Variables](https://github.com/PHCNetworks/multi-tenancy-devise/wiki/ENV---Environment-Variables)
86
+ [Issues & Bug Reports](https://github.com/PHCNetworks/multi-tenancy-devise/issues)
87
+ [Past Security Patch Notes](https://github.com/PHCNetworks/multi-tenancy-devise/wiki/Critical-Security-Updates)
88
+ [Managed by PHCNetworks](http://phcnetworks.net)
89
+
90
+ [![Circle CI](https://circleci.com/gh/PHCNetworks/multi-tenancy-devise/tree/master.svg?style=svg)](https://circleci.com/gh/PHCNetworks/multi-tenancy-devise/tree/master)
data/Rakefile CHANGED
@@ -1,33 +1,33 @@
1
- begin
2
- require 'bundler/setup'
3
-
4
- rescue LoadError
5
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
- end
7
-
8
- require 'rdoc/task'
9
-
10
- RDoc::Task.new(:rdoc) do |rdoc|
11
- rdoc.rdoc_dir = 'rdoc'
12
- rdoc.title = 'Mtdevise'
13
- rdoc.options << '--line-numbers'
14
- rdoc.rdoc_files.include('README.md')
15
- rdoc.rdoc_files.include('lib/**/*.rb')
16
- end
17
-
18
- APP_RAKEFILE = File.expand_path("../spec/testapp/Rakefile", __FILE__)
19
-
20
- load 'rails/tasks/engine.rake'
21
- load 'rails/tasks/statistics.rake'
22
-
23
- require 'bundler/gem_tasks'
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
- task default: :test
1
+ begin
2
+ require 'bundler/setup'
3
+
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+
8
+ require 'rdoc/task'
9
+
10
+ RDoc::Task.new(:rdoc) do |rdoc|
11
+ rdoc.rdoc_dir = 'rdoc'
12
+ rdoc.title = 'Mtdevise'
13
+ rdoc.options << '--line-numbers'
14
+ rdoc.rdoc_files.include('README.md')
15
+ rdoc.rdoc_files.include('lib/**/*.rb')
16
+ end
17
+
18
+ APP_RAKEFILE = File.expand_path("../spec/testapp/Rakefile", __FILE__)
19
+
20
+ load 'rails/tasks/engine.rake'
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+ require 'bundler/gem_tasks'
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
+ task default: :test
@@ -1,2 +1,2 @@
1
- //= link_directory ../javascripts/mtdevise .js
2
- //= link_directory ../stylesheets/mtdevise .scss
1
+ //= link_directory ../javascripts/mtdevise .js
2
+ //= link_directory ../stylesheets/mtdevise .scss
@@ -1,2 +1,2 @@
1
- // Load PHCAdmin3 Javascript
2
- //= require phc_admins_main_three
1
+ // Load PHCAdmin3 Javascript
2
+ //= require phc_admins_main_three
@@ -1,2 +1,2 @@
1
- // Load PHCAdmin3 Styles
2
- @import "phc_admins_style_three";
1
+ // Load PHCAdmin3 Styles
2
+ @import "phc_admins_style_three";
@@ -1,15 +1,15 @@
1
- require_dependency "mtdevise/application_controller"
2
-
3
- module Mtdevise
4
- class Account::DashboardController < Mtdevise::ApplicationController
5
-
6
- # Filters & Layouts
7
- layout "mtdevise/dashboard"
8
- before_action :authenticate_user!
9
-
10
- # User Dashboard Backend
11
- def index
12
- end
13
-
14
- end
1
+ require_dependency "mtdevise/application_controller"
2
+
3
+ module Mtdevise
4
+ class Account::DashboardController < Mtdevise::ApplicationController
5
+
6
+ # Filters & Layouts
7
+ layout "mtdevise/dashboard"
8
+ before_action :authenticate_user!
9
+
10
+ # User Dashboard Backend
11
+ def index
12
+ end
13
+
14
+ end
15
15
  end
@@ -1,33 +1,33 @@
1
- require_dependency "mtdevise/application_controller"
2
-
3
- module Mtdevise
4
- class Account::UsersController < ApplicationController
5
-
6
- # Layouts and Filters
7
- before_action :authenticate_user!
8
- layout :layouts_resolver_accounts
9
- acts_as_token_authentication_handler_for User
10
-
11
- # Define New User
12
- def new
13
- @user = Mtdevise::User.new
14
- end
15
-
16
- # Create Account
17
- def create
18
- account = Mtdevise::Account.find_by_subdomain!(request.subdomain)
19
- user = account.users.create(user_params)
20
- sign_in user
21
- flash[:success] = "You have signed up successfully."
22
- redirect_to root_path
23
- end
24
-
25
- private
26
-
27
- # Common Params
28
- def user_params
29
- params.require(:user).permit(:email, :password, :password_confirmation)
30
- end
31
-
32
- end
1
+ require_dependency "mtdevise/application_controller"
2
+
3
+ module Mtdevise
4
+ class Account::UsersController < ApplicationController
5
+
6
+ # Layouts and Filters
7
+ before_action :authenticate_user!
8
+ layout :layouts_resolver_accounts
9
+ acts_as_token_authentication_handler_for User
10
+
11
+ # Define New User
12
+ def new
13
+ @user = Mtdevise::User.new
14
+ end
15
+
16
+ # Create Account
17
+ def create
18
+ account = Mtdevise::Account.find_by_subdomain!(request.subdomain)
19
+ user = account.users.create(user_params)
20
+ sign_in user
21
+ flash[:success] = "You have signed up successfully."
22
+ redirect_to root_path
23
+ end
24
+
25
+ private
26
+
27
+ # Common Params
28
+ def user_params
29
+ params.require(:user).permit(:email, :password, :password_confirmation)
30
+ end
31
+
32
+ end
33
33
  end
@@ -1,63 +1,63 @@
1
- require_dependency "mtdevise/application_controller"
2
-
3
- module Mtdevise
4
- class AccountsController < ApplicationController
5
-
6
- # Layouts and Filters
7
- layout :layouts_resolver_accounts
8
- before_action :redirect_if_coming_form_sign_up, only: :new
9
- before_action :authenticate_user!, except: [:new, :create]
10
-
11
- # Accounts Index
12
- def index
13
- @accounts = current_user.accounts
14
- end
15
-
16
- # Accounts Registration
17
- def new
18
- @account = Mtdevise::Account.new
19
- @account.build_owner unless user_signed_in?
20
- end
21
-
22
- # Accounts Create action
23
- def create
24
- account = if user_signed_in?
25
- Mtdevise::Account.create(account_params)
26
- else
27
- Mtdevise::Account.create_with_owner(account_params)
28
- end
29
-
30
- @account = account
31
- if account.valid?
32
- flash[:success] = "Your account has been successfully created."
33
-
34
- if user_signed_in?
35
- account.owner = current_user
36
- account.users << current_user
37
- account.save
38
- redirect_to mtdevise.accounts_path
39
-
40
- else
41
- sign_in account.owner
42
- redirect_to mtdevise.root_url(:subdomain => account.subdomain)
43
- end
44
-
45
- else
46
- flash[:error] = "Sorry, your account could not be created."
47
- render :new
48
- end
49
-
50
- end
51
-
52
- private
53
-
54
- def redirect_if_coming_form_sign_up
55
- redirect_to accounts_path if request.url =~ /#{sign_up_path}/ && user_signed_in?
56
- end
57
-
58
- def account_params
59
- params.require(:account).permit(:name, :firstname, :lastname, :username, :subdomain, { :owner_attributes => [:email, :password, :password_confirmation]})
60
- end
61
-
62
- end
63
- end
1
+ require_dependency "mtdevise/application_controller"
2
+
3
+ module Mtdevise
4
+ class AccountsController < ApplicationController
5
+
6
+ # Layouts and Filters
7
+ layout :layouts_resolver_accounts
8
+ before_action :redirect_if_coming_form_sign_up, only: :new
9
+ before_action :authenticate_user!, except: [:new, :create]
10
+
11
+ # Accounts Index
12
+ def index
13
+ @accounts = current_user.accounts
14
+ end
15
+
16
+ # Accounts Registration
17
+ def new
18
+ @account = Mtdevise::Account.new
19
+ @account.build_owner unless user_signed_in?
20
+ end
21
+
22
+ # Accounts Create action
23
+ def create
24
+ account = if user_signed_in?
25
+ Mtdevise::Account.create(account_params)
26
+ else
27
+ Mtdevise::Account.create_with_owner(account_params)
28
+ end
29
+
30
+ @account = account
31
+ if account.valid?
32
+ flash[:success] = "Your account has been successfully created."
33
+
34
+ if user_signed_in?
35
+ account.owner = current_user
36
+ account.users << current_user
37
+ account.save
38
+ redirect_to mtdevise.accounts_path
39
+
40
+ else
41
+ sign_in account.owner
42
+ redirect_to mtdevise.root_url(:subdomain => account.subdomain)
43
+ end
44
+
45
+ else
46
+ flash[:error] = "Sorry, your account could not be created."
47
+ render :new
48
+ end
49
+
50
+ end
51
+
52
+ private
53
+
54
+ def redirect_if_coming_form_sign_up
55
+ redirect_to accounts_path if request.url =~ /#{sign_up_path}/ && user_signed_in?
56
+ end
57
+
58
+ def account_params
59
+ params.require(:account).permit(:name, :firstname, :lastname, :username, :subdomain, { :owner_attributes => [:email, :password, :password_confirmation]})
60
+ end
61
+
62
+ end
63
+ end