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,623 @@
1
+ # Use this hook to configure devise mailer, warden hooks and so forth.
2
+ # Many of these configuration options can be set straight in your model.
3
+ Devise.setup do |config|
4
+ #parent controller
5
+ config.parent_controller = 'Auth::ApplicationController'
6
+ # The secret key used by Devise. Devise uses this key to generate
7
+ # random tokens. Changing this key will render invalid all existing
8
+ # confirmation, reset password and unlock tokens in the database.
9
+ # Devise will use the `secret_key_base` as its `secret_key`
10
+ # by default. You can change it below and use your own secret key.
11
+ # config.secret_key = 'a66b3c69092bb2bfb7364f6140a0874e128da2893d8730f1f646eca560ef84cc32f6a40605d24f56a044b216b73483201b72c28a82c487109b885f812efff607'
12
+
13
+ # ==> Mailer Configuration
14
+ # Configure the e-mail address which will be shown in Devise::Mailer,
15
+ # note that it will be overwritten if you use your own mailer class
16
+ # with default "from" parameter.
17
+ config.mailer_sender = 'hi_there_i_come_from_the_engine@gmail.com'
18
+
19
+ # Configure the class responsible to send e-mails.
20
+ # config.mailer = 'Devise::Mailer'
21
+
22
+ # Configure the parent class responsible to send e-mails.
23
+ # config.parent_mailer = 'ActionMailer::Base'
24
+
25
+ # ==> ORM configuration
26
+ # Load and configure the ORM. Supports :active_record (default) and
27
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
28
+ # available as additional gems.
29
+ require 'devise/orm/mongoid'
30
+
31
+ # ==> Configuration for any authentication mechanism
32
+ # Configure which keys are used when authenticating a user. The default is
33
+ # just :email. You can configure it to use [:username, :subdomain], so for
34
+ # authenticating a user, both parameters are required. Remember that those
35
+ # parameters are used only when authenticating and not when retrieving from
36
+ # session. If you need permissions, you should implement that in a before filter.
37
+ # You can also supply a hash where the value is a boolean determining whether
38
+ # or not authentication should be aborted when the value is not present.
39
+ #config.authentication_keys = [:email]
40
+
41
+ # Configure parameters from the request object used for authentication. Each entry
42
+ # given should be a request method and it will automatically be passed to the
43
+ # find_for_authentication method and considered in your model lookup. For instance,
44
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
45
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
46
+ # config.request_keys = []
47
+
48
+ # Configure which authentication keys should be case-insensitive.
49
+ # These keys will be downcased upon creating or modifying a user and when used
50
+ # to authenticate or find a user. Default is :email.
51
+ config.case_insensitive_keys = [:email]
52
+
53
+ # Configure which authentication keys should have whitespace stripped.
54
+ # These keys will have whitespace before and after removed upon creating or
55
+ # modifying a user and when used to authenticate or find a user. Default is :email.
56
+ config.strip_whitespace_keys = [:email]
57
+
58
+ # Tell if authentication through request.params is enabled. True by default.
59
+ # It can be set to an array that will enable params authentication only for the
60
+ # given strategies, for example, `config.params_authenticatable = [:database]` will
61
+ # enable it only for database (email + password) authentication.
62
+ # config.params_authenticatable = true
63
+
64
+ # Tell if authentication through HTTP Auth is enabled. False by default.
65
+ # It can be set to an array that will enable http authentication only for the
66
+ # given strategies, for example, `config.http_authenticatable = [:database]` will
67
+ # enable it only for database authentication. The supported strategies are:
68
+ # :database = Support basic authentication with authentication key + password
69
+ # config.http_authenticatable = false
70
+
71
+ # If 401 status code should be returned for AJAX requests. True by default.
72
+ # config.http_authenticatable_on_xhr = true
73
+
74
+ # The realm used in Http Basic Authentication. 'Application' by default.
75
+ # config.http_authentication_realm = 'Application'
76
+
77
+ # It will change confirmation, password recovery and other workflows
78
+ # to behave the same regardless if the e-mail provided was right or wrong.
79
+ # Does not affect registerable.
80
+ # config.paranoid = true
81
+
82
+ # By default Devise will store the user in session. You can skip storage for
83
+ # particular strategies by setting this option.
84
+ # Notice that if you are skipping storage for all authentication paths, you
85
+ # may want to disable generating routes to Devise's sessions controller by
86
+ # passing skip: :sessions to `devise_for` in your config/routes.rb
87
+ config.skip_session_storage = [:http_auth]
88
+
89
+ # By default, Devise cleans up the CSRF token on authentication to
90
+ # avoid CSRF token fixation attacks. This means that, when using AJAX
91
+ # requests for sign in and sign up, you need to get a new CSRF token
92
+ # from the server. You can disable this option at your own risk.
93
+ # config.clean_up_csrf_token_on_authentication = true
94
+
95
+ # ==> Configuration for :database_authenticatable
96
+ # For bcrypt, this is the cost for hashing the password and defaults to 11. If
97
+ # using other algorithms, it sets how many times you want the password to be hashed.
98
+ #
99
+ # Limiting the stretches to just one in testing will increase the performance of
100
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
101
+ # a value less than 10 in other environments. Note that, for bcrypt (the default
102
+ # algorithm), the cost increases exponentially with the number of stretches (e.g.
103
+ # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
104
+ config.stretches = Rails.env.test? ? 1 : 11
105
+
106
+ # Set up a pepper to generate the hashed password.
107
+ # config.pepper = '237ce91cd770ea7189d69556aba568168d963ada7b3782b56a581711c7675453168cb3ad0302955f86d9d2552e1ef4e964ba95a0bfa4d29cfe1e55094294b7a8'
108
+
109
+ # Send a notification email when the user's password is changed
110
+ # config.send_password_change_notification = false
111
+
112
+ # ==> Configuration for :confirmable
113
+ # A period that the user is allowed to access the website even without
114
+ # confirming their account. For instance, if set to 2.days, the user will be
115
+ # able to access the website for two days without confirming their account,
116
+ # access will be blocked just in the third day. Default is 0.days, meaning
117
+ # the user cannot access the website without confirming their account.
118
+ # config.allow_unconfirmed_access_for = 2.days
119
+
120
+ # A period that the user is allowed to confirm their account before their
121
+ # token becomes invalid. For example, if set to 3.days, the user can confirm
122
+ # their account within 3 days after the mail was sent, but on the fourth day
123
+ # their account can't be confirmed with the token any more.
124
+ # Default is nil, meaning there is no restriction on how long a user can take
125
+ # before confirming their account.
126
+ # config.confirm_within = 3.days
127
+
128
+ # If true, requires any email changes to be confirmed (exactly the same way as
129
+ # initial account confirmation) to be applied. Requires additional unconfirmed_email
130
+ # db field (see migrations). Until confirmed, new email is stored in
131
+ # unconfirmed_email column, and copied to email column on successful confirmation.
132
+ config.reconfirmable = true
133
+
134
+ # Defines which key will be used when confirming an account
135
+ # config.confirmation_keys = [:email]
136
+
137
+ # ==> Configuration for :rememberable
138
+ # The time the user will be remembered without asking for credentials again.
139
+ # config.remember_for = 2.weeks
140
+
141
+ # Invalidates all the remember me tokens when the user signs out.
142
+ config.expire_all_remember_me_on_sign_out = true
143
+
144
+ # If true, extends the user's remember period when remembered via cookie.
145
+ # config.extend_remember_period = false
146
+
147
+ # Options to be passed to the created cookie. For instance, you can set
148
+ # secure: true in order to force SSL only cookies.
149
+ # config.rememberable_options = {}
150
+
151
+ # ==> Configuration for :validatable
152
+ # Range for password length.
153
+ config.password_length = 6..128
154
+
155
+ # Email regex used to validate email formats. It simply asserts that
156
+ # one (and only one) @ exists in the given string. This is mainly
157
+ # to give user feedback and not to assert the e-mail validity.
158
+ config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
159
+
160
+ # ==> Configuration for :timeoutable
161
+ # The time you want to timeout the user session without activity. After this
162
+ # time the user will be asked for credentials again. Default is 30 minutes.
163
+ # config.timeout_in = 30.minutes
164
+
165
+ # ==> Configuration for :lockable
166
+ # Defines which strategy will be used to lock an account.
167
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
168
+ # :none = No lock strategy. You should handle locking by yourself.
169
+ config.lock_strategy = :failed_attempts
170
+
171
+ # Defines which key will be used when locking and unlocking an account
172
+ config.unlock_keys = [:email]
173
+
174
+ # Defines which strategy will be used to unlock an account.
175
+ # :email = Sends an unlock link to the user email
176
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
177
+ # :both = Enables both strategies
178
+ # :none = No unlock strategy. You should handle unlocking by yourself.
179
+ config.unlock_strategy = :both
180
+
181
+ # Number of authentication tries before locking an account if lock_strategy
182
+ # is failed attempts.
183
+ config.maximum_attempts = 20
184
+
185
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
186
+ config.unlock_in = 1.hour
187
+
188
+ # Warn on the last attempt before the account is locked.
189
+ # config.last_attempt_warning = true
190
+
191
+ # ==> Configuration for :recoverable
192
+ #
193
+ # Defines which key will be used when recovering the password for an account
194
+ config.reset_password_keys = [:email]
195
+
196
+ # Time interval you can reset your password with a reset password key.
197
+ # Don't put a too small interval or your users won't have the time to
198
+ # change their passwords.
199
+ config.reset_password_within = 6.hours
200
+
201
+ # When set to false, does not sign a user in automatically after their password is
202
+ # reset. Defaults to true, so a user is signed in automatically after a reset.
203
+ # config.sign_in_after_reset_password = true
204
+
205
+ # ==> Configuration for :encryptable
206
+ # Allow you to use another hashing or encryption algorithm besides bcrypt (default).
207
+ # You can use :sha1, :sha512 or algorithms from others authentication tools as
208
+ # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
209
+ # for default behavior) and :restful_authentication_sha1 (then you should set
210
+ # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
211
+ #
212
+ # Require the `devise-encryptable` gem when using anything other than bcrypt
213
+ # config.encryptor = :sha512
214
+
215
+ # ==> Scopes configuration
216
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
217
+ # "users/sessions/new". It's turned off by default because it's slower if you
218
+ # are using only default views.
219
+ # config.scoped_views = false
220
+
221
+ # Configure the default scope given to Warden. By default it's the first
222
+ # devise role declared in your routes (usually :user).
223
+ # config.default_scope = :user
224
+
225
+ # Set this configuration to false if you want /users/sign_out to sign out
226
+ # only the current scope. By default, Devise signs out all scopes.
227
+ # config.sign_out_all_scopes = true
228
+
229
+ # ==> Navigation configuration
230
+ # Lists the formats that should be treated as navigational. Formats like
231
+ # :html, should redirect to the sign in page when the user does not have
232
+ # access, but formats like :xml or :json, should return 401.
233
+ #
234
+ # If you have any extra navigational formats, like :iphone or :mobile, you
235
+ # should add them to the navigational formats lists.
236
+ #
237
+ # The "*/*" below is required to match Internet Explorer requests.
238
+ config.navigational_formats = ['*/*', :html, :json, :js]
239
+
240
+ # The default HTTP method used to sign out a resource. Default is :delete.
241
+ config.sign_out_via = :delete
242
+
243
+ # ==> OmniAuth
244
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
245
+ # up on your models and hooks.
246
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
247
+ #config.omniauth :facebook, FACEBOOK_CREDENTIALS[0], FACEBOOK_CREDENTIALS[1],{
248
+ # :scope => 'email',
249
+ # :info_fields => 'first_name,last_name,email,work',
250
+ # :display => 'page'
251
+ #}
252
+
253
+ # ==> Warden configuration
254
+ # If you want to use other strategies, that are not supported by Devise, or
255
+ # change the failure app, you can configure them inside the config.warden block.
256
+ #
257
+ #config.warden do |manager|
258
+ #manager.intercept_401 = false
259
+ #manager.default_strategies(scope: :user).unshift :some_external_strategy
260
+ #manager.failure_app = CustomFailure
261
+ #end
262
+
263
+ # ==> Mountable engine configurations
264
+ # When using Devise inside an engine, let's call it `MyEngine`, and this engine
265
+ # is mountable, there are some extra configurations to be taken into account.
266
+ # The following options are available, assuming the engine is mounted as:
267
+ #
268
+ # mount MyEngine, at: '/my_engine'
269
+ #
270
+ # The router that invoked `devise_for`, in the example above, would be:
271
+ #config.router_name = :auth
272
+ #
273
+ # When using OmniAuth, Devise cannot automatically set OmniAuth path,
274
+ # so you need to do it manually. For the users scope, it would be:
275
+ #config.omniauth_path_prefix = '/other'
276
+ end
277
+
278
+
279
+
280
+ DeviseController.class_eval do
281
+
282
+
283
+
284
+ include Auth::Concerns::DeviseConcern
285
+
286
+ ##add to devise concern.
287
+ skip_before_action :assert_is_devise_resource!, if: :is_omniauth_callback?
288
+
289
+
290
+
291
+ def redirect_to(options = {}, response_status = {})
292
+
293
+ cli = session[:client]
294
+ if (session[:client] && (session[:client].is_a? Hash))
295
+ cli = Auth::Client.new(session[:client])
296
+ end
297
+ ##this handles the condition for example where the user comes to the sign in page with a valid redirect url and api key, then goes to the oauth page, then he clicks sign in by oauth, and comes back from oauth provider after a valid sign in, what happens as a result is that the request variable @redirect_url which was set when the user came to the sign_in_page(or any page controlled by the devise controller), is knocked off, because of the visit to the other domain. But the session variable is still intact, so we set the request variable again to the session variable and everything in front of that is just like what we normally do with render
298
+
299
+ ##THIS SHOULD NO LONGER HAPPEN, I DONT WANT ANYONE TO BE AABLE TO VISIT THE WORDJELLY PAGE WITH A REDIRECT URL AND
300
+ #if !session[:redirect_url].nil? && @redirect_url.nil?
301
+ # @redirect_url = session[:redirect_url]
302
+ # @client = Auth::Client.new(session[:client])
303
+ #end
304
+ #super
305
+ #puts "redirect url was : #{@redirect_url}"
306
+ #puts "client was: #{@client}"
307
+
308
+ #if options =~ /authentication_token|es/
309
+ ##this situation is to prevnet re-redirects.
310
+ # puts "detected auth token and es."
311
+ #redirect_to(options,response_status)
312
+ # super
313
+ #end
314
+
315
+ ##HAVE NO IDEA WHAT THIS IS , AT THE MOMENT.
316
+ if options =~ /authentication_token|es/
317
+ ##this situation is to prevnet re-redirects.
318
+
319
+ #redirect_to(options,response_status)
320
+ super(options,response_status)
321
+ else
322
+ ##as long as its not destroy.
323
+ #if resource && resource.set_client_authentication?(action_name,controller_name,cli)
324
+ # resource.set_client_authentication(cli)
325
+ #end
326
+ if (["passwords","confirmations","unlocks"].include? controller_name)
327
+ super(options,response_status)
328
+ else
329
+
330
+ ##we have a redirect url
331
+ ##we have a client authentication for the client.
332
+ ##we have an authentication token
333
+ ##we are signed_in
334
+ ##we have at least one authentication_key confirmed.
335
+
336
+ if resource && resource.reply_with_redirect_url_and_auth_token_and_es?(session[:redirect_url],cli,current_resource(resource))
337
+
338
+ curr_app_es = resource.client_authentication[cli.current_app_id]
339
+ session.delete(:client)
340
+
341
+
342
+ redirect_to session.delete(:redirect_url) + "?authentication_token=" + resource.authentication_token + "&es=" + curr_app_es
343
+ else
344
+ super
345
+ end
346
+ end
347
+ end
348
+ end
349
+
350
+ def render(*args)
351
+
352
+ cli = session[:client]
353
+ if (session[:client] && (session[:client].is_a? Hash))
354
+ cli = Auth::Client.new(session[:client])
355
+ end
356
+
357
+
358
+ #if resource && resource.set_client_authentication?(action_name,controller_name,cli)
359
+ # resource.set_client_authentication(cli)
360
+ #end
361
+
362
+ if (["passwords","confirmations","unlocks"].include? controller_name)
363
+ super(*args)
364
+ else
365
+
366
+ if resource && resource.reply_with_redirect_url_and_auth_token_and_es?(session[:redirect_url],cli,current_resource(resource))
367
+
368
+ curr_app_es = resource.client_authentication[cli.current_app_id]
369
+ session.delete(:client)
370
+
371
+
372
+ redirect_to (session.delete(:redirect_url) + "?authentication_token=" + resource.authentication_token + "&es=" + curr_app_es)
373
+ else
374
+
375
+ super(*args)
376
+ end
377
+ end
378
+ end
379
+
380
+
381
+
382
+ ##add to devise_concern.
383
+ def require_no_authentication
384
+
385
+ do_before_request
386
+ #puts "came past do before request."
387
+
388
+ assert_is_devise_resource!
389
+ #puts "came past assert is devise resource"
390
+
391
+
392
+ return unless is_navigational_format?
393
+
394
+ #puts "came past is navigational format."
395
+
396
+ no_input = devise_mapping.no_input_strategies
397
+ #puts "no input is: #{no_input}"
398
+
399
+
400
+ authenticated = if no_input.present?
401
+ args = no_input.dup.push scope: resource_name
402
+ #puts "authenticated already."
403
+ warden.authenticate?(*args)
404
+ else
405
+ #puts "check if authenticated"
406
+ warden.authenticated?(resource_name)
407
+ end
408
+
409
+
410
+ if authenticated && resource = warden.user(resource_name)
411
+ if @redirect_url.nil?
412
+ #puts "came to failure."
413
+ flash[:alert] = I18n.t("devise.failure.already_authenticated")
414
+ redirect_to after_sign_in_path_for(resource)
415
+ else
416
+
417
+ end
418
+ end
419
+ end
420
+
421
+ end
422
+
423
+ module Devise
424
+
425
+ ##THIS CHANGE NEEDS TO BE MADE, IN ORDER TO CHANGE THE EMAIL_REQUIRED?
426
+ ##PROTECTED METHOD FROM THE VALIDATABLE MODULE IN DEVISE.
427
+ ##EMAIL IS REQUIRED ONLY IF THE ADDITIONAL LOGIN PARAM IS enabled , but still nil
428
+ module Controllers
429
+ module Helpers
430
+ ##takes care of the test case where no devise mapping is specified in the request.env.
431
+ ##as a result any method that is fired using this as a filter will not fire.
432
+ ##in this case in dummy/ApplicationController.rb, we were configuring_permitted_params if it was a devise_controller.
433
+ ##now this method is modified to first check if there is a devise_mapping, otherwise returns false.
434
+ ## ref test: omniauth_callbacks_request_spec.rb #NO RESOURCE TEST
435
+ def devise_controller?
436
+ if request.env["devise.mapping"].nil?
437
+ false
438
+ else
439
+ is_a?(::DeviseController)
440
+ end
441
+ end
442
+ end
443
+ end
444
+
445
+
446
+
447
+
448
+ SessionsController.class_eval do
449
+
450
+ prepend_before_action :ignore_json_request, only: [:new]
451
+
452
+ private
453
+ ##if the destory request is json, we return not servicable.
454
+ ##otherwise we do nothing.
455
+ def verify_signed_out_user
456
+ if is_json_request?
457
+ render :nothing => true, :status => 406 and return
458
+ end
459
+ if all_signed_out?
460
+ set_flash_message! :notice, :already_signed_out
461
+ respond_to_on_destroy
462
+ end
463
+ end
464
+
465
+ end
466
+
467
+ PasswordsController.class_eval do
468
+
469
+ prepend_before_action :ignore_json_request, only: [:new]
470
+ prepend_before_action :do_before_request, only: [:show,:create]
471
+
472
+
473
+ end
474
+
475
+
476
+ ##the solution to this problem is to change the html unlocks and confirmations "new" views
477
+ ##here if it comes to this point, then
478
+ UnlocksController.class_eval do
479
+
480
+ prepend_before_action :ignore_json_request, only: [:new]
481
+ prepend_before_action :do_before_request, only: [:show,:create]
482
+
483
+
484
+ def show
485
+
486
+ self.resource = resource_class.unlock_access_by_token(params[:unlock_token])
487
+
488
+ yield resource if block_given?
489
+
490
+ if resource.errors.empty?
491
+ if is_json_request?
492
+ render :nothing => true, :status => 201 and return
493
+ end
494
+ set_flash_message! :notice, :unlocked
495
+ respond_with_navigational(resource){ redirect_to after_unlock_path_for(resource) }
496
+ else
497
+ respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }
498
+ end
499
+ end
500
+
501
+ end
502
+
503
+
504
+
505
+ ConfirmationsController.class_eval do
506
+
507
+ prepend_before_action :ignore_json_request, only: [:new]
508
+ prepend_before_action :do_before_request, only: [:show,:create]
509
+
510
+
511
+ def show
512
+ self.resource = resource_class.confirm_by_token(params[:confirmation_token])
513
+
514
+ yield resource if block_given?
515
+
516
+ if resource.errors.empty?
517
+ set_flash_message!(:notice, :confirmed)
518
+ if is_json_request?
519
+ render :nothing => true, :status => 201 and return
520
+ else
521
+ ##when we have first signed into the accoutn, and then we want to change the email, then when we click the confirmation link for the new email, in that case, we cannot set the resource to nil, since the user is already signed in, so we do this check to see if who we have signed in , is the same as the user who has confirmed, and in that case, we just let things proceed.
522
+ current_resource = self.send("current_#{self.resource.class.name.downcase.to_s}")
523
+
524
+ if current_resource && (current_resource.id.to_s == self.resource.id.to_s)
525
+
526
+ else
527
+ ## do this to force sign in after successfull confirmation
528
+
529
+ self.resource = nil
530
+ end
531
+ respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
532
+ end
533
+ else
534
+ respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }
535
+ end
536
+ end
537
+
538
+
539
+ end
540
+
541
+
542
+ module Models
543
+
544
+ module Recoverable
545
+
546
+ ## change password instructions should not be sent if the user has oauth identities.
547
+ def send_reset_password_instructions
548
+ return if has_oauth_identity?
549
+ token = set_reset_password_token
550
+ send_reset_password_instructions_notification(token)
551
+ token
552
+ end
553
+
554
+ end
555
+
556
+ end
557
+
558
+
559
+ module OmniAuth
560
+ module UrlHelpers
561
+ def omniauth_authorize_path(resource_or_scope, provider, *args)
562
+ "#{request.base_url}#{Auth::OmniAuth::Path.omniauth_request_path(resource_or_scope,provider)}"
563
+ end
564
+
565
+ def omniauth_failure_path_for(resource_or_scope)
566
+ "#{request.base_url}#{Auth::OmniAuth::Path.omniauth_failure_route_path(resource_or_scope)}"
567
+ end
568
+ end
569
+ end
570
+
571
+
572
+
573
+
574
+ Devise.include_helpers(Devise::OmniAuth)
575
+
576
+
577
+ ##checks if the request is json, otherwise lets it fall back to whatever is defined by the custom_failure defined in the target app.
578
+ ##if it is a json request, then renders a 401.
579
+ class FailureApp
580
+
581
+ def self.call(env)
582
+ @json_respond ||= action(:json_respond)
583
+ jf = @json_respond.call(env)
584
+ if jf[0] == 401
585
+ jf
586
+ else
587
+ @respond ||= action(:respond)
588
+ @respond.call(env)
589
+ end
590
+ end
591
+
592
+ def json_respond
593
+
594
+ if request.format == :json or request.content_type == 'application/json'
595
+ return json_failure
596
+ end
597
+
598
+ end
599
+
600
+ def json_failure
601
+
602
+ self.status = 401
603
+ self.content_type = 'application/json'
604
+ self.response_body = {"success"=> false, "errors" => ["u shall not pass LOL"]}.to_json
605
+ end
606
+
607
+
608
+
609
+ end
610
+
611
+ ##the additional_login_param is added as a authentication_key
612
+ class ParameterSanitizer
613
+ DEFAULT_PERMITTED_ATTRIBUTES =
614
+ {
615
+ sign_in: [:login,:password, :remember_me, :redirect_url, :api_key, :current_app_id],
616
+ sign_up: [:password, :password_confirmation, :redirect_url, :api_key, :current_app_id],
617
+ account_update: [:password, :password_confirmation, :current_password, :redirect_url, :api_key, :current_app_id]
618
+ }
619
+
620
+ end
621
+
622
+ end
623
+