wordjelly-auth 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +35 -0
- data/app/assets/images/auth/activity.jpg +0 -0
- data/app/assets/images/auth/facebook.svg +1 -0
- data/app/assets/images/auth/google_oauth2.svg +1 -0
- data/app/assets/images/auth/js_pic3.jpg +0 -0
- data/app/assets/images/auth/profile.jpg +0 -0
- data/app/assets/javascripts/auth/admin_create_users.js +2 -0
- data/app/assets/javascripts/auth/application.js +20 -0
- data/app/assets/javascripts/auth/auth_dependencies.js +12 -0
- data/app/assets/javascripts/auth/auth_modals_and_navbar.js +218 -0
- data/app/assets/javascripts/auth/clients.js +2 -0
- data/app/assets/javascripts/auth/search.js +2 -0
- data/app/assets/javascripts/auth/shopping/discounts.js +2 -0
- data/app/assets/javascripts/auth/users/profiles.js +188 -0
- data/app/assets/stylesheets/auth/admin_create_users.css +4 -0
- data/app/assets/stylesheets/auth/application.scss +14 -0
- data/app/assets/stylesheets/auth/auth_default_css.scss +13 -0
- data/app/assets/stylesheets/auth/common-styles.scss +579 -0
- data/app/assets/stylesheets/auth/overrides.scss +26 -0
- data/app/assets/stylesheets/auth/search.css +4 -0
- data/app/assets/stylesheets/auth/shopping/discounts.css +4 -0
- data/app/assets/stylesheets/auth/users/profiles.scss +40 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/auth/admin_create_users_controller.rb +89 -0
- data/app/controllers/auth/application_controller.rb +97 -0
- data/app/controllers/auth/clients_controller.rb +105 -0
- data/app/controllers/auth/concerns/activity_controller_concern.rb +32 -0
- data/app/controllers/auth/concerns/devise_concern.rb +193 -0
- data/app/controllers/auth/concerns/omni_concern.rb +310 -0
- data/app/controllers/auth/concerns/otp_concern.rb +251 -0
- data/app/controllers/auth/concerns/shopping/cart_controller_concern.rb +105 -0
- data/app/controllers/auth/concerns/shopping/cart_item_controller_concern.rb +150 -0
- data/app/controllers/auth/concerns/shopping/discount_controller_concern.rb +97 -0
- data/app/controllers/auth/concerns/shopping/pay_u_money_controller_concern.rb +38 -0
- data/app/controllers/auth/concerns/shopping/payment_controller_concern.rb +101 -0
- data/app/controllers/auth/concerns/shopping/product_controller_concern.rb +68 -0
- data/app/controllers/auth/concerns/token_concern.rb +187 -0
- data/app/controllers/auth/confirmations_controller.rb +3 -0
- data/app/controllers/auth/mailgun_controller.rb +8 -0
- data/app/controllers/auth/omniauth_callbacks_controller.rb +6 -0
- data/app/controllers/auth/passwords_controller.rb +4 -0
- data/app/controllers/auth/profiles_controller.rb +156 -0
- data/app/controllers/auth/registrations_controller.rb +99 -0
- data/app/controllers/auth/search_controller.rb +61 -0
- data/app/controllers/auth/sessions_controller.rb +20 -0
- data/app/controllers/auth/shopping/cart_items_controller.rb +14 -0
- data/app/controllers/auth/shopping/carts_controller.rb +13 -0
- data/app/controllers/auth/shopping/discounts_controller.rb +19 -0
- data/app/controllers/auth/shopping/payments_controller.rb +13 -0
- data/app/controllers/auth/shopping/products_controller.rb +17 -0
- data/app/controllers/auth/shopping/shopping_controller.rb +86 -0
- data/app/controllers/auth/unlocks_controller.rb +3 -0
- data/app/controllers/auth/webhooks_controller.rb +3 -0
- data/app/helpers/auth/admin_create_users_helper.rb +2 -0
- data/app/helpers/auth/application_helper.rb +136 -0
- data/app/helpers/auth/clients_helper.rb +4 -0
- data/app/helpers/auth/resource_helper.rb +10 -0
- data/app/helpers/auth/search_helper.rb +2 -0
- data/app/helpers/auth/shopping/cart_items/cart_items_helper.rb +29 -0
- data/app/helpers/auth/shopping/carts/carts_helper.rb +25 -0
- data/app/helpers/auth/shopping/discounts/discounts_helper.rb +39 -0
- data/app/helpers/auth/shopping/payments/pay_u_money_helper.rb +56 -0
- data/app/helpers/auth/shopping/payments/payments_helper.rb +54 -0
- data/app/helpers/auth/shopping/products/products_helper.rb +52 -0
- data/app/helpers/auth/shopping/shopping_helper.rb +3 -0
- data/app/helpers/auth/users/profiles_helper.rb +12 -0
- data/app/jobs/otp_job.rb +92 -0
- data/app/mailers/application_mailer.rb +4 -0
- data/app/mailers/auth/notifier.rb +9 -0
- data/app/models/auth/admin_create_user.rb +3 -0
- data/app/models/auth/client.rb +52 -0
- data/app/models/auth/concerns/activity_concern.rb +112 -0
- data/app/models/auth/concerns/chief_model_concern.rb +73 -0
- data/app/models/auth/concerns/es_concern.rb +21 -0
- data/app/models/auth/concerns/notification_concern.rb +232 -0
- data/app/models/auth/concerns/notification_response_concern.rb +71 -0
- data/app/models/auth/concerns/owner_concern.rb +81 -0
- data/app/models/auth/concerns/shopping/cart_concern.rb +329 -0
- data/app/models/auth/concerns/shopping/cart_item_concern.rb +437 -0
- data/app/models/auth/concerns/shopping/discount_concern.rb +482 -0
- data/app/models/auth/concerns/shopping/discount_flow.txt +11 -0
- data/app/models/auth/concerns/shopping/pay_u_money_concern.rb +184 -0
- data/app/models/auth/concerns/shopping/payment_concern.rb +613 -0
- data/app/models/auth/concerns/shopping/product_concern.rb +102 -0
- data/app/models/auth/concerns/sms_otp_concern.rb +68 -0
- data/app/models/auth/concerns/user_concern.rb +788 -0
- data/app/models/auth/identity.rb +23 -0
- data/app/models/auth/shopping/cart.rb +3 -0
- data/app/models/auth/shopping/cart_item.rb +6 -0
- data/app/models/auth/shopping/cart_item_payment_result.rb +7 -0
- data/app/models/auth/shopping/discount.rb +4 -0
- data/app/models/auth/shopping/payment.rb +5 -0
- data/app/models/auth/shopping/product.rb +5 -0
- data/app/models/auth/user.rb +3 -0
- data/app/views/auth/admin_create_users/_admin_actions.html.erb +46 -0
- data/app/views/auth/admin_create_users/_form.html.erb +19 -0
- data/app/views/auth/admin_create_users/edit.html.erb +6 -0
- data/app/views/auth/admin_create_users/index.html.erb +25 -0
- data/app/views/auth/admin_create_users/new.html.erb +5 -0
- data/app/views/auth/admin_create_users/show.html.erb +8 -0
- data/app/views/auth/clients/_form.html.erb +41 -0
- data/app/views/auth/clients/edit.html.erb +6 -0
- data/app/views/auth/clients/index.html.erb +33 -0
- data/app/views/auth/clients/new.html.erb +5 -0
- data/app/views/auth/clients/show.html.erb +21 -0
- data/app/views/auth/confirmations/_enter_otp.html.erb +27 -0
- data/app/views/auth/confirmations/_get_otp_status.html.erb +25 -0
- data/app/views/auth/confirmations/_new_otp_input.js.erb +11 -0
- data/app/views/auth/confirmations/_resend_otp.js.erb +8 -0
- data/app/views/auth/confirmations/_resend_sms_otp.html.erb +18 -0
- data/app/views/auth/confirmations/_verify_otp.js.erb +64 -0
- data/app/views/auth/confirmations/create.js.erb +8 -0
- data/app/views/auth/confirmations/enter_otp.html.erb +7 -0
- data/app/views/auth/confirmations/get_otp_status.html.erb +3 -0
- data/app/views/auth/confirmations/new.html.erb +1 -0
- data/app/views/auth/confirmations/new.js.erb +16 -0
- data/app/views/auth/confirmations/otp_status_result.html.erb +20 -0
- data/app/views/auth/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/auth/mailer/password_change.html.erb +3 -0
- data/app/views/auth/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/auth/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/auth/modals/_ajax_error_modal.html.erb +3 -0
- data/app/views/auth/modals/_ajax_error_modal_content.html.erb +0 -0
- data/app/views/auth/modals/_edit_account_content.html.erb +68 -0
- data/app/views/auth/modals/_edit_account_success_content.html.erb +5 -0
- data/app/views/auth/modals/_error_notification.html.erb +8 -0
- data/app/views/auth/modals/_forgot_password_content.html.erb +18 -0
- data/app/views/auth/modals/_forgot_password_success_content.html.erb +8 -0
- data/app/views/auth/modals/_login_default_content.html.erb +3 -0
- data/app/views/auth/modals/_login_forms.html.erb +13 -0
- data/app/views/auth/modals/_login_navigation_options.html.erb +12 -0
- data/app/views/auth/modals/_new_otp_input.html.erb +28 -0
- data/app/views/auth/modals/_oauth_and_submit.html.erb +21 -0
- data/app/views/auth/modals/_recaptcha_tags.html.erb +4 -0
- data/app/views/auth/modals/_resend_confirmation_content.html.erb +17 -0
- data/app/views/auth/modals/_resend_confirmation_success_content.html.erb +8 -0
- data/app/views/auth/modals/_resend_otp.html.erb +23 -0
- data/app/views/auth/modals/_resource_errors.js.erb +24 -0
- data/app/views/auth/modals/_sign_in_inputs.html.erb +10 -0
- data/app/views/auth/modals/_sign_in_needed_modal.html.erb +3 -0
- data/app/views/auth/modals/_sign_in_success_content.html.erb +5 -0
- data/app/views/auth/modals/_sign_up_inputs.html.erb +9 -0
- data/app/views/auth/modals/_sign_up_success_content.html.erb +1 -0
- data/app/views/auth/modals/_sign_up_success_inactive_content.html.erb +2 -0
- data/app/views/auth/modals/_unlock_content.html.erb +17 -0
- data/app/views/auth/modals/_verify_otp.html.erb +1 -0
- data/app/views/auth/modals/base_modal/_base.html.erb +25 -0
- data/app/views/auth/modals/login.js.erb +120 -0
- data/app/views/auth/modals/unlock_success_content.html.erb +8 -0
- data/app/views/auth/notifier/_email.html.erb +3 -0
- data/app/views/auth/notifier/notification.html.erb +2 -0
- data/app/views/auth/notifier/notification.text.erb +1 -0
- data/app/views/auth/omniauth_callbacks/failure.html.erb +4 -0
- data/app/views/auth/passwords/create.js.erb +12 -0
- data/app/views/auth/passwords/edit.html.erb +25 -0
- data/app/views/auth/passwords/new.html.erb +16 -0
- data/app/views/auth/passwords/new.js.erb +19 -0
- data/app/views/auth/profiles/_proxy_resource.html.erb +5 -0
- data/app/views/auth/profiles/set_proxy_resource.js.erb +1 -0
- data/app/views/auth/profiles/show.html.erb +8 -0
- data/app/views/auth/registrations/create.js.erb +40 -0
- data/app/views/auth/registrations/edit.html.erb +2 -0
- data/app/views/auth/registrations/edit.js.erb +5 -0
- data/app/views/auth/registrations/new.html.erb +33 -0
- data/app/views/auth/registrations/update.js.erb +47 -0
- data/app/views/auth/search/_search_bar.html.erb +11 -0
- data/app/views/auth/search/_search_result.html.erb +7 -0
- data/app/views/auth/search/_search_results.html.erb +4 -0
- data/app/views/auth/search/authenticated_user_search.js.erb +45 -0
- data/app/views/auth/search/authenticated_user_search.json +7 -0
- data/app/views/auth/sessions/create.js.erb +5 -0
- data/app/views/auth/sessions/new.html.erb +4 -0
- data/app/views/auth/sessions/new.js.erb +20 -0
- data/app/views/auth/shared/_devise_error_messages.html.erb +9 -0
- data/app/views/auth/shared/_links.html.erb +25 -0
- data/app/views/auth/shared/_object_errors.html.erb +12 -0
- data/app/views/auth/shared/_proxy_resource.html.erb +18 -0
- data/app/views/auth/shopping/cart_items/_form.html.erb +34 -0
- data/app/views/auth/shopping/cart_items/_show_cart_items_collection.html.erb +31 -0
- data/app/views/auth/shopping/cart_items/create_multiple.html.erb +6 -0
- data/app/views/auth/shopping/cart_items/create_multiple.json.erb +9 -0
- data/app/views/auth/shopping/cart_items/edit.html.erb +6 -0
- data/app/views/auth/shopping/cart_items/index.html.erb +52 -0
- data/app/views/auth/shopping/cart_items/new.html.erb +5 -0
- data/app/views/auth/shopping/cart_items/show.html.erb +13 -0
- data/app/views/auth/shopping/carts/_form.html.erb +35 -0
- data/app/views/auth/shopping/carts/_payment_links.html.erb +27 -0
- data/app/views/auth/shopping/carts/_remove_cart_item.html.erb +11 -0
- data/app/views/auth/shopping/carts/_show_cart_balance_info.html.erb +35 -0
- data/app/views/auth/shopping/carts/edit.html.erb +6 -0
- data/app/views/auth/shopping/carts/index.html.erb +43 -0
- data/app/views/auth/shopping/carts/new.html.erb +5 -0
- data/app/views/auth/shopping/carts/show.html.erb +46 -0
- data/app/views/auth/shopping/discounts/_form.html.erb +18 -0
- data/app/views/auth/shopping/discounts/_form_for_create_multiple_cart_items.html.erb +17 -0
- data/app/views/auth/shopping/discounts/_show_pending_discount_request.html.erb +17 -0
- data/app/views/auth/shopping/discounts/destroy.html.erb +2 -0
- data/app/views/auth/shopping/discounts/edit.html.erb +29 -0
- data/app/views/auth/shopping/discounts/index.html.erb +40 -0
- data/app/views/auth/shopping/discounts/new.html.erb +1 -0
- data/app/views/auth/shopping/discounts/show.html.erb +18 -0
- data/app/views/auth/shopping/discounts/update.html.erb +2 -0
- data/app/views/auth/shopping/payments/_approve_payment.html.erb +7 -0
- data/app/views/auth/shopping/payments/_cash_card_cheque.html.erb +24 -0
- data/app/views/auth/shopping/payments/_create_discount_coupon.html.erb +5 -0
- data/app/views/auth/shopping/payments/_form.html.erb +19 -0
- data/app/views/auth/shopping/payments/_gateway.html.erb +21 -0
- data/app/views/auth/shopping/payments/_proceed_to_gateway_or_verify_payment.html.erb +18 -0
- data/app/views/auth/shopping/payments/_refresh_payment.html.erb +7 -0
- data/app/views/auth/shopping/payments/_refund.html.erb +10 -0
- data/app/views/auth/shopping/payments/_show_payment_receipt.html.erb +12 -0
- data/app/views/auth/shopping/payments/edit.html.erb +6 -0
- data/app/views/auth/shopping/payments/index.html.erb +43 -0
- data/app/views/auth/shopping/payments/new.html.erb +13 -0
- data/app/views/auth/shopping/payments/show.html.erb +36 -0
- data/app/views/auth/shopping/products/_form.html.erb +27 -0
- data/app/views/auth/shopping/products/edit.html.erb +6 -0
- data/app/views/auth/shopping/products/index.html.erb +48 -0
- data/app/views/auth/shopping/products/index.json.erb +7 -0
- data/app/views/auth/shopping/products/new.html.erb +5 -0
- data/app/views/auth/shopping/products/show.html.erb +12 -0
- data/app/views/auth/shopping/products/show.json.erb +1 -0
- data/app/views/auth/unlocks/create.js.erb +12 -0
- data/app/views/auth/unlocks/new.html.erb +14 -0
- data/app/views/auth/unlocks/new.js.erb +17 -0
- data/app/views/auth/users/_search_result.html.erb +8 -0
- data/app/views/auth/users/profiles/_user_data.html.erb +4 -0
- data/app/views/auth/users/profiles/show.html.erb +54 -0
- data/app/views/layouts/auth/_modals.html.erb +2 -0
- data/app/views/layouts/auth/application.html.erb +17 -0
- data/app/views/layouts/auth/navbar/_navbar.html.erb +49 -0
- data/app/views/layouts/auth/navbar/_personalization.html.erb +17 -0
- data/app/views/layouts/auth/navbar/_progress_spinner.html.erb +11 -0
- data/app/views/layouts/mailer.html.erb +5 -0
- data/app/views/layouts/mailer.text.erb +1 -0
- data/config/initializers/active_model.rb +36 -0
- data/config/initializers/devise.rb +623 -0
- data/config/initializers/json.rb +10 -0
- data/config/initializers/omniauth.rb +447 -0
- data/config/initializers/redis.rb +2 -0
- data/config/initializers/redis.yml +14 -0
- data/config/locales/devise.en.yml +63 -0
- data/config/routes.rb +1 -0
- data/lib/assets/javascripts/data.js +126 -0
- data/lib/assets/javascripts/jquery.calendario.js +394 -0
- data/lib/assets/javascripts/jquery.tagcloud.js +92 -0
- data/lib/assets/javascripts/leanModal.js +236 -0
- data/lib/assets/javascripts/main.js +668 -0
- data/lib/assets/javascripts/modernizr.custom.63321.js +4 -0
- data/lib/assets/javascripts/payumoney.js +9 -0
- data/lib/assets/javascripts/search.js +36 -0
- data/lib/assets/javascripts/spinner.js +77 -0
- data/lib/assets/javascripts/trianglify.min.js +2 -0
- data/lib/assets/javascripts/you_need_to_sign_in.js.erb +478 -0
- data/lib/assets/stylesheets/calendar.css +111 -0
- data/lib/assets/stylesheets/calendar_modifications.scss +276 -0
- data/lib/auth.rb +32 -0
- data/lib/auth/custom_failure.rb +3 -0
- data/lib/auth/engine.rb +231 -0
- data/lib/auth/job_exception_handler.rb +7 -0
- data/lib/auth/mailgun.rb +28 -0
- data/lib/auth/notify.rb +8 -0
- data/lib/auth/omniauth/path.rb +104 -0
- data/lib/auth/partials.rb +12 -0
- data/lib/auth/rails/routes.rb +169 -0
- data/lib/auth/search/main.rb +97 -0
- data/lib/auth/sidekiq_up.rb +16 -0
- data/lib/auth/two_factor_otp.rb +202 -0
- data/lib/auth/url_shortener.rb +29 -0
- data/lib/auth/version.rb +3 -0
- data/lib/tasks/auth_tasks.rake +4 -0
- metadata +863 -0
data/lib/auth/mailgun.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module Auth
|
2
|
+
module Mailgun
|
3
|
+
## returns the email after adding a webhook identifier variable.
|
4
|
+
def add_webhook_identifier_to_email(email)
|
5
|
+
email.message.mailgun_variables = {}
|
6
|
+
email.message.mailgun_variables["webhook_identifier"] = BSON::ObjectId.new.to_s
|
7
|
+
email
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.set_webhook_identifier(notification_response,last_response)
|
11
|
+
|
12
|
+
last_response = JSON.parse(last_response).deep_symbolize_keys
|
13
|
+
notification_response.webhook_identifier = last_response[:webhook_identifier] if not last_response[:webhook_identifier].nil?
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
def email_webhook(params)
|
18
|
+
|
19
|
+
Auth.configuration.notification_response_class.constantize.find_and_update_notification_response(params[:webhook_identifier], JSON.generate(params)) do |notification_response|
|
20
|
+
|
21
|
+
#puts "found email notification response:"
|
22
|
+
#puts notification_response.attributes.to_s
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
data/lib/auth/notify.rb
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
module Auth
|
2
|
+
module OmniAuth
|
3
|
+
module Path
|
4
|
+
|
5
|
+
##############################################
|
6
|
+
##
|
7
|
+
## FOR BUILDING THE PATHS FOR SHOPPING CLASSES.
|
8
|
+
##
|
9
|
+
##############################################
|
10
|
+
|
11
|
+
def self.new_path(cls)
|
12
|
+
"new_" + cls.constantize.new.class.name.underscore.gsub(/\//,"_") + "_path"
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def self.show_or_update_or_delete_path(cls)
|
17
|
+
|
18
|
+
parts = cls.constantize.new.class.name.split("::")
|
19
|
+
parts.map{|c| c.underscore.downcase}.join("_") + "_path"
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def self.create_or_index_path(cls)
|
24
|
+
parts = cls.constantize.new.class.name.split("::")
|
25
|
+
parts[-1] = parts[-1].pluralize
|
26
|
+
parts.map{|c| c.underscore.downcase}.join("_") + "_path"
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.edit_path(cls)
|
30
|
+
"edit_" + show_or_update_or_delete_path(cls)
|
31
|
+
end
|
32
|
+
|
33
|
+
##############################################
|
34
|
+
##
|
35
|
+
##
|
36
|
+
##
|
37
|
+
##############################################
|
38
|
+
|
39
|
+
|
40
|
+
## given something like : shopping/product
|
41
|
+
## will return something like: Shopping::Product
|
42
|
+
def self.path_to_model(path)
|
43
|
+
path.split("/").map{|c| c = c.capitalize}.join("::").constantize
|
44
|
+
end
|
45
|
+
|
46
|
+
## given something like :Shopping::Product
|
47
|
+
## will return something like shopping/products
|
48
|
+
def self.model_to_path(cls)
|
49
|
+
parts = cls.to_s.split("::").map{|c| c = c.to_s.downcase}
|
50
|
+
parts[-1] = parts[-1].pluralize
|
51
|
+
parts.join("/")
|
52
|
+
end
|
53
|
+
|
54
|
+
##the the path for the request_phase of the omniauth call.
|
55
|
+
def self.omniauth_request_path(resource,provider)
|
56
|
+
resource_or_scope = resource.nil? ? ":res" :
|
57
|
+
resource_pluralized(resource)
|
58
|
+
"#{omniauth_prefix_path}/#{resource_or_scope}/#{provider}"
|
59
|
+
end
|
60
|
+
|
61
|
+
##the omniauth prefix = mount_path/omniauth
|
62
|
+
def self.omniauth_prefix_path
|
63
|
+
"#{Auth.configuration.mount_path}/omniauth"
|
64
|
+
end
|
65
|
+
|
66
|
+
##the path for the callback is the same for all models.
|
67
|
+
def self.common_callback_path(provider)
|
68
|
+
"#{omniauth_prefix_path}/#{provider}/callback"
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.resource_pluralized(resource)
|
72
|
+
resource.to_s.pluralize.underscore.gsub('/', '_')
|
73
|
+
end
|
74
|
+
|
75
|
+
##the path prefix for all the devise modules.
|
76
|
+
def self.resource_path(resource)
|
77
|
+
"#{Auth.configuration.mount_path}/#{resource_pluralized resource}"
|
78
|
+
end
|
79
|
+
|
80
|
+
##the absolute path that is returned by the omniauth url helper
|
81
|
+
##devise takes care of prepending the resource and the mount prefix.
|
82
|
+
def self.omniauth_failure_absolute_path
|
83
|
+
"omniauth/failed"
|
84
|
+
end
|
85
|
+
|
86
|
+
##this is the path that is used in the routes.rb file, to build
|
87
|
+
##the actual route.
|
88
|
+
##keeps :res as a wildcard for the required resource.
|
89
|
+
def self.omniauth_failure_route_path(resource_or_scope)
|
90
|
+
resource_or_scope = resource_or_scope.nil? ? ":res" : resource_pluralized(resource_or_scope.class.name)
|
91
|
+
"#{Auth.configuration.mount_path}/#{resource_or_scope}/#{omniauth_failure_absolute_path}"
|
92
|
+
end
|
93
|
+
|
94
|
+
##refresh auth token path
|
95
|
+
#def self.refresh_auth_token_path(resource_or_scope)
|
96
|
+
# resource_or_scope = resource_or_scope.nil? ? ":res" : resource_pluralized(resource_or_scope.class.name)
|
97
|
+
# "#{Auth.configuration.mount_path}/#{resource_or_scope}/refresh_token"
|
98
|
+
#end
|
99
|
+
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Auth
|
2
|
+
module Partials
|
3
|
+
# a helper method to get the name of the additional login param new otp partial.
|
4
|
+
# used in the auth/views/registrations/create.js.erb,
|
5
|
+
# because there resolving to a nil value in case the additional_login_param_new_otp_partial is not defined, throws an error, even if the if condition for an additional login param is not entered, since its a js.erb.
|
6
|
+
# so the solution was to return a default value as the sign up success invalid content html erb.
|
7
|
+
# this will never be actually hit, but the js erb checks whether the partial exists, even if the if condition where that statement lies is never even reached.
|
8
|
+
def self.additional_login_param_new_otp_partial(resource)
|
9
|
+
Auth.configuration.auth_resources[resource.class.to_s.capitalize][:additional_login_param_new_otp_partial] or 'auth/modals/sign_up_success_inactive_content.html.erb'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,169 @@
|
|
1
|
+
module ActionDispatch::Routing
|
2
|
+
class Mapper
|
3
|
+
|
4
|
+
##@param app_route_resources[Hash] ->
|
5
|
+
##key:resource[String] -> the name of the resource for which omniauth routes are to be generated.
|
6
|
+
##value:opts[Hash] -> the options specifying the views, controllers etc for omniauth.
|
7
|
+
##expected to be present in the preinitializer in the routes of the target app.
|
8
|
+
def mount_routes(app_route_resources)
|
9
|
+
|
10
|
+
resources :search, :controller => "auth/search" do
|
11
|
+
collection do
|
12
|
+
get 'authenticated_user_search', :action => 'authenticated_user_search', :as => "authenticated_user"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
resources :admin_create_users, :controller => "auth/admin_create_users"
|
17
|
+
|
18
|
+
resources :clients, :controller => "auth/clients"
|
19
|
+
resources :profiles, :controller => "auth/profiles" do
|
20
|
+
collection do
|
21
|
+
## :resource will be something like users.
|
22
|
+
post ':resource/set_proxy_user', :action => 'set_proxy_resource', :as => "set_proxy_resource"
|
23
|
+
get 'credential_exists', :action => 'credential_exists'
|
24
|
+
post ':resource/get_user_id', :action => 'get_user_id'
|
25
|
+
put ':resource/update', :action => 'update'
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
if Auth.configuration.otp_controller
|
31
|
+
get "#{Auth.configuration.mount_path}/:resource/otp_verification_result", :action => "otp_verification_result", :controller => "#{Auth.configuration.otp_controller}", :as => "otp_verification_result"
|
32
|
+
get "#{Auth.configuration.mount_path}/:resource/verify_otp", :action => "verify_otp", :controller => "#{Auth.configuration.otp_controller}", :as => "verify_otp"
|
33
|
+
get "#{Auth.configuration.mount_path}/:resource/send_sms_otp", :action => "send_sms_otp", :controller => "#{Auth.configuration.otp_controller}", :as => "send_sms_otp"
|
34
|
+
get "#{Auth.configuration.mount_path}/:resource/resend_sms_otp", :action => "resend_sms_otp", :controller => "#{Auth.configuration.otp_controller}", :as => "resend_sms_otp"
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
["cart_item","cart","payment","product","discount"].each do |model|
|
39
|
+
|
40
|
+
if Auth.configuration.send("#{model}_controller")
|
41
|
+
|
42
|
+
scope_path = "/"
|
43
|
+
as_prefix = nil
|
44
|
+
collection = nil
|
45
|
+
|
46
|
+
Auth.configuration.send("#{model}_class").underscore.pluralize.scan(/(?<scope_path>.+?)\/(?<collection>[A-Za-z_]+)$/) do
|
47
|
+
|
48
|
+
if Regexp.last_match[:scope_path]
|
49
|
+
scope_path = scope_path + Regexp.last_match[:scope_path]
|
50
|
+
## this is done so that the route helper defined inside the engine views also work.
|
51
|
+
as_prefix = Regexp.last_match[:scope_path]
|
52
|
+
end
|
53
|
+
collection = Regexp.last_match[:collection]
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
if collection
|
58
|
+
scope :path => scope_path, :as => as_prefix do
|
59
|
+
#puts "As prefix is: #{as_prefix}"
|
60
|
+
#puts "scope path is: #{scope_path}"
|
61
|
+
controller_name = Auth.configuration.send("#{model}_controller")
|
62
|
+
|
63
|
+
resources collection.to_sym, controller: controller_name do
|
64
|
+
collection do
|
65
|
+
## for the option to create multiple cart items at one time.
|
66
|
+
if model == "cart_item"
|
67
|
+
post 'create_multiple', :action => 'create_multiple'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
##A ROUTE HAS BEEN ADDED IN THE DAUGHTER APP FOR THE POST -> TO THE PAYMENTS_UPDATE FOR PAYUMONEY.
|
75
|
+
##refer payumoney_controller_concern.rb
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
app_route_resources.each do |resource,opts|
|
86
|
+
|
87
|
+
#puts "resource is : #{resource}"
|
88
|
+
#puts "opts are: #{opts}"
|
89
|
+
# ensure objects exist to simplify attr checks
|
90
|
+
opts[:controllers] ||= {}
|
91
|
+
opts[:skip] ||= []
|
92
|
+
|
93
|
+
|
94
|
+
# check for ctrl overrides, fall back to defaults
|
95
|
+
sessions_ctrl = opts[:controllers][:sessions] || "auth/sessions"
|
96
|
+
registrations_ctrl = opts[:controllers][:registrations] || "auth/registrations"
|
97
|
+
passwords_ctrl = opts[:controllers][:passwords] || "auth/passwords"
|
98
|
+
confirmations_ctrl = opts[:controllers][:confirmations] || "auth/confirmations"
|
99
|
+
omniauth_ctrl = opts[:controllers][:omniauth_callbacks] || "auth/omniauth_callbacks"
|
100
|
+
unlocks_ctrl = opts[:controllers][:unlocks] || "auth/unlocks"
|
101
|
+
|
102
|
+
# define devise controller mappings
|
103
|
+
controllers = {:sessions => sessions_ctrl,
|
104
|
+
:registrations => registrations_ctrl,
|
105
|
+
:passwords => passwords_ctrl,
|
106
|
+
:confirmations => confirmations_ctrl,
|
107
|
+
:unlocks => unlocks_ctrl
|
108
|
+
}
|
109
|
+
|
110
|
+
# remove any unwanted devise modules
|
111
|
+
opts[:skip].each{|item| controllers.delete(item)}
|
112
|
+
|
113
|
+
resource_as_pluralized_string = Auth::OmniAuth::Path.resource_pluralized(resource)
|
114
|
+
|
115
|
+
devise_for resource_as_pluralized_string.to_sym,
|
116
|
+
:class_name => resource,
|
117
|
+
:module => :devise,
|
118
|
+
:path => "#{Auth::OmniAuth::Path.resource_path(resource)}",
|
119
|
+
:controllers => controllers,
|
120
|
+
:skip => opts[:skip] + [:omniauth_callbacks]
|
121
|
+
|
122
|
+
|
123
|
+
resource_class = Object.const_get resource
|
124
|
+
|
125
|
+
#################################################################
|
126
|
+
##
|
127
|
+
## OMNIAUTH PATHS
|
128
|
+
##
|
129
|
+
#################################################################
|
130
|
+
|
131
|
+
if !(opts[:skip].include? :omniauthable)
|
132
|
+
|
133
|
+
resource_class.omniauth_providers.each do |provider|
|
134
|
+
|
135
|
+
omniauth_request_path = Auth::OmniAuth::Path.omniauth_request_path(nil,provider)
|
136
|
+
|
137
|
+
common_callback_path = Auth::OmniAuth::Path.common_callback_path(provider)
|
138
|
+
|
139
|
+
if !Rails.application.routes.url_helpers.method_defined?("#{provider}_omniauth_authorize_path".to_sym)
|
140
|
+
puts "calling route for provider: #{provider}"
|
141
|
+
match "#{omniauth_request_path}", controller: omniauth_ctrl, action: "passthru", via: [:get,:post], as: "#{provider}_omniauth_authorize"
|
142
|
+
end
|
143
|
+
|
144
|
+
if !Rails.application.routes.url_helpers.method_defined?("#{provider}_omniauth_callback_path".to_sym)
|
145
|
+
match "#{common_callback_path}", controller: omniauth_ctrl, action: "omni_common", via: [:get,:post], as: "#{provider}_omniauth_callback"
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
oauth_failure_route_path = Auth::OmniAuth::Path.omniauth_failure_route_path(nil)
|
150
|
+
|
151
|
+
if !Rails.application.routes.url_helpers.method_defined?("omniauth_failure_path".to_sym)
|
152
|
+
|
153
|
+
match "#{oauth_failure_route_path}", controller: omniauth_ctrl, action: "failure", via:[:get,:post], as: "omniauth_failure"
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
#################################################################
|
158
|
+
##
|
159
|
+
## RESOURCE_PROFILE PATHS
|
160
|
+
##
|
161
|
+
#################################################################
|
162
|
+
|
163
|
+
#match "#{omniauth_request_path}", controller: omniauth_ctrl, action: "passthru", via: [:get,:post], as: "#{provider}_omniauth_authorize"
|
164
|
+
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module Auth
|
2
|
+
module Search
|
3
|
+
module Main
|
4
|
+
## this def, returns a hash with the structure for the basic ngram query.
|
5
|
+
## the query_string is left blank, and you should merge this in through any def that wants to perform an ngram query.
|
6
|
+
## @return[Hash]
|
7
|
+
def self.base_ngram_query
|
8
|
+
{
|
9
|
+
body: {
|
10
|
+
query: {
|
11
|
+
filtered:
|
12
|
+
{
|
13
|
+
query: {
|
14
|
+
match: {
|
15
|
+
_all: {
|
16
|
+
query: "",
|
17
|
+
operator: "and"
|
18
|
+
}
|
19
|
+
}
|
20
|
+
},
|
21
|
+
filter: {
|
22
|
+
match_all:{
|
23
|
+
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
## @param[Hash] : This is expected to contain the following:
|
33
|
+
## @query_string : the query supplied by the user
|
34
|
+
## @resource_id : a resource_id with which to filter search results, if its not provided, no filter is used on the search results
|
35
|
+
## @size : if not provided a default size of 20 is used
|
36
|
+
## this def will use the #base_ngram_query hash and merge in a filter for the resource_id.
|
37
|
+
|
38
|
+
## 'Public' Resources
|
39
|
+
## if the public field is present, don't add any resource_id filter.
|
40
|
+
## if the public field is not present, then add the resource_id filter if the resource_id is provided.
|
41
|
+
|
42
|
+
|
43
|
+
## @return[Array] response: an array of mongoid search result objects.
|
44
|
+
def self.search(args)
|
45
|
+
args = args.deep_symbolize_keys
|
46
|
+
return [] unless args[:query_string]
|
47
|
+
query = base_ngram_query
|
48
|
+
|
49
|
+
## set all the required values.
|
50
|
+
query[:size] = args[:size] || 20
|
51
|
+
|
52
|
+
query[:body][:query][:filtered][:query][:match][:_all][:query] = args[:query_string]
|
53
|
+
if args[:resource_id]
|
54
|
+
query[:body][:query][:filtered][:filter] = {
|
55
|
+
|
56
|
+
bool: {
|
57
|
+
should: [
|
58
|
+
{
|
59
|
+
bool: {
|
60
|
+
must: [
|
61
|
+
{
|
62
|
+
term: {
|
63
|
+
public: "no"
|
64
|
+
}
|
65
|
+
},
|
66
|
+
{
|
67
|
+
term: {
|
68
|
+
resource_id: args[:resource_id]
|
69
|
+
}
|
70
|
+
}
|
71
|
+
]
|
72
|
+
}
|
73
|
+
},
|
74
|
+
{
|
75
|
+
term: {
|
76
|
+
public: "yes"
|
77
|
+
}
|
78
|
+
}
|
79
|
+
]
|
80
|
+
}
|
81
|
+
|
82
|
+
}
|
83
|
+
else
|
84
|
+
## if a resource id is not provided then
|
85
|
+
## it means that the resource is admin,
|
86
|
+
## and they should be able to access and see
|
87
|
+
## any resource
|
88
|
+
## so in that case we leave the query
|
89
|
+
## as is.
|
90
|
+
end
|
91
|
+
|
92
|
+
#puts JSON.pretty_generate(query)
|
93
|
+
Mongoid::Elasticsearch.search(query,{:wrapper => :load}).results
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
=begin
|
2
|
+
require "sidekiq/api"
|
3
|
+
module Auth
|
4
|
+
module SidekiqUp
|
5
|
+
## @param job_description[String]: a json representation of whatever job / arguments you wanted to pass into sidekiq, it is used to log an error in case sidekiq is down.
|
6
|
+
## the determination of sidekiq begin down is done by checking if the queues hash is empty.
|
7
|
+
## @return : yields the block called with this method in case the queues are not empty, otherwise the result of calling Rails.logger.error
|
8
|
+
def self.sidekiq_running(job_description)
|
9
|
+
stats = Sidekiq::Stats.new
|
10
|
+
yield
|
11
|
+
#yield unless stats.queues.empty?
|
12
|
+
#Rails.logger.error("sidekiq could not do job because sidekiq was not started: #{job_description}") if stats.queues.empty?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
=end
|