wordjelly-auth 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (275) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +35 -0
  5. data/app/assets/images/auth/activity.jpg +0 -0
  6. data/app/assets/images/auth/facebook.svg +1 -0
  7. data/app/assets/images/auth/google_oauth2.svg +1 -0
  8. data/app/assets/images/auth/js_pic3.jpg +0 -0
  9. data/app/assets/images/auth/profile.jpg +0 -0
  10. data/app/assets/javascripts/auth/admin_create_users.js +2 -0
  11. data/app/assets/javascripts/auth/application.js +20 -0
  12. data/app/assets/javascripts/auth/auth_dependencies.js +12 -0
  13. data/app/assets/javascripts/auth/auth_modals_and_navbar.js +218 -0
  14. data/app/assets/javascripts/auth/clients.js +2 -0
  15. data/app/assets/javascripts/auth/search.js +2 -0
  16. data/app/assets/javascripts/auth/shopping/discounts.js +2 -0
  17. data/app/assets/javascripts/auth/users/profiles.js +188 -0
  18. data/app/assets/stylesheets/auth/admin_create_users.css +4 -0
  19. data/app/assets/stylesheets/auth/application.scss +14 -0
  20. data/app/assets/stylesheets/auth/auth_default_css.scss +13 -0
  21. data/app/assets/stylesheets/auth/common-styles.scss +579 -0
  22. data/app/assets/stylesheets/auth/overrides.scss +26 -0
  23. data/app/assets/stylesheets/auth/search.css +4 -0
  24. data/app/assets/stylesheets/auth/shopping/discounts.css +4 -0
  25. data/app/assets/stylesheets/auth/users/profiles.scss +40 -0
  26. data/app/assets/stylesheets/scaffold.css +56 -0
  27. data/app/controllers/auth/admin_create_users_controller.rb +89 -0
  28. data/app/controllers/auth/application_controller.rb +97 -0
  29. data/app/controllers/auth/clients_controller.rb +105 -0
  30. data/app/controllers/auth/concerns/activity_controller_concern.rb +32 -0
  31. data/app/controllers/auth/concerns/devise_concern.rb +193 -0
  32. data/app/controllers/auth/concerns/omni_concern.rb +310 -0
  33. data/app/controllers/auth/concerns/otp_concern.rb +251 -0
  34. data/app/controllers/auth/concerns/shopping/cart_controller_concern.rb +105 -0
  35. data/app/controllers/auth/concerns/shopping/cart_item_controller_concern.rb +150 -0
  36. data/app/controllers/auth/concerns/shopping/discount_controller_concern.rb +97 -0
  37. data/app/controllers/auth/concerns/shopping/pay_u_money_controller_concern.rb +38 -0
  38. data/app/controllers/auth/concerns/shopping/payment_controller_concern.rb +101 -0
  39. data/app/controllers/auth/concerns/shopping/product_controller_concern.rb +68 -0
  40. data/app/controllers/auth/concerns/token_concern.rb +187 -0
  41. data/app/controllers/auth/confirmations_controller.rb +3 -0
  42. data/app/controllers/auth/mailgun_controller.rb +8 -0
  43. data/app/controllers/auth/omniauth_callbacks_controller.rb +6 -0
  44. data/app/controllers/auth/passwords_controller.rb +4 -0
  45. data/app/controllers/auth/profiles_controller.rb +156 -0
  46. data/app/controllers/auth/registrations_controller.rb +99 -0
  47. data/app/controllers/auth/search_controller.rb +61 -0
  48. data/app/controllers/auth/sessions_controller.rb +20 -0
  49. data/app/controllers/auth/shopping/cart_items_controller.rb +14 -0
  50. data/app/controllers/auth/shopping/carts_controller.rb +13 -0
  51. data/app/controllers/auth/shopping/discounts_controller.rb +19 -0
  52. data/app/controllers/auth/shopping/payments_controller.rb +13 -0
  53. data/app/controllers/auth/shopping/products_controller.rb +17 -0
  54. data/app/controllers/auth/shopping/shopping_controller.rb +86 -0
  55. data/app/controllers/auth/unlocks_controller.rb +3 -0
  56. data/app/controllers/auth/webhooks_controller.rb +3 -0
  57. data/app/helpers/auth/admin_create_users_helper.rb +2 -0
  58. data/app/helpers/auth/application_helper.rb +136 -0
  59. data/app/helpers/auth/clients_helper.rb +4 -0
  60. data/app/helpers/auth/resource_helper.rb +10 -0
  61. data/app/helpers/auth/search_helper.rb +2 -0
  62. data/app/helpers/auth/shopping/cart_items/cart_items_helper.rb +29 -0
  63. data/app/helpers/auth/shopping/carts/carts_helper.rb +25 -0
  64. data/app/helpers/auth/shopping/discounts/discounts_helper.rb +39 -0
  65. data/app/helpers/auth/shopping/payments/pay_u_money_helper.rb +56 -0
  66. data/app/helpers/auth/shopping/payments/payments_helper.rb +54 -0
  67. data/app/helpers/auth/shopping/products/products_helper.rb +52 -0
  68. data/app/helpers/auth/shopping/shopping_helper.rb +3 -0
  69. data/app/helpers/auth/users/profiles_helper.rb +12 -0
  70. data/app/jobs/otp_job.rb +92 -0
  71. data/app/mailers/application_mailer.rb +4 -0
  72. data/app/mailers/auth/notifier.rb +9 -0
  73. data/app/models/auth/admin_create_user.rb +3 -0
  74. data/app/models/auth/client.rb +52 -0
  75. data/app/models/auth/concerns/activity_concern.rb +112 -0
  76. data/app/models/auth/concerns/chief_model_concern.rb +73 -0
  77. data/app/models/auth/concerns/es_concern.rb +21 -0
  78. data/app/models/auth/concerns/notification_concern.rb +232 -0
  79. data/app/models/auth/concerns/notification_response_concern.rb +71 -0
  80. data/app/models/auth/concerns/owner_concern.rb +81 -0
  81. data/app/models/auth/concerns/shopping/cart_concern.rb +329 -0
  82. data/app/models/auth/concerns/shopping/cart_item_concern.rb +437 -0
  83. data/app/models/auth/concerns/shopping/discount_concern.rb +482 -0
  84. data/app/models/auth/concerns/shopping/discount_flow.txt +11 -0
  85. data/app/models/auth/concerns/shopping/pay_u_money_concern.rb +184 -0
  86. data/app/models/auth/concerns/shopping/payment_concern.rb +613 -0
  87. data/app/models/auth/concerns/shopping/product_concern.rb +102 -0
  88. data/app/models/auth/concerns/sms_otp_concern.rb +68 -0
  89. data/app/models/auth/concerns/user_concern.rb +788 -0
  90. data/app/models/auth/identity.rb +23 -0
  91. data/app/models/auth/shopping/cart.rb +3 -0
  92. data/app/models/auth/shopping/cart_item.rb +6 -0
  93. data/app/models/auth/shopping/cart_item_payment_result.rb +7 -0
  94. data/app/models/auth/shopping/discount.rb +4 -0
  95. data/app/models/auth/shopping/payment.rb +5 -0
  96. data/app/models/auth/shopping/product.rb +5 -0
  97. data/app/models/auth/user.rb +3 -0
  98. data/app/views/auth/admin_create_users/_admin_actions.html.erb +46 -0
  99. data/app/views/auth/admin_create_users/_form.html.erb +19 -0
  100. data/app/views/auth/admin_create_users/edit.html.erb +6 -0
  101. data/app/views/auth/admin_create_users/index.html.erb +25 -0
  102. data/app/views/auth/admin_create_users/new.html.erb +5 -0
  103. data/app/views/auth/admin_create_users/show.html.erb +8 -0
  104. data/app/views/auth/clients/_form.html.erb +41 -0
  105. data/app/views/auth/clients/edit.html.erb +6 -0
  106. data/app/views/auth/clients/index.html.erb +33 -0
  107. data/app/views/auth/clients/new.html.erb +5 -0
  108. data/app/views/auth/clients/show.html.erb +21 -0
  109. data/app/views/auth/confirmations/_enter_otp.html.erb +27 -0
  110. data/app/views/auth/confirmations/_get_otp_status.html.erb +25 -0
  111. data/app/views/auth/confirmations/_new_otp_input.js.erb +11 -0
  112. data/app/views/auth/confirmations/_resend_otp.js.erb +8 -0
  113. data/app/views/auth/confirmations/_resend_sms_otp.html.erb +18 -0
  114. data/app/views/auth/confirmations/_verify_otp.js.erb +64 -0
  115. data/app/views/auth/confirmations/create.js.erb +8 -0
  116. data/app/views/auth/confirmations/enter_otp.html.erb +7 -0
  117. data/app/views/auth/confirmations/get_otp_status.html.erb +3 -0
  118. data/app/views/auth/confirmations/new.html.erb +1 -0
  119. data/app/views/auth/confirmations/new.js.erb +16 -0
  120. data/app/views/auth/confirmations/otp_status_result.html.erb +20 -0
  121. data/app/views/auth/mailer/confirmation_instructions.html.erb +5 -0
  122. data/app/views/auth/mailer/password_change.html.erb +3 -0
  123. data/app/views/auth/mailer/reset_password_instructions.html.erb +8 -0
  124. data/app/views/auth/mailer/unlock_instructions.html.erb +7 -0
  125. data/app/views/auth/modals/_ajax_error_modal.html.erb +3 -0
  126. data/app/views/auth/modals/_ajax_error_modal_content.html.erb +0 -0
  127. data/app/views/auth/modals/_edit_account_content.html.erb +68 -0
  128. data/app/views/auth/modals/_edit_account_success_content.html.erb +5 -0
  129. data/app/views/auth/modals/_error_notification.html.erb +8 -0
  130. data/app/views/auth/modals/_forgot_password_content.html.erb +18 -0
  131. data/app/views/auth/modals/_forgot_password_success_content.html.erb +8 -0
  132. data/app/views/auth/modals/_login_default_content.html.erb +3 -0
  133. data/app/views/auth/modals/_login_forms.html.erb +13 -0
  134. data/app/views/auth/modals/_login_navigation_options.html.erb +12 -0
  135. data/app/views/auth/modals/_new_otp_input.html.erb +28 -0
  136. data/app/views/auth/modals/_oauth_and_submit.html.erb +21 -0
  137. data/app/views/auth/modals/_recaptcha_tags.html.erb +4 -0
  138. data/app/views/auth/modals/_resend_confirmation_content.html.erb +17 -0
  139. data/app/views/auth/modals/_resend_confirmation_success_content.html.erb +8 -0
  140. data/app/views/auth/modals/_resend_otp.html.erb +23 -0
  141. data/app/views/auth/modals/_resource_errors.js.erb +24 -0
  142. data/app/views/auth/modals/_sign_in_inputs.html.erb +10 -0
  143. data/app/views/auth/modals/_sign_in_needed_modal.html.erb +3 -0
  144. data/app/views/auth/modals/_sign_in_success_content.html.erb +5 -0
  145. data/app/views/auth/modals/_sign_up_inputs.html.erb +9 -0
  146. data/app/views/auth/modals/_sign_up_success_content.html.erb +1 -0
  147. data/app/views/auth/modals/_sign_up_success_inactive_content.html.erb +2 -0
  148. data/app/views/auth/modals/_unlock_content.html.erb +17 -0
  149. data/app/views/auth/modals/_verify_otp.html.erb +1 -0
  150. data/app/views/auth/modals/base_modal/_base.html.erb +25 -0
  151. data/app/views/auth/modals/login.js.erb +120 -0
  152. data/app/views/auth/modals/unlock_success_content.html.erb +8 -0
  153. data/app/views/auth/notifier/_email.html.erb +3 -0
  154. data/app/views/auth/notifier/notification.html.erb +2 -0
  155. data/app/views/auth/notifier/notification.text.erb +1 -0
  156. data/app/views/auth/omniauth_callbacks/failure.html.erb +4 -0
  157. data/app/views/auth/passwords/create.js.erb +12 -0
  158. data/app/views/auth/passwords/edit.html.erb +25 -0
  159. data/app/views/auth/passwords/new.html.erb +16 -0
  160. data/app/views/auth/passwords/new.js.erb +19 -0
  161. data/app/views/auth/profiles/_proxy_resource.html.erb +5 -0
  162. data/app/views/auth/profiles/set_proxy_resource.js.erb +1 -0
  163. data/app/views/auth/profiles/show.html.erb +8 -0
  164. data/app/views/auth/registrations/create.js.erb +40 -0
  165. data/app/views/auth/registrations/edit.html.erb +2 -0
  166. data/app/views/auth/registrations/edit.js.erb +5 -0
  167. data/app/views/auth/registrations/new.html.erb +33 -0
  168. data/app/views/auth/registrations/update.js.erb +47 -0
  169. data/app/views/auth/search/_search_bar.html.erb +11 -0
  170. data/app/views/auth/search/_search_result.html.erb +7 -0
  171. data/app/views/auth/search/_search_results.html.erb +4 -0
  172. data/app/views/auth/search/authenticated_user_search.js.erb +45 -0
  173. data/app/views/auth/search/authenticated_user_search.json +7 -0
  174. data/app/views/auth/sessions/create.js.erb +5 -0
  175. data/app/views/auth/sessions/new.html.erb +4 -0
  176. data/app/views/auth/sessions/new.js.erb +20 -0
  177. data/app/views/auth/shared/_devise_error_messages.html.erb +9 -0
  178. data/app/views/auth/shared/_links.html.erb +25 -0
  179. data/app/views/auth/shared/_object_errors.html.erb +12 -0
  180. data/app/views/auth/shared/_proxy_resource.html.erb +18 -0
  181. data/app/views/auth/shopping/cart_items/_form.html.erb +34 -0
  182. data/app/views/auth/shopping/cart_items/_show_cart_items_collection.html.erb +31 -0
  183. data/app/views/auth/shopping/cart_items/create_multiple.html.erb +6 -0
  184. data/app/views/auth/shopping/cart_items/create_multiple.json.erb +9 -0
  185. data/app/views/auth/shopping/cart_items/edit.html.erb +6 -0
  186. data/app/views/auth/shopping/cart_items/index.html.erb +52 -0
  187. data/app/views/auth/shopping/cart_items/new.html.erb +5 -0
  188. data/app/views/auth/shopping/cart_items/show.html.erb +13 -0
  189. data/app/views/auth/shopping/carts/_form.html.erb +35 -0
  190. data/app/views/auth/shopping/carts/_payment_links.html.erb +27 -0
  191. data/app/views/auth/shopping/carts/_remove_cart_item.html.erb +11 -0
  192. data/app/views/auth/shopping/carts/_show_cart_balance_info.html.erb +35 -0
  193. data/app/views/auth/shopping/carts/edit.html.erb +6 -0
  194. data/app/views/auth/shopping/carts/index.html.erb +43 -0
  195. data/app/views/auth/shopping/carts/new.html.erb +5 -0
  196. data/app/views/auth/shopping/carts/show.html.erb +46 -0
  197. data/app/views/auth/shopping/discounts/_form.html.erb +18 -0
  198. data/app/views/auth/shopping/discounts/_form_for_create_multiple_cart_items.html.erb +17 -0
  199. data/app/views/auth/shopping/discounts/_show_pending_discount_request.html.erb +17 -0
  200. data/app/views/auth/shopping/discounts/destroy.html.erb +2 -0
  201. data/app/views/auth/shopping/discounts/edit.html.erb +29 -0
  202. data/app/views/auth/shopping/discounts/index.html.erb +40 -0
  203. data/app/views/auth/shopping/discounts/new.html.erb +1 -0
  204. data/app/views/auth/shopping/discounts/show.html.erb +18 -0
  205. data/app/views/auth/shopping/discounts/update.html.erb +2 -0
  206. data/app/views/auth/shopping/payments/_approve_payment.html.erb +7 -0
  207. data/app/views/auth/shopping/payments/_cash_card_cheque.html.erb +24 -0
  208. data/app/views/auth/shopping/payments/_create_discount_coupon.html.erb +5 -0
  209. data/app/views/auth/shopping/payments/_form.html.erb +19 -0
  210. data/app/views/auth/shopping/payments/_gateway.html.erb +21 -0
  211. data/app/views/auth/shopping/payments/_proceed_to_gateway_or_verify_payment.html.erb +18 -0
  212. data/app/views/auth/shopping/payments/_refresh_payment.html.erb +7 -0
  213. data/app/views/auth/shopping/payments/_refund.html.erb +10 -0
  214. data/app/views/auth/shopping/payments/_show_payment_receipt.html.erb +12 -0
  215. data/app/views/auth/shopping/payments/edit.html.erb +6 -0
  216. data/app/views/auth/shopping/payments/index.html.erb +43 -0
  217. data/app/views/auth/shopping/payments/new.html.erb +13 -0
  218. data/app/views/auth/shopping/payments/show.html.erb +36 -0
  219. data/app/views/auth/shopping/products/_form.html.erb +27 -0
  220. data/app/views/auth/shopping/products/edit.html.erb +6 -0
  221. data/app/views/auth/shopping/products/index.html.erb +48 -0
  222. data/app/views/auth/shopping/products/index.json.erb +7 -0
  223. data/app/views/auth/shopping/products/new.html.erb +5 -0
  224. data/app/views/auth/shopping/products/show.html.erb +12 -0
  225. data/app/views/auth/shopping/products/show.json.erb +1 -0
  226. data/app/views/auth/unlocks/create.js.erb +12 -0
  227. data/app/views/auth/unlocks/new.html.erb +14 -0
  228. data/app/views/auth/unlocks/new.js.erb +17 -0
  229. data/app/views/auth/users/_search_result.html.erb +8 -0
  230. data/app/views/auth/users/profiles/_user_data.html.erb +4 -0
  231. data/app/views/auth/users/profiles/show.html.erb +54 -0
  232. data/app/views/layouts/auth/_modals.html.erb +2 -0
  233. data/app/views/layouts/auth/application.html.erb +17 -0
  234. data/app/views/layouts/auth/navbar/_navbar.html.erb +49 -0
  235. data/app/views/layouts/auth/navbar/_personalization.html.erb +17 -0
  236. data/app/views/layouts/auth/navbar/_progress_spinner.html.erb +11 -0
  237. data/app/views/layouts/mailer.html.erb +5 -0
  238. data/app/views/layouts/mailer.text.erb +1 -0
  239. data/config/initializers/active_model.rb +36 -0
  240. data/config/initializers/devise.rb +623 -0
  241. data/config/initializers/json.rb +10 -0
  242. data/config/initializers/omniauth.rb +447 -0
  243. data/config/initializers/redis.rb +2 -0
  244. data/config/initializers/redis.yml +14 -0
  245. data/config/locales/devise.en.yml +63 -0
  246. data/config/routes.rb +1 -0
  247. data/lib/assets/javascripts/data.js +126 -0
  248. data/lib/assets/javascripts/jquery.calendario.js +394 -0
  249. data/lib/assets/javascripts/jquery.tagcloud.js +92 -0
  250. data/lib/assets/javascripts/leanModal.js +236 -0
  251. data/lib/assets/javascripts/main.js +668 -0
  252. data/lib/assets/javascripts/modernizr.custom.63321.js +4 -0
  253. data/lib/assets/javascripts/payumoney.js +9 -0
  254. data/lib/assets/javascripts/search.js +36 -0
  255. data/lib/assets/javascripts/spinner.js +77 -0
  256. data/lib/assets/javascripts/trianglify.min.js +2 -0
  257. data/lib/assets/javascripts/you_need_to_sign_in.js.erb +478 -0
  258. data/lib/assets/stylesheets/calendar.css +111 -0
  259. data/lib/assets/stylesheets/calendar_modifications.scss +276 -0
  260. data/lib/auth.rb +32 -0
  261. data/lib/auth/custom_failure.rb +3 -0
  262. data/lib/auth/engine.rb +231 -0
  263. data/lib/auth/job_exception_handler.rb +7 -0
  264. data/lib/auth/mailgun.rb +28 -0
  265. data/lib/auth/notify.rb +8 -0
  266. data/lib/auth/omniauth/path.rb +104 -0
  267. data/lib/auth/partials.rb +12 -0
  268. data/lib/auth/rails/routes.rb +169 -0
  269. data/lib/auth/search/main.rb +97 -0
  270. data/lib/auth/sidekiq_up.rb +16 -0
  271. data/lib/auth/two_factor_otp.rb +202 -0
  272. data/lib/auth/url_shortener.rb +29 -0
  273. data/lib/auth/version.rb +3 -0
  274. data/lib/tasks/auth_tasks.rake +4 -0
  275. metadata +863 -0
