wordjelly-auth 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. checksums.yaml +4 -4
  2. data/lib/auth/version.rb +1 -1
  3. data/spec/auth_test.rb +7 -0
  4. data/spec/controllers/auth/admin_create_users_controller_spec.rb +141 -0
  5. data/spec/controllers/auth/clients_controller_spec.rb +223 -0
  6. data/spec/controllers/auth/search_controller_spec.rb +5 -0
  7. data/spec/controllers/auth/shopping/discounts_controller_spec.rb +54 -0
  8. data/spec/controllers/auth/users/profiles_controller_spec.rb +5 -0
  9. data/spec/dummy/README.rdoc +28 -0
  10. data/spec/dummy/Rakefile +6 -0
  11. data/spec/dummy/app/assets/javascripts/activity.js +2 -0
  12. data/spec/dummy/app/assets/javascripts/application.js +16 -0
  13. data/spec/dummy/app/assets/javascripts/home.js +2 -0
  14. data/spec/dummy/app/assets/javascripts/pollymer.min.js +170 -0
  15. data/spec/dummy/app/assets/javascripts/tests.js +2 -0
  16. data/spec/dummy/app/assets/javascripts/topics.js +2 -0
  17. data/spec/dummy/app/assets/stylesheets/activity.css +4 -0
  18. data/spec/dummy/app/assets/stylesheets/application.scss +16 -0
  19. data/spec/dummy/app/assets/stylesheets/home.css +4 -0
  20. data/spec/dummy/app/assets/stylesheets/tests.css +4 -0
  21. data/spec/dummy/app/assets/stylesheets/topics.css +4 -0
  22. data/spec/dummy/app/controllers/activity_controller.rb +3 -0
  23. data/spec/dummy/app/controllers/admins/confirmations_controller.rb +28 -0
  24. data/spec/dummy/app/controllers/admins/omniauth_callbacks_controller.rb +28 -0
  25. data/spec/dummy/app/controllers/admins/passwords_controller.rb +32 -0
  26. data/spec/dummy/app/controllers/admins/registrations_controller.rb +60 -0
  27. data/spec/dummy/app/controllers/admins/sessions_controller.rb +5 -0
  28. data/spec/dummy/app/controllers/admins/unlocks_controller.rb +28 -0
  29. data/spec/dummy/app/controllers/application_controller.rb +49 -0
  30. data/spec/dummy/app/controllers/home_controller.rb +13 -0
  31. data/spec/dummy/app/controllers/otp_controller.rb +3 -0
  32. data/spec/dummy/app/controllers/shopping/cart_items_controller.rb +28 -0
  33. data/spec/dummy/app/controllers/shopping/carts_controller.rb +4 -0
  34. data/spec/dummy/app/controllers/shopping/discounts_controller.rb +3 -0
  35. data/spec/dummy/app/controllers/shopping/payments_controller.rb +5 -0
  36. data/spec/dummy/app/controllers/shopping/products_controller.rb +2 -0
  37. data/spec/dummy/app/controllers/tests_controller.rb +58 -0
  38. data/spec/dummy/app/controllers/topics_controller.rb +63 -0
  39. data/spec/dummy/app/controllers/users/sessions_controller.rb +3 -0
  40. data/spec/dummy/app/controllers/webhooks_controller.rb +13 -0
  41. data/spec/dummy/app/helpers/activity_helper.rb +2 -0
  42. data/spec/dummy/app/helpers/api/v1/token_auth_helper.rb +2 -0
  43. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  44. data/spec/dummy/app/helpers/home_helper.rb +2 -0
  45. data/spec/dummy/app/helpers/tests_helper.rb +2 -0
  46. data/spec/dummy/app/helpers/topics_helper.rb +2 -0
  47. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  48. data/spec/dummy/app/mailers/new.rb +3 -0
  49. data/spec/dummy/app/models/activity.rb +3 -0
  50. data/spec/dummy/app/models/admin.rb +12 -0
  51. data/spec/dummy/app/models/noti.rb +48 -0
  52. data/spec/dummy/app/models/noti_response.rb +9 -0
  53. data/spec/dummy/app/models/shopping/cart.rb +3 -0
  54. data/spec/dummy/app/models/shopping/cart_item.rb +7 -0
  55. data/spec/dummy/app/models/shopping/discount.rb +3 -0
  56. data/spec/dummy/app/models/shopping/payment.rb +16 -0
  57. data/spec/dummy/app/models/shopping/product.rb +6 -0
  58. data/spec/dummy/app/models/test.rb +5 -0
  59. data/spec/dummy/app/models/topic.rb +75 -0
  60. data/spec/dummy/app/models/user.rb +95 -0
  61. data/spec/dummy/app/views/home/index.html.erb +6 -0
  62. data/spec/dummy/app/views/home/send_notification.html.erb +2 -0
  63. data/spec/dummy/app/views/layouts/application.html.erb +26 -0
  64. data/spec/dummy/app/views/layouts/mailer.html.erb +8 -0
  65. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  66. data/spec/dummy/app/views/new/notification.html.erb +1 -0
  67. data/spec/dummy/app/views/new/notification.text.erb +1 -0
  68. data/spec/dummy/app/views/shopping/_navigation_options.html.erb +1 -0
  69. data/spec/dummy/app/views/tests/_form.html.erb +25 -0
  70. data/spec/dummy/app/views/tests/edit.html.erb +6 -0
  71. data/spec/dummy/app/views/tests/index.html.erb +33 -0
  72. data/spec/dummy/app/views/tests/new.html.erb +5 -0
  73. data/spec/dummy/app/views/tests/show.html.erb +14 -0
  74. data/spec/dummy/app/views/topics/_form.html.erb +25 -0
  75. data/spec/dummy/app/views/topics/edit.html.erb +6 -0
  76. data/spec/dummy/app/views/topics/index.html.erb +29 -0
  77. data/spec/dummy/app/views/topics/new.html.erb +5 -0
  78. data/spec/dummy/app/views/topics/show.html.erb +14 -0
  79. data/spec/dummy/app/views/users/sessions/create.js.erb +6 -0
  80. data/spec/dummy/bin/bundle +3 -0
  81. data/spec/dummy/bin/rails +4 -0
  82. data/spec/dummy/bin/rake +4 -0
  83. data/spec/dummy/bin/setup +29 -0
  84. data/spec/dummy/config.ru +8 -0
  85. data/spec/dummy/config/application.rb +31 -0
  86. data/spec/dummy/config/boot.rb +5 -0
  87. data/spec/dummy/config/environment.rb +4 -0
  88. data/spec/dummy/config/environments/development.rb +57 -0
  89. data/spec/dummy/config/environments/production.rb +92 -0
  90. data/spec/dummy/config/environments/test.rb +44 -0
  91. data/spec/dummy/config/initializers/assets.rb +11 -0
  92. data/spec/dummy/config/initializers/aws.rb +15 -0
  93. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  94. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  95. data/spec/dummy/config/initializers/devise.rb +273 -0
  96. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  97. data/spec/dummy/config/initializers/inflections.rb +16 -0
  98. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  99. data/spec/dummy/config/initializers/preinitializer.rb +167 -0
  100. data/spec/dummy/config/initializers/redis.rb +9 -0
  101. data/spec/dummy/config/initializers/session_store.rb +3 -0
  102. data/spec/dummy/config/initializers/wrap_parameters.rb +9 -0
  103. data/spec/dummy/config/locales/devise.en.yml +62 -0
  104. data/spec/dummy/config/locales/en.yml +25 -0
  105. data/spec/dummy/config/mongoid.yml +142 -0
  106. data/spec/dummy/config/redis.yml +14 -0
  107. data/spec/dummy/config/routes.rb +38 -0
  108. data/spec/dummy/config/secrets.yml +22 -0
  109. data/spec/dummy/db/seeds.rb +48 -0
  110. data/spec/dummy/lib/admin/parameter_sanitizer.rb +9 -0
  111. data/spec/dummy/lib/assets/files/test_names.json +1 -0
  112. data/spec/dummy/lib/user/parameter_sanitizer.rb +8 -0
  113. data/spec/dummy/public/404.html +67 -0
  114. data/spec/dummy/public/422.html +67 -0
  115. data/spec/dummy/public/500.html +66 -0
  116. data/spec/dummy/public/favicon.ico +0 -0
  117. data/spec/dummy/shoryuken.yml +5 -0
  118. data/spec/dummy/sidekiq.yml +9 -0
  119. data/spec/dummy/sidekiq_prep.sh +6 -0
  120. data/spec/dummy/spec/controllers/activity_controller_spec.rb +5 -0
  121. data/spec/dummy/spec/controllers/tests_controller_spec.rb +141 -0
  122. data/spec/dummy/spec/factories/tests.rb +6 -0
  123. data/spec/dummy/spec/fixtures/new/send_notification +3 -0
  124. data/spec/dummy/spec/helpers/activity_helper_spec.rb +15 -0
  125. data/spec/dummy/spec/helpers/tests_helper_spec.rb +15 -0
  126. data/spec/dummy/spec/mailers/new_spec.rb +18 -0
  127. data/spec/dummy/spec/mailers/previews/new_preview.rb +13 -0
  128. data/spec/dummy/spec/models/test_spec.rb +5 -0
  129. data/spec/dummy/spec/requests/tests_spec.rb +10 -0
  130. data/spec/dummy/spec/routing/tests_routing_spec.rb +39 -0
  131. data/spec/dummy/spec/views/tests/edit.html.erb_spec.rb +21 -0
  132. data/spec/dummy/spec/views/tests/index.html.erb_spec.rb +22 -0
  133. data/spec/dummy/spec/views/tests/new.html.erb_spec.rb +21 -0
  134. data/spec/dummy/spec/views/tests/show.html.erb_spec.rb +16 -0
  135. data/spec/dummy/test/controllers/api/v1/token_auth_controller_test.rb +7 -0
  136. data/spec/dummy/test/controllers/home_controller_test.rb +9 -0
  137. data/spec/dummy/test/controllers/oauth_tests_controller_test.rb +7 -0
  138. data/spec/dummy/test/fixtures/oauth_tests.yml +11 -0
  139. data/spec/dummy/test/fixtures/users.yml +7 -0
  140. data/spec/dummy/test/models/oauth_test_test.rb +7 -0
  141. data/spec/dummy/test/models/user_test.rb +7 -0
  142. data/spec/factories/client_factory.rb +77 -0
  143. data/spec/features/additional_login_param_feature_spec.rb +63 -0
  144. data/spec/features/extension_spec.rb +680 -0
  145. data/spec/features/redirect_disable_spec.rb +74 -0
  146. data/spec/fixtures/auth/clients.yml +13 -0
  147. data/spec/helpers/auth/admin_create_users_helper_spec.rb +15 -0
  148. data/spec/helpers/auth/resource_helper_spec.rb +15 -0
  149. data/spec/helpers/auth/search_helper_spec.rb +15 -0
  150. data/spec/helpers/auth/users/profiles_helper_spec.rb +15 -0
  151. data/spec/integration/navigation_test.rb +8 -0
  152. data/spec/mailers/auth/notifier_spec.rb +5 -0
  153. data/spec/mailers/previews/auth/notifier_preview.rb +4 -0
  154. data/spec/models/auth/admin_create_user_spec.rb +5 -0
  155. data/spec/models/auth/client_test.rb +9 -0
  156. data/spec/models/auth/shopping/discount_spec.rb +5 -0
  157. data/spec/rails_helper.rb +70 -0
  158. data/spec/requests/admin/confirmation_request_spec.rb +164 -0
  159. data/spec/requests/admin/password_request_spec.rb +191 -0
  160. data/spec/requests/admin/registration_request_spec.rb +574 -0
  161. data/spec/requests/admin/session_request_spec.rb +352 -0
  162. data/spec/requests/admin/unlock_request_spec.rb +178 -0
  163. data/spec/requests/admin_create_user_request_spec.rb +303 -0
  164. data/spec/requests/background_job_request_spec.rb +28 -0
  165. data/spec/requests/cart_item_request_spec.rb +381 -0
  166. data/spec/requests/cart_request_spec.rb +451 -0
  167. data/spec/requests/client_request_spec.rb +65 -0
  168. data/spec/requests/discount_request_spec.rb +589 -0
  169. data/spec/requests/payment_request_spec.rb +1254 -0
  170. data/spec/requests/search_request_spec.rb +173 -0
  171. data/spec/requests/topic_request_spec.rb +138 -0
  172. data/spec/requests/user/additional_login_param_and_email_validation_spec.rb +673 -0
  173. data/spec/requests/user/confirmation_request_spec.rb +189 -0
  174. data/spec/requests/user/omniauth_callbacks_request_spec.rb +682 -0
  175. data/spec/requests/user/otp_basic_flow_request_spec.rb +512 -0
  176. data/spec/requests/user/password_request_spec.rb +216 -0
  177. data/spec/requests/user/registration_request_spec.rb +615 -0
  178. data/spec/requests/user/session_request_spec.rb +361 -0
  179. data/spec/requests/user/unlock_request_spec.rb +208 -0
  180. data/spec/routing/admin/admin_routes_spec.rb +15 -0
  181. data/spec/routing/auth/admin_create_users_routing_spec.rb +39 -0
  182. data/spec/routing/clients_controller_routes_spec.rb +75 -0
  183. data/spec/routing/engine_routes_spec.rb +16 -0
  184. data/spec/spec_helper.rb +138 -0
  185. data/spec/support/factory_girl.rb +3 -0
  186. data/spec/support/omniauth_macros.rb +195 -0
  187. data/spec/support/payumoney_support.rb +11 -0
  188. data/spec/support/sign_in_support.rb +361 -0
  189. data/spec/support/wait_for_ajax.rb +11 -0
  190. data/spec/views/auth/admin_create_users/edit.html.erb_spec.rb +14 -0
  191. data/spec/views/auth/admin_create_users/index.html.erb_spec.rb +14 -0
  192. data/spec/views/auth/admin_create_users/new.html.erb_spec.rb +14 -0
  193. data/spec/views/auth/admin_create_users/show.html.erb_spec.rb +11 -0
  194. data/spec/views/auth/shopping/discounts/create.html.erb_spec.rb +5 -0
  195. data/spec/views/auth/shopping/discounts/destroy.html.erb_spec.rb +5 -0
  196. data/spec/views/auth/shopping/discounts/edit.html.erb_spec.rb +5 -0
  197. data/spec/views/auth/shopping/discounts/index.html.erb_spec.rb +5 -0
  198. data/spec/views/auth/shopping/discounts/new.html.erb_spec.rb +5 -0
  199. data/spec/views/auth/shopping/discounts/show.html.erb_spec.rb +5 -0
  200. data/spec/views/auth/shopping/discounts/update.html.erb_spec.rb +5 -0
  201. data/spec/views/profile/show.html.erb_spec.rb +5 -0
  202. metadata +401 -3
