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
@@ -0,0 +1,26 @@
|
|
1
|
+
/***
|
2
|
+
get rid of the ghastly yellow background color that chrome adds when autofilling forms.
|
3
|
+
**/
|
4
|
+
input:-webkit-autofill,
|
5
|
+
input:-webkit-autofill:hover,
|
6
|
+
input:-webkit-autofill:focus,
|
7
|
+
input:-webkit-autofill:active {
|
8
|
+
transition: background-color 5000s ease-in-out 0s;
|
9
|
+
}
|
10
|
+
|
11
|
+
input[type=submit] {
|
12
|
+
-webkit-appearance: none !important;
|
13
|
+
}
|
14
|
+
|
15
|
+
label{
|
16
|
+
width:100%;
|
17
|
+
left:0px !important;
|
18
|
+
}
|
19
|
+
|
20
|
+
.spinner-layer{
|
21
|
+
border-color: white !important;
|
22
|
+
}
|
23
|
+
|
24
|
+
.g-recaptcha{
|
25
|
+
display:inline-block;
|
26
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
/***
|
2
|
+
eg of importing font and using it in a css file.
|
3
|
+
@import url(http://fonts.googleapis.com/css?family=Lato:300,400,700);
|
4
|
+
body {
|
5
|
+
font-family: 'Lato', Calibri, Arial, sans-serif;
|
6
|
+
background: #f9f9f9 url(../images/bg.jpg);
|
7
|
+
font-weight: 300;
|
8
|
+
font-size: 15px;
|
9
|
+
color: #333;
|
10
|
+
height: 100%;
|
11
|
+
}
|
12
|
+
****/
|
13
|
+
|
14
|
+
.shadow{
|
15
|
+
display: block;
|
16
|
+
width: 250px;
|
17
|
+
height: 250px;
|
18
|
+
margin: 1em auto;
|
19
|
+
background-size: cover;
|
20
|
+
background-repeat: no-repeat;
|
21
|
+
background-position: center center;
|
22
|
+
-webkit-border-radius: 99em;
|
23
|
+
-moz-border-radius: 99em;
|
24
|
+
border-radius: 99em;
|
25
|
+
border: 5px solid #eee;
|
26
|
+
box-shadow: 0 3px 2px rgba(0, 0, 0, 0.3);
|
27
|
+
}
|
28
|
+
|
29
|
+
|
30
|
+
.helper{
|
31
|
+
display: inline-block;
|
32
|
+
height: 100%;
|
33
|
+
vertical-align: middle;
|
34
|
+
}
|
35
|
+
|
36
|
+
.calendar_day_background_image{
|
37
|
+
width: 100%;
|
38
|
+
height: auto;
|
39
|
+
vertical-align:middle;
|
40
|
+
}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
2
|
+
|
3
|
+
body, p, ol, ul, td {
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
+
font-size: 13px;
|
6
|
+
line-height: 18px;
|
7
|
+
}
|
8
|
+
|
9
|
+
pre {
|
10
|
+
background-color: #eee;
|
11
|
+
padding: 10px;
|
12
|
+
font-size: 11px;
|
13
|
+
}
|
14
|
+
|
15
|
+
a { color: #000; }
|
16
|
+
a:visited { color: #666; }
|
17
|
+
a:hover { color: #fff; background-color:#000; }
|
18
|
+
|
19
|
+
div.field, div.actions {
|
20
|
+
margin-bottom: 10px;
|
21
|
+
}
|
22
|
+
|
23
|
+
#notice {
|
24
|
+
color: green;
|
25
|
+
}
|
26
|
+
|
27
|
+
.field_with_errors {
|
28
|
+
padding: 2px;
|
29
|
+
background-color: red;
|
30
|
+
display: table;
|
31
|
+
}
|
32
|
+
|
33
|
+
#error_explanation {
|
34
|
+
width: 450px;
|
35
|
+
border: 2px solid red;
|
36
|
+
padding: 7px;
|
37
|
+
padding-bottom: 0;
|
38
|
+
margin-bottom: 20px;
|
39
|
+
background-color: #f0f0f0;
|
40
|
+
}
|
41
|
+
|
42
|
+
#error_explanation h2 {
|
43
|
+
text-align: left;
|
44
|
+
font-weight: bold;
|
45
|
+
padding: 5px 5px 5px 15px;
|
46
|
+
font-size: 12px;
|
47
|
+
margin: -7px;
|
48
|
+
margin-bottom: 0px;
|
49
|
+
background-color: #c00;
|
50
|
+
color: #fff;
|
51
|
+
}
|
52
|
+
|
53
|
+
#error_explanation ul li {
|
54
|
+
font-size: 12px;
|
55
|
+
list-style: square;
|
56
|
+
}
|
@@ -0,0 +1,89 @@
|
|
1
|
+
class Auth::AdminCreateUsersController < ApplicationController
|
2
|
+
## only these actions need an authenticated user to be present for them to be executed.
|
3
|
+
CONDITIONS_FOR_TOKEN_AUTH = [:create,:update,:destroy,:edit,:new,:index,:show]
|
4
|
+
TCONDITIONS = {:only => CONDITIONS_FOR_TOKEN_AUTH}
|
5
|
+
include Auth::Concerns::DeviseConcern
|
6
|
+
include Auth::Concerns::TokenConcern
|
7
|
+
before_filter :do_before_request , TCONDITIONS
|
8
|
+
before_filter :initialize_vars , TCONDITIONS
|
9
|
+
## ensures that only admin users.
|
10
|
+
before_filter :is_admin_user , TCONDITIONS
|
11
|
+
|
12
|
+
|
13
|
+
## called before all the actions.
|
14
|
+
def initialize_vars
|
15
|
+
|
16
|
+
@auth_user_class = Auth.configuration.user_class.constantize
|
17
|
+
|
18
|
+
@auth_user_params = permitted_params.fetch(:user,{})
|
19
|
+
|
20
|
+
@auth_user = params[:id] ? @auth_user_class.find_self(params[:id],current_signed_in_resource) : @auth_user_class.new(@auth_user_params)
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
# GET /auth/admin_create_users
|
25
|
+
def index
|
26
|
+
#@auth_admin_create_users = Auth::AdminCreateUser.all
|
27
|
+
end
|
28
|
+
|
29
|
+
# GET /auth/admin_create_users/1
|
30
|
+
def show
|
31
|
+
end
|
32
|
+
|
33
|
+
# GET /auth/admin_create_users/new
|
34
|
+
def new
|
35
|
+
# what kind of form should be presented to the admin.
|
36
|
+
|
37
|
+
#@auth_admin_create_user = Auth::AdminCreateUser.new
|
38
|
+
## just render a form with the user model.
|
39
|
+
end
|
40
|
+
|
41
|
+
# GET /auth/admin_create_users/1/edit
|
42
|
+
def edit
|
43
|
+
end
|
44
|
+
|
45
|
+
# User.where(:email => "bhargav.r.raut@gmail.com").first.delete
|
46
|
+
# POST /auth/admin_create_users
|
47
|
+
def create
|
48
|
+
@auth_user.password = @auth_user.password_confirmation =SecureRandom.hex(24)
|
49
|
+
@auth_user.m_client = self.m_client
|
50
|
+
@auth_user.created_by_admin = true
|
51
|
+
|
52
|
+
## we will have to set the m_client.
|
53
|
+
## but what if that client is different from the client that was used to create the user?
|
54
|
+
## no this will not happen here.
|
55
|
+
## here we will only create.
|
56
|
+
respond_to do |format|
|
57
|
+
if @auth_user.save
|
58
|
+
if !@auth_user.additional_login_param.blank?
|
59
|
+
format.html {render "auth/confirmations/enter_otp.html.erb"}
|
60
|
+
format.json {render json: @auth_user.to_json, status: :created}
|
61
|
+
else
|
62
|
+
format.html {render "auth/admin_create_users/show.html.erb"}
|
63
|
+
format.json {render json: @auth_user.to_json, status: :created}
|
64
|
+
end
|
65
|
+
else
|
66
|
+
format.html {render "new.html.erb"}
|
67
|
+
format.json {render json: {:errors => @auth_user.errors}, status: 422}
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# PATCH/PUT /auth/admin_create_users/1
|
73
|
+
def update
|
74
|
+
## should also allow stuff like
|
75
|
+
## resend sms otp
|
76
|
+
## resend confirmation email
|
77
|
+
end
|
78
|
+
|
79
|
+
# DELETE /auth/admin_create_users/1
|
80
|
+
def destroy
|
81
|
+
@auth_admin_create_user.destroy
|
82
|
+
redirect_to auth_admin_create_users_url, notice: 'Admin create user was successfully destroyed.'
|
83
|
+
end
|
84
|
+
|
85
|
+
def permitted_params
|
86
|
+
params.permit({user: [:email,:additional_login_param, :password, :password_confirmation]},:id)
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module Auth
|
2
|
+
class ApplicationController < ::ApplicationController
|
3
|
+
|
4
|
+
protect_from_forgery with: :exception
|
5
|
+
|
6
|
+
rescue_from ActionController::RoutingError do |e|
|
7
|
+
puts "e is : #{e.to_s}"
|
8
|
+
respond_to do |format|
|
9
|
+
format.json {render json: {:errors => e.to_s}, status: 422}
|
10
|
+
format.js {render :partial => "auth/modals/resource_errors.js.erb", locals: {:errors => [e.to_s]}}
|
11
|
+
format.html {render :text => e.to_s}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def from_bson(bson_doc,klass)
|
17
|
+
|
18
|
+
if !bson_doc.nil?
|
19
|
+
|
20
|
+
user = Mongoid::Factory.from_db(klass,bson_doc)
|
21
|
+
return user
|
22
|
+
|
23
|
+
else
|
24
|
+
|
25
|
+
return nil
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
def from_view(view,klass)
|
32
|
+
|
33
|
+
if !view.nil? && view.count > 0
|
34
|
+
|
35
|
+
user = Mongoid::Factory.from_db(klass,view.first)
|
36
|
+
return user
|
37
|
+
|
38
|
+
else
|
39
|
+
|
40
|
+
return nil
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
##CURRENTLY BEING USED IN THE DUMMY APP IN OTP_CONTROLLER
|
47
|
+
##RENDERS A NOT FOUND RESPONSE, in case the user is not found.
|
48
|
+
##
|
49
|
+
def not_found(error = 'Not Found')
|
50
|
+
raise ActionController::RoutingError.new(error)
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
def check_for_update(obj)
|
56
|
+
puts "Came to check for update."
|
57
|
+
not_found if obj.nil?
|
58
|
+
not_found("please provide a valid id for the update") if obj.new_record?
|
59
|
+
end
|
60
|
+
|
61
|
+
def check_for_create(obj)
|
62
|
+
not_found if obj.nil?
|
63
|
+
obj.new_record? or not_found("this is not a new record")
|
64
|
+
end
|
65
|
+
|
66
|
+
def check_for_destroy(obj)
|
67
|
+
not_found("please provide a cart id") if obj.new_record?
|
68
|
+
end
|
69
|
+
|
70
|
+
## will call authenticate_(first_key_in_the_auth_resources) if there is no currently signed in scoep
|
71
|
+
## will return true, for the first auth_resource that gives a current_(user/whatever)
|
72
|
+
## if nothing returns true, will redirect to not_found,
|
73
|
+
## use this function wherever you want to protect a controller just using devise authentication.
|
74
|
+
## only makes sense to use in the scope of the web app.
|
75
|
+
def authenticate_resource!
|
76
|
+
send("authenticate_#{Auth.configuration.auth_resources.keys.first.downcase}!") if (signed_in? == false)
|
77
|
+
Auth.configuration.auth_resources.keys.each do |model|
|
78
|
+
break if @resource_for_web_app = send("current_#{model.downcase}")
|
79
|
+
end
|
80
|
+
return if @resource_for_web_app
|
81
|
+
not_found("Could not authenticate")
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
protected
|
89
|
+
|
90
|
+
def check_method_missing
|
91
|
+
puts Rails.application.routes.url_helpers.to_s
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require_dependency "auth/application_controller"
|
2
|
+
module Auth
|
3
|
+
class ClientsController < ApplicationController
|
4
|
+
|
5
|
+
respond_to :html
|
6
|
+
|
7
|
+
before_action :authenticate_resource!
|
8
|
+
|
9
|
+
before_action :set_client
|
10
|
+
|
11
|
+
## what if the client id is not the same as the user id.
|
12
|
+
## in that case an error should be raised.
|
13
|
+
|
14
|
+
before_action :verify_client_belongs_to_user
|
15
|
+
|
16
|
+
|
17
|
+
# GET /clients
|
18
|
+
def index
|
19
|
+
render :nothing => true, :status => 200
|
20
|
+
end
|
21
|
+
|
22
|
+
# GET /clients/1
|
23
|
+
def show
|
24
|
+
respond_with @client
|
25
|
+
end
|
26
|
+
|
27
|
+
# GET /clients/new
|
28
|
+
def new
|
29
|
+
#@client = Client.new
|
30
|
+
render :nothing => true, :status => 200
|
31
|
+
end
|
32
|
+
|
33
|
+
# GET /clients/1/edit
|
34
|
+
def edit
|
35
|
+
## edit should show forms for adding an app id.
|
36
|
+
## design the form.
|
37
|
+
end
|
38
|
+
|
39
|
+
# POST /clients
|
40
|
+
def create
|
41
|
+
render :nothing => true, :status => 200
|
42
|
+
end
|
43
|
+
|
44
|
+
# response code of 204 is ok.
|
45
|
+
# anything else means fail.
|
46
|
+
# PATCH/PUT /clients/1
|
47
|
+
def update
|
48
|
+
|
49
|
+
|
50
|
+
@client.redirect_urls << client_params[:add_redirect_url] if client_params[:add_redirect_url]
|
51
|
+
|
52
|
+
@client.app_ids << BSON::ObjectId.new.to_s if client_params[:add_app_id]
|
53
|
+
|
54
|
+
|
55
|
+
@client.versioned_update({"redirect_urls" => 1, "app_ids" => 1})
|
56
|
+
|
57
|
+
if @client.op_success?
|
58
|
+
render "show"
|
59
|
+
else
|
60
|
+
render "edit"
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
# response status of 404 or 204 is ok.
|
66
|
+
# 404 means client doesnt exist
|
67
|
+
# 204 means it was destroyed.
|
68
|
+
# DELETE /clients/1
|
69
|
+
def destroy
|
70
|
+
@client.destroy
|
71
|
+
#redirect_to clients_url, notice: 'Client was successfully destroyed.'
|
72
|
+
respond_with(status: 200)
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
# Use callbacks to share common setup or constraints between actions.
|
77
|
+
# the find method is overriden in the model, where it uses the :id (which is actually the user_id, because we have overridden the to_param method to use user_id).
|
78
|
+
def set_client
|
79
|
+
@client = Auth::Client.find(params[:id])
|
80
|
+
if @client.nil?
|
81
|
+
render :nothing => true, :status => 404
|
82
|
+
else
|
83
|
+
return
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
## if the resource_signed_in is an admin, just return
|
88
|
+
## otherwise if the user's id is not the same as the id passed in, then throw a not_found.
|
89
|
+
def verify_client_belongs_to_user
|
90
|
+
return if @resource_for_web_app.is_admin?
|
91
|
+
not_found("client does not belong to user") if @resource_for_web_app.id.to_s != params[:id]
|
92
|
+
end
|
93
|
+
|
94
|
+
# Only allow a trusted parameter "white list" through.
|
95
|
+
def client_params
|
96
|
+
params.require(:client).permit({:redirect_urls => []},{:app_ids => []}, :add_app_id, :add_redirect_url)
|
97
|
+
end
|
98
|
+
|
99
|
+
#def ensure_json_request
|
100
|
+
# return if request.format == :json
|
101
|
+
# render :nothing => true, :status => 406
|
102
|
+
#end
|
103
|
+
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Auth::Concerns::ActivityControllerConcern
|
2
|
+
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
|
7
|
+
respond_to :html,:json,:js
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
##@used_in: jquery.calendario.js
|
12
|
+
##@param[Hash] : params should have range key(which is itself a hash, and a user_id key which is a string.), {range: {"from" => date[format: ], "to" => date[format: ]}, user_id: String}
|
13
|
+
##@return[Hash]: timestamp => activity_object hashified.
|
14
|
+
def get_activities
|
15
|
+
filt_test = permitted_params
|
16
|
+
activities_hash = model.get_in_range(filt_test)
|
17
|
+
respond_with activities_hash
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
##gives the model class from the underlying controller
|
24
|
+
def model
|
25
|
+
Object.const_get(controller_name.classify)
|
26
|
+
end
|
27
|
+
|
28
|
+
def permitted_params
|
29
|
+
params.permit(:user_id, range: [:from, :to], only: [])
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|