@@ -0,0 +1,97 @@
1
+ module Auth::Concerns::Shopping::DiscountControllerConcern
2
+
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+
7
+ end
8
+
9
+ def initialize_vars
10
+
11
+ instantiate_shopping_classes
12
+
13
+
14
+ @auth_shopping_discount_params = permitted_params.fetch(:discount,{})
15
+
16
+ @auth_shopping_discount = params[:id] ? @auth_shopping_discount_class.find(params[:id]) : @auth_shopping_discount_class.new(@auth_shopping_discount_params)
17
+
18
+ end
19
+
20
+ ##########################################################
21
+ ##
22
+ ##
23
+ ## ACTIONS.
24
+ ##
25
+ ##
26
+ ##########################################################
27
+
28
+ ##expects the product id, resource_id is the logged in resource, and quantity
29
+ def create
30
+ ##ensure that the cart item is new
31
+
32
+ check_for_create(@auth_shopping_discount)
33
+ @auth_shopping_discount = add_owner_and_signed_in_resource(@auth_shopping_discount)
34
+
35
+ @auth_shopping_discount.save
36
+
37
+ respond_with @auth_shopping_discount
38
+ end
39
+
40
+ ##only permits the quantity to be changed, transaction id is internally assigned and can never be changed by the external world.
41
+ def update
42
+
43
+ check_for_update(@auth_shopping_discount)
44
+
45
+ @auth_shopping_discount.assign_attributes(@auth_shopping_discount_params)
46
+ @auth_shopping_discount = add_owner_and_signed_in_resource(@auth_shopping_discount)
47
+
48
+
49
+ @auth_shopping_discount.save
50
+ respond_with @auth_shopping_discount
51
+ end
52
+
53
+ def show
54
+ instantiate_shopping_classes
55
+ @auth_shopping_discount = @auth_shopping_discount_class.find(params[:id])
56
+ respond_with @auth_shopping_discount
57
+ end
58
+
59
+ ##should show those cart items which do not have a parent_id.
60
+ ##since these are the pending cart items.
61
+ ##all remaining cart items have already been assigned to carts
62
+ def index
63
+ @auth_shopping_discounts = @auth_shopping_discount_class.where({:resource_id => lookup_resource.id.to_s})
64
+ respond_with @auth_shopping_discounts
65
+ end
66
+
67
+
68
+ ##can be removed.
69
+ ##responds with 204, and empty response body, if all is ok.
70
+ def destroy
71
+ not_found if @auth_shopping_discount.nil?
72
+ @auth_shopping_discount.destroy
73
+ respond_with @auth_shopping_discount
74
+ end
75
+
76
+
77
+
78
+ private
79
+
80
+
81
+ def permitted_params
82
+
83
+ params_list = [:discount_amount,:discount_percentage,:cart_id, :requires_verification]
84
+
85
+ params_list << :count if (current_signed_in_resource && current_signed_in_resource.is_admin?)
86
+
87
+ ## if its an update, we can allow the add_verified_ids and the add_declined_ids.
88
+ if action_name.to_s == "update"
89
+ params_list << [{:add_verified_ids => []}, {:add_declined_ids => []}]
90
+ end
91
+
92
+ params.permit({discount: params_list},:id)
93
+
94
+ end
95
+
96
+
97
+ end
@@ -0,0 +1,38 @@
1
+ module Auth::Concerns::Shopping::PayUMoneyControllerConcern
2
+
3
+ extend ActiveSupport::Concern
4
+
5
+
6
+ included do
7
+
8
+ protect_from_forgery :except => [:update]
9
+
10
+ end
11
+
12
+
13
+ ## This includes the params sent back in the payumoney callback +
14
+ ## PLUS the params that we send to the payumoney endpoint[:amount,:txnid,:surl,:furl,:productinfo,:firstname,:email,:phone]
15
+ ## => of these, [firstname, email, phone, amount and txnid] are also sent back in the payumoney callback.
16
+ ## PLUS the params that are native to the payment concern [:payment_type, :cart_id]
17
+ ## Everywhere txnid, and :id is the same thing.
18
+ def payumoney_params
19
+ [:txnid, :surl, :furl, :productinfo, :firstname, :email, :phone, :gateway_payment_initiated]
20
+ end
21
+
22
+ ##note that the payumoney callback makes a POST requet to whatever url you specifiy.
23
+ ##This does not suit our puprose, since we want it to make a PUT request to the update_url.
24
+ ##for this purpose a route has been added to the dummy apps routes file, that maps a POST request to the update path for the
25
+
26
+ ## permits the original parameters defined in the payment_controller_concern and the additional params that are defined here as "payumoney_params, alongwith id."
27
+ def permitted_params
28
+
29
+ payment_controller_params = []
30
+
31
+ if super["payment"]
32
+ payment_controller_params = super["payment"].keys.map{|c| c = c.to_sym}
33
+ end
34
+ pp = payumoney_params + payment_controller_params
35
+ params.permit({payment: pp},:id)
36
+ end
37
+
38
+ end
@@ -0,0 +1,101 @@
1
+ module Auth::Concerns::Shopping::PaymentControllerConcern
2
+
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ include Auth::Shopping::Payments::PaymentsHelper
7
+ end
8
+
9
+ def initialize_vars
10
+
11
+ instantiate_shopping_classes
12
+ @auth_shopping_payment_params = permitted_params.fetch(:payment,{})
13
+
14
+ @auth_shopping_payment = params[:id] ? @auth_shopping_payment_class.find_self(params[:id],current_signed_in_resource) : @auth_shopping_payment_class.new(@auth_shopping_payment_params)
15
+ end
16
+
17
+ def show
18
+ @auth_shopping_payment = add_signed_in_resource(@auth_shopping_payment)
19
+ @auth_shopping_payment.set_payment_receipt
20
+ respond_with @auth_shopping_payment
21
+ end
22
+
23
+ def index
24
+ ## need to find all the payments
25
+ @auth_shopping_payments = @auth_shopping_payment_class.where(:resource_id => lookup_resource.id.to_s)
26
+ respond_with @auth_shopping_payments
27
+ end
28
+
29
+ def new
30
+ @auth_shopping_payment = add_owner_and_signed_in_resource(@auth_shopping_payment)
31
+ ## so simply render the new action anyways.
32
+ end
33
+
34
+ def edit
35
+
36
+ end
37
+
38
+ def create
39
+
40
+ check_for_create(@auth_shopping_payment)
41
+
42
+ @auth_shopping_payment.payment_params = params
43
+
44
+
45
+
46
+ @auth_shopping_payment = add_owner_and_signed_in_resource(@auth_shopping_payment)
47
+
48
+ resp = @auth_shopping_payment.save
49
+
50
+
51
+
52
+ respond_with @auth_shopping_payment
53
+ end
54
+
55
+ ##in the normal process of making a cash payment
56
+ ##we render a cash form, then we create a payment and then we should in the show screen,to confirm and commit the payment which finally brings it here.
57
+ ##validations in the create call should look into whether there is a picture/cash/cheque whatever requirements are there.
58
+ def update
59
+ #puts "params coming to update are:"
60
+ #puts params.to_s
61
+ check_for_update(@auth_shopping_payment)
62
+
63
+ @auth_shopping_payment.assign_attributes(@auth_shopping_payment_params)
64
+
65
+ @auth_shopping_payment = add_owner_and_signed_in_resource(@auth_shopping_payment)
66
+
67
+ ##note that params and not permitted_params is called, here because the gateway sends back all the params as a naked hash, and that is used directly to verify the authenticity, in the gateway functions.
68
+ #puts "these are the attributes assigned in the update action."
69
+ #puts @auth_shopping_payment.attributes.to_s
70
+ @auth_shopping_payment.payment_params = params
71
+ #puts "assigned params."
72
+ save_response = @auth_shopping_payment.save
73
+
74
+ ## if save successfull then otherwise, respond_with edit.
75
+ respond_with @auth_shopping_payment, location: (save_response == true ? payment_path(@auth_shopping_payment) : edit_payment_path(@auth_shopping_payment))
76
+
77
+ end
78
+
79
+ def destroy
80
+ @auth_shopping_payment = add_signed_in_resource(@auth_shopping_payment)
81
+ if @auth_shopping_payment.signed_in_resource.is_admin?
82
+ @auth_shopping_payment.delete
83
+ end
84
+ respond_with @auth_shopping_payment
85
+ end
86
+
87
+
88
+ def permitted_params
89
+ payment_params = [:payment_type, :amount, :cart_id,:payment_ack_proof, :refund, :payment_status, :is_verify_payment,:discount_id]
90
+
91
+ if !current_signed_in_resource.is_admin?
92
+ payment_params.delete(:payment_status)
93
+ if action_name.to_s == "update"
94
+ payment_params = [:is_verify_payment]
95
+ end
96
+ end
97
+ params.permit({payment: payment_params},:id)
98
+
99
+ end
100
+
101
+ end
@@ -0,0 +1,68 @@
1
+ module Auth::Concerns::Shopping::ProductControllerConcern
2
+
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+
7
+ include Auth::Shopping::Products::ProductsHelper
8
+
9
+ end
10
+
11
+ def initialize_vars
12
+ instantiate_shopping_classes
13
+ @auth_shopping_product_params = permitted_params.fetch(:product,{})
14
+ @auth_shopping_product = params[:id] ? @auth_shopping_product_class.find_self(params[:id],current_signed_in_resource) : @auth_shopping_product_class.new(@auth_shopping_product_params)
15
+ end
16
+
17
+
18
+
19
+ def create
20
+ check_for_create(@auth_shopping_product)
21
+ @auth_shopping_product = add_owner_and_signed_in_resource(@auth_shopping_product,{:owner_is_current_resource => true})
22
+
23
+ @auth_shopping_product.save
24
+ respond_with @auth_shopping_product
25
+
26
+ end
27
+
28
+ def update
29
+ check_for_update(@auth_shopping_product)
30
+ @auth_shopping_product = add_owner_and_signed_in_resource(@auth_shopping_product,{:owner_is_current_resource => true})
31
+ @auth_shopping_product.assign_attributes(@auth_shopping_product_params)
32
+ @auth_shopping_product.save
33
+ respond_with @auth_shopping_product
34
+
35
+ end
36
+
37
+ def index
38
+ instantiate_shopping_classes
39
+ @auth_shopping_products = @auth_shopping_product_class.all
40
+ end
41
+
42
+ def show
43
+ instantiate_shopping_classes
44
+ @auth_shopping_product = @auth_shopping_product_class.find(params[:id])
45
+ ## will render show.json.erb if its a json request.
46
+ end
47
+
48
+ def destroy
49
+ check_for_destroy(@auth_shopping_product)
50
+ @auth_shopping_product.delete
51
+ respond_with @auth_shopping_product
52
+ end
53
+
54
+ def new
55
+
56
+ end
57
+
58
+ def edit
59
+
60
+ end
61
+
62
+ def permitted_params
63
+ params.permit({:product => [:name,:price]})
64
+ end
65
+
66
+ end
67
+
68
+ ## how to handle situation where the resource_id and resource_class is
@@ -0,0 +1,187 @@
1
+ module Auth::Concerns::TokenConcern
2
+
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+
7
+ attr_accessor :authentication_done
8
+
9
+ ## adds simple_token_authentication to whichever controller implements this concern.
10
+ ## the models have alredy been made token_authenticatable in the lib/auth/omniauth.rb file
11
+ ## logic implemented here is that it iterates the auth_resources one at a time, and as long as the previous one is not already signed in , will add the 'acts_as_token_authentication_handler_for' the current resource_type.
12
+ ## merges in the entire hash for the current resource_type, from the configuration preinitializer file.
13
+ ## it then merges in any controller level configuration options
14
+ ## for this purpose, the controller should add a class method called 'token_authentication_conditions', which should return a hash of options. Refer to models/auth/shopping/cart_concern.rb and model/auth/shopping/cart_item_concern.rb to see how this has been implemented. Only options supported by simple_token_authentication can be set in the hash.
15
+
16
+ ### Example how to add it in the controller
17
+
18
+ =begin
19
+ ### in this case, the token authentication will be done on all actions defined below.
20
+ ### so it won't be done on "show"
21
+
22
+ =end
23
+
24
+ ### Example ends
25
+
26
+ ## POINT B:
27
+ ## so as per documentation of simple-token-authentication, if multiple models are to be handled for token auth then all but the last must have a fallback of :none in case of authentication failure.
28
+ ## this is so that it doesnt fail on the first model.
29
+ ## and at least tries all the remaining models.
30
+ ## So if there is only one model : then its fallback is default.
31
+ ## if there is more than one model : all but the last will have a fallback of :none.
32
+ ##
33
+
34
+ TCONDITIONS = {} unless defined? TCONDITIONS
35
+
36
+
37
+ if Auth.configuration.enable_token_auth
38
+
39
+ ## conditions can be defined at the controller level .
40
+ ## include a constant called TCONDITIONS, before the line
41
+ ## include Auth::Concerns::TokenConcern
42
+ ## refer to Auth::RegistrationsController or implementation.
43
+
44
+
45
+
46
+
47
+ ## how many models are defined in the preinitializer
48
+ auth_resources_count = Auth.configuration.auth_resources.size
49
+
50
+
51
+
52
+ ## if we have more than one auth resource model.
53
+ if auth_resources_count > 1
54
+ ## take all of them except the last, and add the fallback as none to them.
55
+ ## also merge the controller level conditions defined above.
56
+
57
+ Auth.configuration.auth_resources.keys.slice(0,auth_resources_count - 1).each do |res|
58
+
59
+ acts_as_token_authentication_handler_for(res.constantize,Auth.configuration.auth_resources[res].merge({:fallback => :none}).merge(self::TCONDITIONS))
60
+
61
+
62
+
63
+ end
64
+ ## for the last one, just dont add the fallback as none, other conditions are the same.
65
+ res = Auth.configuration.auth_resources.keys[-1]
66
+
67
+ acts_as_token_authentication_handler_for(res.constantize,Auth.configuration.auth_resources[res].merge(self::TCONDITIONS || {}))
68
+
69
+
70
+ else
71
+ ## in case there is only one authentication resource, then the conditions are like the last one in case there are multiple(like above.)
72
+ res = Auth.configuration.auth_resources.keys[0]
73
+
74
+ acts_as_token_authentication_handler_for(res.constantize,Auth.configuration.auth_resources[res].merge(self::TCONDITIONS || {}))
75
+
76
+ end
77
+
78
+ end
79
+
80
+ before_filter :set_resource
81
+
82
+ ## made this a helper so that it can be used in views as well.
83
+ helper_method :lookup_resource
84
+
85
+ helper_method :current_signed_in_resource
86
+ end
87
+
88
+ ## iterates all the authentication resources in the config.
89
+ ## tries to see if we have a current_resource for any of them
90
+ ## if yes, sets the resource to the first encoutered such key and breaks the iteration
91
+ ## basically a convenience method to set @resource variable, since when we have more than one model that is being authenticated with Devise, there is no way to know which one to call.
92
+ def set_resource
93
+
94
+
95
+ Auth.configuration.auth_resources.keys.each do |resource|
96
+ break if @resource = self.send("current_#{resource.downcase}")
97
+ end
98
+
99
+ #puts "do we have a resource"
100
+ #puts @resource.to_s
101
+
102
+ ## devise in registrations_controller#destroy assumes the existence of an 'resource' variable, so we set that here.
103
+ if devise_controller?
104
+ self.resource = @resource
105
+ end
106
+
107
+ puts "we have a resource as: #{@resource}"
108
+
109
+ end
110
+
111
+
112
+
113
+ def lookup_resource
114
+ ## if the current signed in resource si not an admin, just return it, because the concept of proxy arises only if the current_signed in resource is an admin.
115
+ return current_signed_in_resource unless current_signed_in_resource.is_admin?
116
+
117
+ ## else.
118
+
119
+ ## first check the session or the params for a proxy resource.
120
+ proxy_resource_id = params[:proxy_resource_id] || session[:proxy_resource_id]
121
+ proxy_resource_class = params[:proxy_resource_class] || session[:proxy_resource_class]
122
+
123
+ ## if these are not provided or set, and if the resource is an admin, then the admin becomes the proxy_resource
124
+ proxy_resource_id = current_signed_in_resource.id.to_s if (current_signed_in_resource.is_admin? && proxy_resource_id.nil?)
125
+
126
+ proxy_resource_class = current_signed_in_resource.class.to_s if (current_signed_in_resource.is_admin? && proxy_resource_class.nil?)
127
+
128
+ ## now return nil if the proxy resource is still nil.
129
+ return nil unless (proxy_resource_class && proxy_resource_id)
130
+ return nil unless (Auth.configuration.auth_resources.include? proxy_resource_class.capitalize)
131
+
132
+ proxy_resource_class = proxy_resource_class.capitalize.constantize
133
+ begin
134
+ proxy_resource = proxy_resource_class.find(proxy_resource_id)
135
+ proxy_resource
136
+ rescue Mongoid::Errors::DocumentNotFound => error
137
+ nil
138
+ end
139
+
140
+ end
141
+
142
+ ## the current signed in resource.
143
+ def current_signed_in_resource
144
+ @resource
145
+ end
146
+
147
+
148
+ ## convenience method to add the current signed in resource to the model instance.
149
+ ## the object instance passed in MUST implement the owner concern
150
+ ## @param[Object] : instance of any object that implements the OwnerConcern.
151
+ ## @return : the object passed in.
152
+ def add_signed_in_resource(obj,options={})
153
+ if obj.respond_to? :signed_in_resource
154
+ obj.signed_in_resource = current_signed_in_resource
155
+ end
156
+ return obj
157
+ end
158
+
159
+ ## only adds the owner resource if its not already present, implying that once the owner resource is set, it should never change.
160
+ def add_owner_resource(obj,options={})
161
+ if (obj.respond_to? :resource_id) && (obj.respond_to? :resource_class)
162
+ if options[:owner_is_current_resource]
163
+ obj.resource_id = current_signed_in_resource.id.to_s if obj.resource_id.nil?
164
+ obj.resource_class = current_signed_in_resource.class.name.to_s if obj.resource_class.nil?
165
+ else
166
+ obj.resource_id = lookup_resource.id.to_s if obj.resource_id.nil?
167
+ obj.resource_class = lookup_resource.class.name.to_s if obj.resource_class.nil?
168
+ end
169
+ end
170
+ return obj
171
+ end
172
+
173
+ ## @param[Object] obj: the object whose owner is to be defined.
174
+ ## @param[Hash] options: possible options include:
175
+ ## :owner_is_current_resource => if this option exists, the resource_id and resource_class is set to the current resource
176
+ def add_owner_and_signed_in_resource(obj,options={})
177
+ obj = add_owner_resource(obj,options)
178
+ obj = add_signed_in_resource(obj,options)
179
+ obj
180
+ end
181
+
182
+ ## this is used as a before_filter.
183
+ def is_admin_user
184
+ not_found("You don't have sufficient privileges to complete that action") if !current_signed_in_resource.is_admin?
185
+ end
186
+
187
+ end