@@ -0,0 +1,5 @@
1
+ class Admins::SessionsController < Auth::SessionsController
2
+
3
+
4
+
5
+ end
@@ -0,0 +1,28 @@
1
+ class Admins::UnlocksController < Devise::UnlocksController
2
+ # GET /resource/unlock/new
3
+ # def new
4
+ # super
5
+ # end
6
+
7
+ # POST /resource/unlock
8
+ # def create
9
+ # super
10
+ # end
11
+
12
+ # GET /resource/unlock?unlock_token=abcdef
13
+ # def show
14
+ # super
15
+ # end
16
+
17
+ # protected
18
+
19
+ # The path used after sending unlock password instructions
20
+ # def after_sending_unlock_instructions_path_for(resource)
21
+ # super(resource)
22
+ # end
23
+
24
+ # The path used after unlocking the resource
25
+ # def after_unlock_path_for(resource)
26
+ # super(resource)
27
+ # end
28
+ end
@@ -0,0 +1,49 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+
6
+
7
+ #use this line to directly include the layout from the engine.
8
+ #layout 'auth/application'
9
+ layout 'application'
10
+ respond_to :html,:js,:json
11
+
12
+
13
+ ###NOW TESTING ALL THE PATH OVERRIDES.
14
+ ###THESE ARE OVERRIDDEN FOR ADMIN ONLY.
15
+ ##i also have to test the path helpers.
16
+ def after_sign_in_path_for(resource)
17
+ if resource.class.name.to_s == "Admin"
18
+ ##we wanna set a different path, and test that it goes there in the specs.
19
+ new_topic_path
20
+ else
21
+ super
22
+ end
23
+ end
24
+
25
+ def after_sign_out_path_for(resource)
26
+ super
27
+ end
28
+
29
+ def after_sign_up_path_for(resource)
30
+ super
31
+ end
32
+
33
+ def after_inactive_sign_up_path_for(resource)
34
+ super
35
+ end
36
+
37
+ protected
38
+
39
+ def devise_parameter_sanitizer
40
+ if resource_class == User
41
+ User::ParameterSanitizer.new(User, :user, params)
42
+ elsif resource_class == Admin
43
+ Admin::ParameterSanitizer.new(Admin,:admin,params)
44
+ else
45
+ super # Use the default one
46
+ end
47
+ end
48
+
49
+ end
@@ -0,0 +1,13 @@
1
+ class HomeController < ApplicationController
2
+ #before_action :authenticate_user!
3
+ def index
4
+
5
+ end
6
+
7
+ def send_notification
8
+ n = Noti.dummy
9
+ Auth::Notify.send_notification(n)
10
+ end
11
+
12
+
13
+ end
@@ -0,0 +1,3 @@
1
+ class OtpController < Auth::ApplicationController
2
+ include Auth::Concerns::OtpConcern
3
+ end
@@ -0,0 +1,28 @@
1
+ class Shopping::CartItemsController < Auth::Shopping::CartItemsController
2
+
3
+ =begin
4
+ def index
5
+ cart_item_params = permitted_params.fetch(:cart_item,{})
6
+ if pub = cart_item_params[:public]
7
+ @cart_items = @cart_item_class.find_cart_items({:resource => lookup_resource,:pub => pub}).page 1
8
+ else
9
+ super
10
+ end
11
+ end
12
+
13
+ def show
14
+ cart_item = permitted_params.fetch(:cart_item,{})
15
+ if pub = cart_item[:public]
16
+ options = {:cart_item_id => permitted_params[:id], :resource => lookup_resource, :pub => pub}
17
+ @cart_item = @cart_item_class.find_cart_item(options)
18
+ else
19
+ super
20
+ end
21
+ end
22
+
23
+ =end
24
+ def permitted_params
25
+ super.deep_merge(params.permit({cart_item: [:description,:sample_type]}))
26
+ end
27
+
28
+ end
@@ -0,0 +1,4 @@
1
+ class Shopping::CartsController < Auth::Shopping::CartsController
2
+
3
+
4
+ end
@@ -0,0 +1,3 @@
1
+ class Shopping::DiscountsController < Auth::Shopping::DiscountsController
2
+
3
+ end
@@ -0,0 +1,5 @@
1
+ class Shopping::PaymentsController < Auth::Shopping::PaymentsController
2
+
3
+ include Auth::Concerns::Shopping::PayUMoneyControllerConcern
4
+
5
+ end
@@ -0,0 +1,2 @@
1
+ class Shopping::ProductsController < Auth::Shopping::ProductsController
2
+ end
@@ -0,0 +1,58 @@
1
+ class TestsController < ApplicationController
2
+ before_action :set_test, only: [:show, :edit, :update, :destroy]
3
+
4
+ # GET /tests
5
+ def index
6
+ @tests = Test.all.page 1
7
+ end
8
+
9
+ # GET /tests/1
10
+ def show
11
+ end
12
+
13
+ # GET /tests/new
14
+ def new
15
+ @test = Test.new
16
+ end
17
+
18
+ # GET /tests/1/edit
19
+ def edit
20
+ end
21
+
22
+ # POST /tests
23
+ def create
24
+ @test = Test.new(test_params)
25
+
26
+ if @test.save
27
+ redirect_to @test, notice: 'Test was successfully created.'
28
+ else
29
+ render :new
30
+ end
31
+ end
32
+
33
+ # PATCH/PUT /tests/1
34
+ def update
35
+ if @test.update(test_params)
36
+ redirect_to @test, notice: 'Test was successfully updated.'
37
+ else
38
+ render :edit
39
+ end
40
+ end
41
+
42
+ # DELETE /tests/1
43
+ def destroy
44
+ @test.destroy
45
+ redirect_to tests_url, notice: 'Test was successfully destroyed.'
46
+ end
47
+
48
+ private
49
+ # Use callbacks to share common setup or constraints between actions.
50
+ def set_test
51
+ @test = Test.find(params[:id])
52
+ end
53
+
54
+ # Only allow a trusted parameter "white list" through.
55
+ def test_params
56
+ params.require(:test).permit(:price, :name)
57
+ end
58
+ end
@@ -0,0 +1,63 @@
1
+ class TopicsController < ApplicationController
2
+ include Auth::Concerns::TokenConcern
3
+ respond_to :html, :json
4
+ before_action :set_topic, only: [:show, :edit, :update, :destroy]
5
+
6
+ # GET /topics
7
+ def index
8
+ #redirect_to "http://www.google.com"
9
+
10
+ @topics = Topic.all
11
+ end
12
+
13
+ # GET /topics/1
14
+ def show
15
+ end
16
+
17
+ # GET /topics/new
18
+ def new
19
+ @topic = Topic.new
20
+ respond_with @topic
21
+ end
22
+
23
+ # GET /topics/1/edit
24
+ def edit
25
+ end
26
+
27
+ # POST /topics
28
+ def create
29
+ @topic = Topic.new(topic_params)
30
+
31
+ if @topic.save
32
+ redirect_to @topic, notice: 'Topic was successfully created.'
33
+ else
34
+ render :new
35
+ end
36
+ end
37
+
38
+ # PATCH/PUT /topics/1
39
+ def update
40
+ if @topic.update(topic_params)
41
+ redirect_to @topic, notice: 'Topic was successfully updated.'
42
+ else
43
+ render :edit
44
+ end
45
+ end
46
+
47
+ # DELETE /topics/1
48
+ def destroy
49
+ @topic.destroy
50
+ redirect_to topics_url, notice: 'Topic was successfully destroyed.'
51
+ end
52
+
53
+ private
54
+ # Use callbacks to share common setup or constraints between actions.
55
+ def set_topic
56
+ @topic = Topic.find(params[:id])
57
+ end
58
+
59
+ # Only allow a trusted parameter "white list" through.
60
+ def topic_params
61
+ params.require(:topic).permit(:name, :place)
62
+ end
63
+ end
@@ -0,0 +1,3 @@
1
+ class Users::SessionsController < Auth::SessionsController
2
+
3
+ end
@@ -0,0 +1,13 @@
1
+ class WebhooksController < Auth::WebhooksController
2
+ def sms_webhook
3
+ ## send to a background job in the respective module.
4
+ OtpJob.perform_later([nil,nil,"sms_webhook",JSON.generate(params)])
5
+ render :nothing => true, :status => 200
6
+ end
7
+
8
+ def email_webhook
9
+ ## send to a background job in the respective module.
10
+ OtpJob.perform_later([nil,nil,"email_webhook",JSON.generate(params)])
11
+ render :nothing => true, :status => 200
12
+ end
13
+ end
@@ -0,0 +1,2 @@
1
+ module ActivityHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module Api::V1::TokenAuthHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module HomeHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module TestsHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module TopicsHelper
2
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: "from@example.com"
3
+ layout 'mailer'
4
+ end
@@ -0,0 +1,3 @@
1
+ class New < Auth::Notifier
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ class Activity
2
+ include Auth::Concerns::ActivityConcern
3
+ end
@@ -0,0 +1,12 @@
1
+ class Admin
2
+ include Mongoid::Document
3
+ include Auth::Concerns::UserConcern
4
+ field :name, type: String
5
+ field :admin, type: Boolean, default: true
6
+
7
+ def send_devise_notification(notification, *args)
8
+ devise_mailer.send(notification, self, *args).deliver_later
9
+ end
10
+
11
+
12
+ end
@@ -0,0 +1,48 @@
1
+ class Noti
2
+ include Auth::Concerns::NotificationConcern
3
+ def format_for_sms(resource)
4
+ ## in our case we are using two factor so it needs some parameters to be sent in.
5
+ ## it expects:
6
+ ## to_number,template_name,var_hash,template_sender_id
7
+ ## so here we return an array of arguments.
8
+ response = {}
9
+ response[:to_number] = resource.additional_login_param
10
+
11
+ ## the following three are things which will be specific to the template configured in twofactor.
12
+ response[:template_name] = "test2"
13
+ response[:var_hash] = {var1: resource.id.to_s, var2: objects[:payment_id]}
14
+ response[:template_sender_id] = "PATHOF"
15
+
16
+ response
17
+ end
18
+
19
+ def send_sms_background(resource)
20
+
21
+ job_arguments = [resource.class.name.to_s,resource.id.to_s,"send_transactional_sms",JSON.generate({:notification_id => self.id.to_s, :notification_class => self.class.name.to_s})]
22
+ #Auth::SidekiqUp.sidekiq_running(JSON.generate(job_arguments)) do
23
+ k = OtpJob.perform_later(job_arguments)
24
+ puts "send sms background : perform_later returns: #{k.to_s}"
25
+ #end
26
+ end
27
+
28
+
29
+ def send_email_background(resource)
30
+ job_arguments = [resource.class.name.to_s,resource.id.to_s,"send_email",JSON.generate({:notification_id => self.id.to_s, :notification_class => self.class.name.to_s})]
31
+ #Auth::SidekiqUp.sidekiq_running(JSON.generate(job_arguments)) do
32
+ k = OtpJob.perform_later(job_arguments)
33
+ puts "send email background : perform_later returns: #{k.to_s}"
34
+ #end
35
+ end
36
+
37
+
38
+ ########################### TEST METHODS ####################
39
+ def self.dummy
40
+ n = Noti.new
41
+ resource_ids = {}
42
+ resource_ids[User.name] = ["59a5405c421aa90f732c9059"]
43
+ n.resource_ids = JSON.generate(resource_ids)
44
+ n.save
45
+ n
46
+ end
47
+
48
+ end
@@ -0,0 +1,9 @@
1
+ class NotiResponse
2
+ include Auth::Concerns::NotificationResponseConcern
3
+
4
+ def set_webhook_identifier(response)
5
+ Auth::Mailgun.set_webhook_identifier(self,response)
6
+ Auth::TwoFactorOtp.set_webhook_identifier(self,response)
7
+ end
8
+
9
+ end
@@ -0,0 +1,3 @@
1
+ class Shopping::Cart < Auth::Shopping::Cart
2
+
3
+ end
@@ -0,0 +1,7 @@
1
+ class Shopping::CartItem < Auth::Shopping::CartItem
2
+
3
+
4
+ create_es_index(INDEX_DEFINITION)
5
+
6
+
7
+ end
@@ -0,0 +1,3 @@
1
+ class Shopping::Discount < Auth::Shopping::Discount
2
+
3
+ end
@@ -0,0 +1,16 @@
1
+ require "auth/notify"
2
+ class Shopping::Payment < Auth::Shopping::Payment
3
+ include Auth::Concerns::Shopping::PayUMoneyConcern
4
+ include Auth::Notify
5
+ =begin
6
+ after_save do |document|
7
+ notification = Noti.new
8
+ resource_ids = {}
9
+ resource_ids[User.name] = [document.resource_id]
10
+ notification.resource_ids = JSON.generate(resource_ids)
11
+ notification.objects[:payment_id] = document.id.to_s
12
+ notification.save
13
+ Auth::Notify.send_notification(notification)
14
+ end
15
+ =end
16
+ end