phcdevworks_accounts 3.0.5 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3815bb2d86b61c19ad6475d594eb3938c9c2c6cd87ed3adc0ae5d0f96ac43bc7
4
- data.tar.gz: fbad6257af5dd2d5006356f515c85004bebc7e24c8d2efa12a4bcb7d5a9c8fd6
3
+ metadata.gz: b2093924da8575dc57bdaf811cddc71451d3878ce9792c59d0a6b8a664cda05d
4
+ data.tar.gz: bf612d14ae462d489c7037579097191518cf152acb9963359b64cb62ef7b3a69
5
5
  SHA512:
6
- metadata.gz: 9013ad9d810463c03908b01b80bbdebce7d782685a341645b719c7a02d8536b9c56c6671a5eba88fe2e6d8f793f99550c3e067bb0085b8b8061fbe864ca89877
7
- data.tar.gz: 31c423bf1715b0b11002e531f94bb7bb6bc3613a26626a809682588956d59c649b5135f5048a62842f04a50661f5ad06a8567aae0833c68d70f2c14c1ad63ee5
6
+ metadata.gz: 866a2386fe6b0754a6c1d468136786bb34b17e7e1df03a961c33ed9f4e926babd06eec5c98a6cda3cacba07151e3bf128fb0a20ec64e7acec0ed418781dc7358
7
+ data.tar.gz: 4375a693a0ebb9e4e37c0936b70436d1159907d23ef36de386d32762199125fe62264e61c97da5874e234b8b9abbdfb9c4872eec31e192a0044ff0893e53237b
@@ -16,7 +16,7 @@ module PhcdevworksAccounts
16
16
 
17
17
  # Whitelist Additional Fields
18
18
  def phcdevworks_accounts_permitted_parameters
19
- added_attrs = [:username, :firstname, :lastname, :email, :terms_of_service, :password, :password_confirmation, :remember_me]
19
+ added_attrs = [:username, :firstname, :lastname, :email, :terms_of_service, :payments_customer_id, :payments_subscription_id, :payments_plan_id, :password, :password_confirmation, :remember_me]
20
20
  devise_parameter_sanitizer.permit :sign_up, keys: added_attrs
21
21
  devise_parameter_sanitizer.permit :account_update, keys: added_attrs
22
22
  end
@@ -9,7 +9,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
9
9
  # end
10
10
 
11
11
  # More info at:
12
- # https://github.com/plataformatec/devise#omniauth
12
+ # https://github.com/heartcombo/devise#omniauth
13
13
 
14
14
  # GET|POST /resource/auth/twitter
15
15
  # def passthru
@@ -1,64 +1,74 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Users::RegistrationsController < Devise::RegistrationsController
4
+ # before_action :configure_sign_up_params, only: [:create]
5
+ # before_action :configure_account_update_params, only: [:update]
6
+ after_action :phcdevworks_accounts_payments_add_customer, :only => :create, if: -> {defined?(PhcdevworksAccountsStripe)}
4
7
 
5
- # before_action :configure_sign_up_params, only: [:create]
6
- # before_action :configure_account_update_params, only: [:update]
8
+ # GET /resource/sign_up
9
+ # def new
10
+ # super
11
+ # end
7
12
 
8
- # GET /resource/sign_up
9
- # def new
10
- # super
11
- # end
13
+ # POST /resource
14
+ def create
15
+ super
16
+ end
12
17
 
13
- # POST /resource
14
- # def create
15
- # super
16
- # end
18
+ # GET /resource/edit
19
+ # def edit
20
+ # super
21
+ # end
17
22
 
18
- # GET /resource/edit
19
- # def edit
20
- # super
21
- # end
23
+ # PUT /resource
24
+ # def update
25
+ # super
26
+ # end
22
27
 
23
- # PUT /resource
24
- # def update
25
- # super
26
- # end
28
+ # DELETE /resource
29
+ # def destroy
30
+ # super
31
+ # end
27
32
 
28
- # DELETE /resource
29
- # def destroy
30
- # super
31
- # end
33
+ # GET /resource/cancel
34
+ # Forces the session data which is usually expired after sign
35
+ # in to be expired now. This is useful if the user wants to
36
+ # cancel oauth signing in/up in the middle of the process,
37
+ # removing all OAuth session data.
38
+ # def cancel
39
+ # super
40
+ # end
32
41
 
33
- # GET /resource/cancel
34
- # Forces the session data which is usually expired after sign
35
- # in to be expired now. This is useful if the user wants to
36
- # cancel oauth signing in/up in the middle of the process,
37
- # removing all OAuth session data.
38
- # def cancel
39
- # super
40
- # end
42
+ # protected
41
43
 
