phcdevworks_accounts 3.1.0 → 3.2.2

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: 8a142c0aaf0e4e1fc0f097bf81a8afcb3a5654f88f80e2b8f74094668428b0a6
4
- data.tar.gz: bdde23435054b4a9574ce5b3fba5efcce15399549f66065d0abe0eff62e311aa
3
+ metadata.gz: de586027378f7a02c9c8007e4963b7279c3c49361cd3e1203f6dcbec6d4fc19a
4
+ data.tar.gz: adc5bbfe8783182cbb1378d8a9678d44618fe4f747d2ab5c2e9acd6bf8253a55
5
5
  SHA512:
6
- metadata.gz: 25c7d235bd5a608bb6fd33705eeed169b49680257d00dbb66cc5183d2f0bd13673e78f7d53bf7a1151602c1780ece55f077bf0c43b3c0d0907c811a328a0fe3f
7
- data.tar.gz: 905636dfd8eff5e83df1e76fea7214c3f8c3d3e285a7d33042bfb9c1ffbd957877618dd71c65aef40062cf9c55d26b17d94c4db3fe69b27b88335348c8465f0b
6
+ metadata.gz: 013c6a26916f4352859b13c6692cf411792ca9a35026be37148167c3090703c2fd4156b5d8d770e29a9a63fdb1b3bc952146998b92f01690fb1586654fdde4c1
7
+ data.tar.gz: 45601f4f7000e5efb402d33f23c94c10e9f0326cab1d1fec2eae506653840fc8fdd5e5fd6489e760b09970ee873caf2291feb717ffe921c5879cd16664f31998
@@ -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,14 +277,49 @@
277
277
  <!-- -PHC- Sidebar - Sidebar Navigation - PHCDevworks Core Modules -->
278
278
  <% end %>
279
279
 
280
- <li class="nav-header">Administration</li>
281
280
  <% if current_user && current_user.admin? %>
281
+ <li class="nav-header">Administration</li>
282
+ <% if defined?phcdevworks_accounts_stripe %>
283
+ <!-- -PHC- Sidebar - Sidebar Navigation - PHCDevworks Accounts Stripe -->
284
+ <li class="has-sub">
285
+ <a href="javascript:;">
286
+ <b class="caret"></b>
287
+ <i class="fab fa-cc-visa"></i>
288
+ <span>Accounting</span>
289
+ </a>
290
+ <ul class="sub-menu">
291
+ <li class="<%= phc_menu_active_controller("phcdevworks_accounts_stripe/admin/subscriptions#admin_subscription_list") %>"><%= link_to("Invoices", phcdevworks_accounts_stripe.admin_invoices_path) %></li>
292
+ <li class="<%= phc_menu_active_controller("phcdevworks_accounts_stripe/admin/subscriptions#admin_subscription_list") %>"><%= link_to("Subscriptions", phcdevworks_accounts_stripe.admin_subscriptions_path) %></li>
293
+ </ul>
294
+ </li>
295
+ <li class="has-sub">
296
+ <a href="javascript:;">
297
+ <b class="caret"></b>
298
+ <i class="fad fa-money-check-alt"></i>
299
+ <span>Services</span>
300
+ </a>
301
+ <ul class="sub-menu">
302
+ <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>
303
+ </ul>
304
+ </li>
305
+ <li class="has-sub">
306
+ <a href="javascript:;">
307
+ <b class="caret"></b>
308
+ <i class="fad fa-users"></i>
309
+ <span>Customers</span>
310
+ </a>
311
+ <ul class="sub-menu">
312
+ <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>
313
+ </ul>
314
+ </li>
315
+ <!-- -PHC- Sidebar - Sidebar Navigation - PHCDevworks Accounts Stripe -->
316
+ <% end %>
282
317
  <!-- -PHC- Sidebar - Sidebar Navigation - PHCAccounts Admin Options -->
283
318
  <li class="has-sub">
284
319
  <a href="javascript:;">
285
320
  <b class="caret"></b>
286
- <i class="fad fa-user"></i>
287
- <span>User Auth</span>
321
+ <i class="fad fa-user-lock"></i>
322
+ <span>User Logins</span>
288
323
  </a>
289
324
  <ul class="sub-menu">
290
325
  <li class="<%= phc_menu_active_controller("phcdevworks_accounts/admin/users") %>"><%= link_to "User List", phcdevworks_accounts.admin_users_all_path %></li>
@@ -294,13 +329,40 @@
294
329
  <% end %>
295
330
 
296
331
  <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>Your Subscription</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>Your 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
+
297
359
  <% if current_user %>
298
360
  <!-- -PHC- Sidebar - Sidebar Navigation - PHCAccounts User Options -->
299
361
  <li class="has-sub">
300
362
  <a href="javascript:;">
301
363
  <b class="caret"></b>
302
364
  <i class="fad fa-user"></i>
303
- <span>Accounts Settings</span>
365
+ <span>Login Settings</span>
304
366
  </a>
305
367
  <ul class="sub-menu">
306
368
  <li class="<%= phc_menu_active_controller("phcdevworks_accounts/user/edit") %>"><%= link_to "Settings", phcdevworks_accounts.edit_user_registration_path %></li>
@@ -46,9 +46,11 @@
46
46
 
47
47
  <tbody>
48
48
  <% @admin_users.each do |user| %>
49
- <td><%= user.username %></td>
50
- <td><%= user.firstname %> <%= user.lastname %></td>
51
- <td><%= user.email %></td>
49
+ <tr>
50
+ <td><%= user.username %></td>
51
+ <td><%= user.firstname %> <%= user.lastname %></td>
52
+ <td><%= user.email %></td>
53
+ </tr>
52
54
  <% end %>
53
55
  </tbody>
54
56
 
@@ -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.1.0"
2
+ VERSION = "3.2.2"
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.1.0
4
+ version: 3.2.2
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-07 00:00:00.000000000 Z
11
+ date: 2021-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -413,6 +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/20210407121952_add_customer_id_to_users.rb
416
417
  - lib/phcdevworks_accounts.rb
417
418
  - lib/phcdevworks_accounts/engine.rb
418
419
  - lib/phcdevworks_accounts/version.rb