mtwarden 6.0.1 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +20 -20
  3. data/README.md +35 -35
  4. data/Rakefile +33 -33
  5. data/app/assets/config/mtwarden_manifest.js +2 -2
  6. data/app/assets/javascripts/mtwarden/application.js +2 -2
  7. data/app/assets/stylesheets/mtwarden/application.scss +2 -2
  8. data/app/controllers/mtwarden/account/accounts_controller.rb +67 -67
  9. data/app/controllers/mtwarden/account/dashboard_controller.rb +7 -7
  10. data/app/controllers/mtwarden/account/sessions_controller.rb +20 -20
  11. data/app/controllers/mtwarden/account/users_controller.rb +23 -23
  12. data/app/controllers/mtwarden/accounts_controller.rb +32 -32
  13. data/app/controllers/mtwarden/application_controller.rb +12 -12
  14. data/app/controllers/mtwarden/dashboard_controller.rb +6 -6
  15. data/app/extenders/controllers/application_controller_extender.rb +38 -38
  16. data/app/helpers/mtwarden/application_helper.rb +4 -4
  17. data/app/jobs/mtwarden/application_job.rb +4 -4
  18. data/app/mailers/mtwarden/application_mailer.rb +8 -8
  19. data/app/models/mtwarden/account.rb +39 -39
  20. data/app/models/mtwarden/application_record.rb +5 -5
  21. data/app/models/mtwarden/member.rb +6 -6
  22. data/app/models/mtwarden/plan.rb +4 -4
  23. data/app/models/mtwarden/user.rb +7 -7
  24. data/app/views/layouts/mtwarden/application.html.erb +16 -16
  25. data/app/views/mtwarden/account/accounts/_existing_subscription.html.erb +3 -3
  26. data/app/views/mtwarden/account/accounts/_new_subscription.html.erb +38 -38
  27. data/app/views/mtwarden/account/accounts/edit.html.erb +17 -17
  28. data/app/views/mtwarden/account/accounts/plan.html.erb +14 -14
  29. data/app/views/mtwarden/account/dashboard/index.html.erb +1 -1
  30. data/app/views/mtwarden/account/sessions/new.html.erb +19 -19
  31. data/app/views/mtwarden/account/users/_form.html.erb +14 -14
  32. data/app/views/mtwarden/account/users/new.html.erb +6 -6
  33. data/app/views/mtwarden/accounts/new.html.erb +20 -20
  34. data/app/views/mtwarden/dashboard/index.html.erb +1 -1
  35. data/app/views/mtwarden/shared/_login.html.erb +7 -7
  36. data/config/initializers/warden/strategies/password.rb +18 -18
  37. data/config/routes.rb +30 -30
  38. data/db/migrate/20140621030847_create_mtwarden_accounts.rb +11 -11
  39. data/db/migrate/20140621114149_add_owner_id_to_mtwarden_accounts.rb +7 -7
  40. data/db/migrate/20140621114231_create_mtwarden_users.rb +12 -12
  41. data/db/migrate/20140621114308_create_mtwarden_members.rb +12 -12
  42. data/db/migrate/20140621114417_add_subdomain_to_mtwarden_accounts.rb +8 -8
  43. data/db/migrate/20140829231923_create_mtwarden_plans.rb +13 -13
  44. data/db/migrate/20140830011033_add_plan_id_to_mtwarden_accounts.rb +7 -7
  45. data/db/migrate/20140830020346_add_braintree_subscription_id_to_mtwarden_accounts.rb +7 -7
  46. data/lib/mtwarden.rb +4 -4
  47. data/lib/mtwarden/braintree_plan_fetcher.rb +22 -22
  48. data/lib/mtwarden/constraints/subdomain_required.rb +11 -11
  49. data/lib/mtwarden/engine.rb +52 -52
  50. data/lib/mtwarden/scoped_to.rb +9 -9
  51. data/lib/mtwarden/testing_support/authentication_helpers.rb +21 -21
  52. data/lib/mtwarden/testing_support/factories/account_factory.rb +14 -14
  53. data/lib/mtwarden/testing_support/factories/user_factory.rb +7 -7
  54. data/lib/mtwarden/testing_support/subdomain_helpers.rb +16 -16
  55. data/lib/mtwarden/version.rb +3 -3
  56. data/lib/tasks/mtwarden_tasks.rake +6 -6
  57. metadata +23 -53
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e537c5d2f81b6facbb000fb52a08854c2c866ebe
4
- data.tar.gz: 8f23669c4280c416dcee9e8f090a6f97f5841c60
3
+ metadata.gz: 7a57797ca77aa2cf92f52bdaaa70e92a17bd423f
4
+ data.tar.gz: 10b3d7dbe1b815b7a11e0ca82f08819e9c8a6c95
5
5
  SHA512:
6
- metadata.gz: b5fd8d0310dbad5382b948125bfbff1d94289281c158f8218237f2f42fa2f4828c066d1bd176366c63821532b910adae150de3328a7bf0d0aa414e537fa8ce2e
7
- data.tar.gz: 8ad9173565093b0286c9a0d695f6d90da4610e576daa272919062f054ec3911176ec98f20954a8f9291ea97436ab46d2f579ad85def9e52fdbcbf3c99f51e2e6
6
+ metadata.gz: 7f13566412310a77a8f5a0e0380e4cca229bf61e4baed942d791ee1e9f61656838a1892236baecfa143a7a9450ff87b5f2b4c3bdac1c05f402347e7ef1cec4ff
7
+ data.tar.gz: ce04dbf003c9725c0edff3519e40bd0a2d0ff31dea2d635104138f6ad50e72476ce294808e7bcc60c5bf517416f62f676eff91c65009ebac0d318be6532ffc07
data/MIT-LICENSE CHANGED
@@ -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,35 +1,35 @@
1
- [![security](https://hakiri.io/github/PHCNetworks/multi-tenancy-warden/master.svg)](https://hakiri.io/github/PHCNetworks/multi-tenancy-warden/master)
2
- [![Code Climate](https://codeclimate.com/github/PHCNetworks/multi-tenancy-warden/badges/gpa.svg)](https://codeclimate.com/github/PHCNetworks/multi-tenancy-warden)
3
- [![Dependency Status](https://gemnasium.com/badges/github.com/PHCNetworks/multi-tenancy-warden.svg)](https://gemnasium.com/github.com/PHCNetworks/multi-tenancy-warden)
4
- [![Gem Version](https://badge.fury.io/rb/mtwarden.svg)](https://badge.fury.io/rb/mtwarden)
5
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/PHCNetworks/multi-tenancy-warden/blob/master/MIT-LICENSE)
6
-
7
- ### MTWarden(6) Rails 5.1 Multi-Tenancy Engine Documentation
8
- PHC MTWarden(6) Rails 5.1 engine adds a separate multi-tenant layer that handles all user registrations, multi-tenancy app functions, and login through subdomains using Warden authentication gem.
9
-
10
- #### Step 1 - Add Mtwarden to your gemfile and run command
11
-
12
- gem 'mtwarden', '~> 6.0'
13
- bundle exec install
14
-
15
- #### Step 2 - Add and migrate mtwarden database tables
16
-
17
- rake railties:install:migrations
18
- rake db:migrate
19
-
20
- #### Step 3 - Mount the Engine in your Routes File
21
- Add this line at the top of the routes.rb file.
22
-
23
- require 'mtwarden/constraints/subdomain_required'
24
-
25
- #### Step 4 - Mount the Engine in your Routes File
26
- Add this line at the end of the routes.rb file.
27
-
28
- mount Mtwarden::Engine, :at => '/'
29
-
30
- #### Step 5 - Constrain the routes you want secured in your routes.rb file.
31
- All the routes you want to have multi-tenancy login functions goes in between the constraints block.
32
-
33
- constraints(Mtwarden::Constraints::SubdomainRequired) do
34
- # Routes Requiring Security & Multi-Tenancy Routes
35
- end
1
+ [![security](https://hakiri.io/github/PHCNetworks/multi-tenancy-warden/master.svg)](https://hakiri.io/github/PHCNetworks/multi-tenancy-warden/master)
2
+ [![Code Climate](https://codeclimate.com/github/PHCNetworks/multi-tenancy-warden/badges/gpa.svg)](https://codeclimate.com/github/PHCNetworks/multi-tenancy-warden)
3
+ [![Dependency Status](https://gemnasium.com/badges/github.com/PHCNetworks/multi-tenancy-warden.svg)](https://gemnasium.com/github.com/PHCNetworks/multi-tenancy-warden)
4
+ [![Gem Version](https://badge.fury.io/rb/mtwarden.svg)](https://badge.fury.io/rb/mtwarden)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/PHCNetworks/multi-tenancy-warden/blob/master/MIT-LICENSE)
6
+
7
+ ### MTWarden(6) Rails 5.1 Multi-Tenancy Engine Documentation
8
+ PHC MTWarden(6) Rails 5.1 engine adds a separate multi-tenant layer that handles all user registrations, multi-tenancy app functions, and login through subdomains using Warden authentication gem.
9
+
10
+ #### Step 1 - Add Mtwarden to your gemfile and run command
11
+
12
+ gem 'mtwarden', '~> 6.0'
13
+ bundle exec install
14
+
15
+ #### Step 2 - Add and migrate mtwarden database tables
16
+
17
+ rake railties:install:migrations
18
+ rake db:migrate
19
+
20
+ #### Step 3 - Mount the Engine in your Routes File
21
+ Add this line at the top of the routes.rb file.
22
+
23
+ require 'mtwarden/constraints/subdomain_required'
24
+
25
+ #### Step 4 - Mount the Engine in your Routes File
26
+ Add this line at the end of the routes.rb file.
27
+
28
+ mount Mtwarden::Engine, :at => '/'
29
+
30
+ #### Step 5 - Constrain the routes you want secured in your routes.rb file.
31
+ All the routes you want to have multi-tenancy login functions goes in between the constraints block.
32
+
33
+ constraints(Mtwarden::Constraints::SubdomainRequired) do
34
+ # Routes Requiring Security & Multi-Tenancy Routes
35
+ end
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 = 'Mtwarden'
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 = 'Mtwarden'
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/mtwarden .js
2
- //= link_directory ../stylesheets/mtwarden .scss
1
+ //= link_directory ../javascripts/mtwarden .js
2
+ //= link_directory ../stylesheets/mtwarden .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,67 +1,67 @@
1
- require_dependency "mtwarden/application_controller"
2
-
3
- module Mtwarden
4
- class Account::AccountsController < ApplicationController
5
- before_filter :authenticate_user!
6
- before_filter :authorize_owner, only: [:edit, :update, :plan]
7
-
8
- def update
9
- plan_id = account_params.delete(:plan_id)
10
- if current_account.update_attributes(account_params)
11
- flash[:success] = "Account updated successfully."
12
- if plan_id != current_account.plan_id
13
- redirect_to plan_account_url(:plan_id => plan_id)
14
- else
15
- redirect_to root_path
16
- end
17
- else
18
- flash[:error] = "Account could not be updated."
19
- render :edit
20
- end
21
- end
22
-
23
- def plan
24
- @plan = Mtwarden::Plan.find(params[:plan_id])
25
- end
26
-
27
- def subscribe
28
- @plan = Mtwarden::Plan.find(params[:plan_id])
29
- @result = Braintree::TransparentRedirect.confirm(request.query_string)
30
- if @result.success?
31
- subscription_result = Braintree::Subscription.create(
32
- :payment_method_token => @result.customer.credit_cards[0].token,
33
- :plan_id => @plan.braintree_id
34
- )
35
- current_account.update_column(:plan_id, params[:plan_id])
36
- subscription_id = subscription_result.subscription.id
37
- current_account.update_column(:braintree_subscription_id, subscription_id)
38
- flash[:success] = "You have switched to the '#{plan.name}' plan."
39
- redirect_to root_path
40
- else
41
- flash[:error] = "Invalid credit card details. Please try again."
42
- render "plan"
43
- end
44
- end
45
-
46
- def confirm_plan
47
- @plan = Mtwarden::Plan.find(params[:plan_id])
48
- subscription_id = current_account.braintree_subscription_id
49
- subscription_result = Braintree::Subscription.update(subscription_id,
50
- :plan_id => plan.braintree_id)
51
- if subscription_result.success?
52
- current_account.update_column(:plan_id, plan.id)
53
- flash[:success] = "You have switched to the '#{plan.name}' plan."
54
- redirect_to root_path
55
- else
56
- flash[:error] = "Something went wrong. Please try again."
57
- render "plan"
58
- end
59
- end
60
-
61
- private
62
-
63
- def account_params
64
- params.require(:account).permit(:name, :plan_id)
65
- end
66
- end
67
- end
1
+ require_dependency "mtwarden/application_controller"
2
+
3
+ module Mtwarden
4
+ class Account::AccountsController < ApplicationController
5
+ before_filter :authenticate_user!
6
+ before_filter :authorize_owner, only: [:edit, :update, :plan]
7
+
8
+ def update
9
+ plan_id = account_params.delete(:plan_id)
10
+ if current_account.update_attributes(account_params)
11
+ flash[:success] = "Account updated successfully."
12
+ if plan_id != current_account.plan_id
13
+ redirect_to plan_account_url(:plan_id => plan_id)
14
+ else
15
+ redirect_to root_path
16
+ end
17
+ else
18
+ flash[:error] = "Account could not be updated."
19
+ render :edit
20
+ end
21
+ end
22
+
23
+ def plan
24
+ @plan = Mtwarden::Plan.find(params[:plan_id])
25
+ end
26
+
27
+ def subscribe
28
+ @plan = Mtwarden::Plan.find(params[:plan_id])
29
+ @result = Braintree::TransparentRedirect.confirm(request.query_string)
30
+ if @result.success?
31
+ subscription_result = Braintree::Subscription.create(
32
+ :payment_method_token => @result.customer.credit_cards[0].token,
33
+ :plan_id => @plan.braintree_id
34
+ )
35
+ current_account.update_column(:plan_id, params[:plan_id])
36
+ subscription_id = subscription_result.subscription.id
37
+ current_account.update_column(:braintree_subscription_id, subscription_id)
38
+ flash[:success] = "You have switched to the '#{plan.name}' plan."
39
+ redirect_to root_path
40
+ else
41
+ flash[:error] = "Invalid credit card details. Please try again."
42
+ render "plan"
43
+ end
44
+ end
45
+
46
+ def confirm_plan
47
+ @plan = Mtwarden::Plan.find(params[:plan_id])
48
+ subscription_id = current_account.braintree_subscription_id
49
+ subscription_result = Braintree::Subscription.update(subscription_id,
50
+ :plan_id => plan.braintree_id)
51
+ if subscription_result.success?
52
+ current_account.update_column(:plan_id, plan.id)
53
+ flash[:success] = "You have switched to the '#{plan.name}' plan."
54
+ redirect_to root_path
55
+ else
56
+ flash[:error] = "Something went wrong. Please try again."
57
+ render "plan"
58
+ end
59
+ end
60
+
61
+ private
62
+
63
+ def account_params
64
+ params.require(:account).permit(:name, :plan_id)
65
+ end
66
+ end
67
+ end
@@ -1,7 +1,7 @@
1
- require_dependency "mtwarden/application_controller"
2
-
3
- module Mtwarden
4
- class Account::DashboardController < ApplicationController
5
- before_filter :authenticate_user!
6
- end
7
- end
1
+ require_dependency "mtwarden/application_controller"
2
+
3
+ module Mtwarden
4
+ class Account::DashboardController < ApplicationController
5
+ before_filter :authenticate_user!
6
+ end
7
+ end
@@ -1,20 +1,20 @@
1
- require_dependency "mtwarden/application_controller"
2
-
3
- module Mtwarden
4
- class Account::SessionsController < Mtwarden::ApplicationController
5
- def new
6
- @user = User.new
7
- end
8
-
9
- def create
10
- if env["warden"].authenticate(:scope => :user)
11
- flash[:success] = "You are now signed in."
12
- redirect_to root_path
13
- else
14
- @user = User.new
15
- flash[:error] = "Invalid email or password."
16
- render :action => "new"
17
- end
18
- end
19
- end
20
- end
1
+ require_dependency "mtwarden/application_controller"
2
+
3
+ module Mtwarden
4
+ class Account::SessionsController < Mtwarden::ApplicationController
5
+ def new
6
+ @user = User.new
7
+ end
8
+
9
+ def create
10
+ if env["warden"].authenticate(:scope => :user)
11
+ flash[:success] = "You are now signed in."
12
+ redirect_to root_path
13
+ else
14
+ @user = User.new
15
+ flash[:error] = "Invalid email or password."
16
+ render :action => "new"
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,23 +1,23 @@
1
- require_dependency "mtwarden/application_controller"
2
-
3
- module Mtwarden
4
- class Account::UsersController < ApplicationController
5
- def new
6
- @user = Mtwarden::User.new
7
- end
8
-
9
- def create
10
- account = Mtwarden::Account.find_by(:subdomain => request.subdomain)
11
- user = account.users.create(user_params)
12
- force_authentication!(user)
13
- flash[:success] = "You have signed up successfully."
14
- redirect_to root_path
15
- end
16
-
17
- private
18
-
19
- def user_params
20
- params.require(:user).permit(:email, :password, :password_confirmation)
21
- end
22
- end
23
- end
1
+ require_dependency "mtwarden/application_controller"
2
+
3
+ module Mtwarden
4
+ class Account::UsersController < ApplicationController
5
+ def new
6
+ @user = Mtwarden::User.new
7
+ end
8
+
9
+ def create
10
+ account = Mtwarden::Account.find_by(:subdomain => request.subdomain)
11
+ user = account.users.create(user_params)
12
+ force_authentication!(user)
13
+ flash[:success] = "You have signed up successfully."
14
+ redirect_to root_path
15
+ end
16
+
17
+ private
18
+
19
+ def user_params
20
+ params.require(:user).permit(:email, :password, :password_confirmation)
21
+ end
22
+ end
23
+ end