42
- # protected
44
+ # If you have extra params to permit, append them to the sanitizer.
45
+ # def configure_sign_up_params
46
+ # devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])
47
+ # end
43
48
 
44
- # If you have extra params to permit, append them to the sanitizer.
45
- # def configure_sign_up_params
46
- # devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])
47
- # end
49
+ # If you have extra params to permit, append them to the sanitizer.
50
+ # def configure_account_update_params
51
+ # devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
52
+ # end
48
53
 
49
- # If you have extra params to permit, append them to the sanitizer.
50
- # def configure_account_update_params
51
- # devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
52
- # end
54
+ # The path used after sign up.
55
+ # def after_sign_up_path_for(resource)
56
+ # super(resource)
57
+ # end
53
58
 
54
- # The path used after sign up.
55
- # def after_sign_up_path_for(resource)
56
- # super(resource)
57
- # end
59
+ # The path used after sign up for inactive accounts.
60
+ # def after_inactive_sign_up_path_for(resource)
61
+ # super(resource)
62
+ # end
58
63
 
59
- # The path used after sign up for inactive accounts.
60
- # def after_inactive_sign_up_path_for(resource)
61
- # super(resource)
62
- # end
64
+ def phcdevworks_accounts_payments_add_customer
65
+ if resource.valid?
66
+ phcdevworks_accounts_customer = Stripe::Customer.create({
67
+ email: current_user.email, name: current_user.firstname + " " + current_user.lastname
68
+ })
69
+ @user.payments_customer_id = phcdevworks_accounts_customer.id
70
+ @user.save
71
+ end
72
+ end
63
73
 
64
74
  end
@@ -14,7 +14,10 @@ module PhcdevworksAccounts
14
14
 
15
15
  # Include default devise modules. Others available are:
16
16
  # :trackable, :confirmable, :lockable and :omniauthable
17
- devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :timeoutable
17
+ devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :timeoutable
18
+
19
+ # Validations
20
+ validates :username, :presence => true, :uniqueness => true
18
21
 
19
22
  private
20
23
 
@@ -277,44 +277,9 @@
277
277
  <!-- -PHC- Sidebar - Sidebar Navigation - PHCDevworks Core Modules -->
278
278
  <% end %>
279
279
 
280
- <li class="nav-header">Administration</li>
281
- <% if defined?phcdevworks_accounts_stripe && current_user && current_user.admin %>
282
- <!-- -PHC- Sidebar - Sidebar Navigation - PHCDevworks Accounts Stripe -->
283
- <li class="has-sub">
284
- <a href="javascript:;">
285
- <b class="caret"></b>
286
- <i class="fab fa-cc-stripe"></i>
287
- <span>Subscriptions</span>
288
- </a>
289
- <ul class="sub-menu">
290
- <li class="<%= phc_menu_active_controller("phcdevworks_accounts_stripe/admin/subscriptions#admin_subscription_list") %>"><%= link_to("Subscription Index", phcdevworks_accounts_stripe.admin_subscriptions_path) %></li>
291
- </ul>
292
- </li>
293
- <li class="has-sub">
294
- <a href="javascript:;">
295
- <b class="caret"></b>
296
- <i class="fad fa-money-check-alt"></i>
297
- <span>Plans</span>
298
- </a>
299
- <ul class="sub-menu">
300
- <li class="<%= phc_menu_active_controller("phcdevworks_accounts_stripe/admin/products#admin_products_list") %>"><%= link_to("Product List", phcdevworks_accounts_stripe.admin_products_path) %></li>
301
- </ul>
302
- </li>
303
- <li class="has-sub">
304
- <a href="javascript:;">
305
- <b class="caret"></b>
306
- <i class="fad fa-users"></i>
307
- <span>Customers</span>
308
- </a>
309
- <ul class="sub-menu">
310
- <li class="<%= phc_menu_active_controller("phcdevworks_accounts_stripe/admin/customers#admin_customer_list") %>"><%= link_to("Customer List", phcdevworks_accounts_stripe.admin_customers_path) %></li>
311
- </ul>
312
- </li>
313
- <!-- -PHC- Sidebar - Sidebar Navigation - PHCDevworks Accounts Stripe -->
314
- <% end %>
315
-
316
280
  <% if current_user && current_user.admin? %>
317
281
  <!-- -PHC- Sidebar - Sidebar Navigation - PHCAccounts Admin Options -->
282
+ <li class="nav-header">Administration</li>
318
283
  <li class="has-sub">
319
284
  <a href="javascript:;">
320
285
  <b class="caret"></b>
@@ -329,33 +294,6 @@
329
294
  <% end %>
330
295
 
331
296
  <li class="nav-header">Your Account</li>
332
- <% if defined?phcdevworks_accounts_stripe && current_user %>
333
- <!-- -PHC- Sidebar - Sidebar Navigation - PHCDevworks Accounts Stripe -->
334
- <li class="has-sub">
335
- <a href="javascript:;">
336
- <b class="caret"></b>
337
- <i class="fad fa-money-check-alt"></i>
338
- <span>Plan Settings</span>
339
- </a>
340
- <ul class="sub-menu">
341
- <li class="<%= phc_menu_active_controller("phcdevworks_accounts_stripe/admin/subscriptions#admin_subscription_list") %>"><%= link_to("Your Subscription", phcdevworks_accounts_stripe.user_subscription_path) %></li>
342
- <li class="<%= phc_menu_active_controller("phcdevworks_accounts_stripe/admin/products#admin_product_list") %>"><%= link_to("Switch Subscriptions", phcdevworks_accounts_stripe.user_subscription_path) %></li>
343
- </ul>
344
- </li>
345
- <li class="has-sub">
346
- <a href="javascript:;">
347
- <b class="caret"></b>
348
- <i class="fad fa-file-invoice"></i>
349
- <span>Invoices</span>
350
- </a>
351
- <ul class="sub-menu">
352
- <li class="<%= phc_menu_active_controller("phcdevworks_accounts_stripe/user/invoices#admin_customer_list") %>"><%= link_to("Current Invoice", phcdevworks_accounts_stripe.user_invoices_path) %></li>
353
- <li class="<%= phc_menu_active_controller("phcdevworks_accounts_stripe/user/invoices#admin_customer_list") %>"><%= link_to("Past Invoices", phcdevworks_accounts_stripe.admin_customers_path) %></li>
354
- </ul>
355
- </li>
356
- <!-- -PHC- Sidebar - Sidebar Navigation - PHCDevworks Accounts Stripe -->
357
- <% end %>
358
-
359
297
  <% if current_user %>
360
298
  <!-- -PHC- Sidebar - Sidebar Navigation - PHCAccounts User Options -->
361
299
  <li class="has-sub">
@@ -67,7 +67,7 @@
67
67
  <label class="control-label">Password Confirmation <span class="text-danger">*</span></label>
68
68
  <div class="row m-b-15">
69
69
  <div class="col-md-12">
70
- <%= form.password_field :password, autocomplete: "off", placeholder: "Confirm your Password", class: "form-control" %>
70
+ <%= form.password_field :password_confirmation, autocomplete: "off", placeholder: "Confirm your Password", class: "form-control" %>
71
71
  </div>
72
72
  </div>
73
73
 
data/config/routes.rb CHANGED
@@ -10,9 +10,10 @@ PhcdevworksAccounts::Engine.routes.draw do
10
10
  match "/admin/user/:id", to: "admin/pages#user_profile", via: "get"
11
11
 
12
12
  # User Routes
13
- devise_for :users, {
14
- class_name: "PhcdevworksAccounts::User",
15
- module: :devise
13
+ devise_for :users, class_name: "PhcdevworksAccounts::User",
14
+ module: :devise,
15
+ controllers: {
16
+ registrations: 'users/registrations'
16
17
  }
17
18
 
18
19
  end
@@ -0,0 +1,7 @@
1
+ class AddCustomerIdToUsers < ActiveRecord::Migration[6.1]
2
+ def change
3
+
4
+ add_column :phcdevworks_accounts_users, :payments_customer_id, :string
5
+
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module PhcdevworksAccounts
2
- VERSION = "3.0.5"
2
+ VERSION = "3.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phcdevworks_accounts
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.5
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - PHCDevworks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-04 00:00:00.000000000 Z
11
+ date: 2021-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -413,7 +413,7 @@ files:
413
413
  - db/migrate/20191012060241_add_userinfo_to_users.rb
414
414
  - db/migrate/20191012060308_add_role_to_users.rb
415
415
  - db/migrate/20191012060324_add_tos_to_users.rb
416
- - db/migrate/20210402042717_add_stripe_id_to_users.rb
416
+ - db/migrate/20210407121952_add_customer_id_to_users.rb
417
417
  - lib/phcdevworks_accounts.rb
418
418
  - lib/phcdevworks_accounts/engine.rb
419
419
  - lib/phcdevworks_accounts/version.rb
@@ -1,7 +0,0 @@
1
- class AddStripeIdToUsers < ActiveRecord::Migration[6.1]
2
- def change
3
-
4
- add_column :phcdevworks_accounts_users, :stripe_customer_id, :string
5
-
6
- end
7
- end