activity_notification 2.0.0 → 2.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +22 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
- data/.github/pull_request_template.md +13 -0
- data/.gitignore +10 -3
- data/.travis.yml +6 -5
- data/CHANGELOG.md +60 -0
- data/Gemfile +8 -3
- data/Procfile +1 -1
- data/README.md +153 -1510
- data/activity_notification.gemspec +4 -1
- data/app/channels/activity_notification/notification_api_channel.rb +12 -0
- data/app/channels/activity_notification/notification_api_with_devise_channel.rb +46 -0
- data/app/channels/activity_notification/notification_channel.rb +2 -2
- data/app/channels/activity_notification/notification_with_devise_channel.rb +2 -2
- data/app/controllers/activity_notification/apidocs_controller.rb +75 -0
- data/app/controllers/activity_notification/notifications_api_controller.rb +143 -0
- data/app/controllers/activity_notification/notifications_api_with_devise_controller.rb +7 -0
- data/app/controllers/activity_notification/notifications_controller.rb +79 -53
- data/app/controllers/activity_notification/subscriptions_api_controller.rb +197 -0
- data/app/controllers/activity_notification/subscriptions_api_with_devise_controller.rb +7 -0
- data/app/controllers/activity_notification/subscriptions_controller.rb +78 -69
- data/app/views/activity_notification/notifications/default/_default.html.erb +18 -18
- data/app/views/activity_notification/notifications/default/_default_without_grouping.html.erb +14 -14
- data/app/views/activity_notification/notifications/default/index.html.erb +6 -6
- data/app/views/activity_notification/optional_targets/default/action_cable_channel/_default.html.erb +176 -0
- data/app/views/activity_notification/subscriptions/default/_form.html.erb +1 -1
- data/app/views/activity_notification/subscriptions/default/_notification_keys.html.erb +3 -31
- data/app/views/activity_notification/subscriptions/default/_subscription.html.erb +7 -7
- data/app/views/activity_notification/subscriptions/default/index.html.erb +11 -7
- data/bin/deploy_on_heroku.sh +3 -1
- data/docs/CODE_OF_CONDUCT.md +76 -0
- data/docs/CONTRIBUTING.md +36 -0
- data/docs/Functions.md +1130 -0
- data/docs/Setup.md +801 -0
- data/docs/Testing.md +148 -0
- data/gemfiles/Gemfile.rails-4.2 +5 -1
- data/gemfiles/Gemfile.rails-5.0 +6 -1
- data/gemfiles/Gemfile.rails-5.1 +6 -1
- data/gemfiles/Gemfile.rails-5.2 +6 -1
- data/gemfiles/{Gemfile.rails-6.0.rc → Gemfile.rails-6.0} +6 -5
- data/lib/activity_notification.rb +13 -0
- data/lib/activity_notification/apis/notification_api.rb +37 -93
- data/lib/activity_notification/apis/subscription_api.rb +20 -8
- data/lib/activity_notification/apis/swagger.rb +6 -0
- data/lib/activity_notification/common.rb +4 -1
- data/lib/activity_notification/config.rb +41 -21
- data/lib/activity_notification/controllers/common_api_controller.rb +30 -0
- data/lib/activity_notification/controllers/common_controller.rb +45 -21
- data/lib/activity_notification/controllers/concerns/swagger/error_responses.rb +55 -0
- data/lib/activity_notification/controllers/concerns/swagger/notifications_api.rb +273 -0
- data/lib/activity_notification/controllers/concerns/swagger/notifications_parameters.rb +92 -0
- data/lib/activity_notification/controllers/concerns/swagger/subscriptions_api.rb +405 -0
- data/lib/activity_notification/controllers/concerns/swagger/subscriptions_parameters.rb +50 -0
- data/lib/activity_notification/controllers/devise_authentication_controller.rb +7 -6
- data/lib/activity_notification/gem_version.rb +14 -0
- data/lib/activity_notification/helpers/errors.rb +2 -0
- data/lib/activity_notification/helpers/view_helpers.rb +4 -0
- data/lib/activity_notification/mailers/helpers.rb +17 -10
- data/lib/activity_notification/models/concerns/notifiable.rb +31 -15
- data/lib/activity_notification/models/concerns/subscriber.rb +12 -1
- data/lib/activity_notification/models/concerns/swagger/error_schema.rb +36 -0
- data/lib/activity_notification/models/concerns/swagger/notification_schema.rb +209 -0
- data/lib/activity_notification/models/concerns/swagger/subscription_schema.rb +162 -0
- data/lib/activity_notification/models/concerns/target.rb +36 -10
- data/lib/activity_notification/models/notification.rb +1 -0
- data/lib/activity_notification/models/subscription.rb +1 -0
- data/lib/activity_notification/optional_targets/action_cable_api_channel.rb +69 -0
- data/lib/activity_notification/optional_targets/action_cable_channel.rb +68 -0
- data/lib/activity_notification/optional_targets/base.rb +7 -13
- data/lib/activity_notification/orm/active_record/notification.rb +17 -1
- data/lib/activity_notification/orm/active_record/subscription.rb +1 -1
- data/lib/activity_notification/orm/dynamoid.rb +38 -3
- data/lib/activity_notification/orm/dynamoid/extension.rb +79 -1
- data/lib/activity_notification/orm/dynamoid/notification.rb +49 -14
- data/lib/activity_notification/orm/dynamoid/subscription.rb +2 -2
- data/lib/activity_notification/orm/mongoid.rb +32 -3
- data/lib/activity_notification/orm/mongoid/notification.rb +24 -6
- data/lib/activity_notification/orm/mongoid/subscription.rb +1 -1
- data/lib/activity_notification/rails/routes.rb +132 -48
- data/lib/activity_notification/renderable.rb +13 -2
- data/lib/activity_notification/roles/acts_as_notifiable.rb +39 -20
- data/lib/activity_notification/version.rb +1 -1
- data/lib/generators/activity_notification/controllers_generator.rb +2 -1
- data/lib/generators/templates/activity_notification.rb +8 -0
- data/lib/generators/templates/controllers/notifications_api_controller.rb +31 -0
- data/lib/generators/templates/controllers/notifications_api_with_devise_controller.rb +31 -0
- data/lib/generators/templates/controllers/notifications_controller.rb +1 -37
- data/lib/generators/templates/controllers/notifications_with_devise_controller.rb +1 -45
- data/lib/generators/templates/controllers/subscriptions_api_controller.rb +61 -0
- data/lib/generators/templates/controllers/subscriptions_api_with_devise_controller.rb +61 -0
- data/lib/generators/templates/controllers/subscriptions_controller.rb +14 -37
- data/lib/generators/templates/controllers/subscriptions_with_devise_controller.rb +14 -45
- data/lib/generators/templates/models/README +8 -4
- data/lib/generators/templates/models/notification.rb +1 -1
- data/lib/generators/templates/models/subscription.rb +1 -1
- data/package.json +8 -0
- data/spec/channels/notification_api_channel_shared_examples.rb +59 -0
- data/spec/channels/notification_api_channel_spec.rb +51 -0
- data/spec/channels/notification_api_with_devise_channel_spec.rb +78 -0
- data/spec/concerns/apis/notification_api_spec.rb +38 -3
- data/spec/concerns/models/notifiable_spec.rb +82 -18
- data/spec/concerns/models/subscriber_spec.rb +13 -16
- data/spec/concerns/models/target_spec.rb +32 -0
- data/spec/concerns/renderable_spec.rb +2 -2
- data/spec/config_spec.rb +26 -15
- data/spec/controllers/controller_spec_utility.rb +136 -0
- data/spec/controllers/notifications_api_controller_shared_examples.rb +506 -0
- data/spec/controllers/notifications_api_controller_spec.rb +19 -0
- data/spec/controllers/notifications_api_with_devise_controller_spec.rb +60 -0
- data/spec/controllers/notifications_controller_shared_examples.rb +54 -79
- data/spec/controllers/notifications_controller_spec.rb +1 -2
- data/spec/controllers/notifications_with_devise_controller_spec.rb +3 -12
- data/spec/controllers/subscriptions_api_controller_shared_examples.rb +750 -0
- data/spec/controllers/subscriptions_api_controller_spec.rb +19 -0
- data/spec/controllers/subscriptions_api_with_devise_controller_spec.rb +60 -0
- data/spec/controllers/subscriptions_controller_shared_examples.rb +94 -121
- data/spec/controllers/subscriptions_controller_spec.rb +1 -2
- data/spec/controllers/subscriptions_with_devise_controller_spec.rb +3 -12
- data/spec/helpers/view_helpers_spec.rb +4 -11
- data/spec/mailers/mailer_spec.rb +41 -0
- data/spec/models/notification_spec.rb +17 -0
- data/spec/models/subscription_spec.rb +8 -13
- data/spec/optional_targets/action_cable_api_channel_spec.rb +37 -0
- data/spec/optional_targets/action_cable_channel_spec.rb +44 -0
- data/spec/optional_targets/amazon_sns_spec.rb +0 -2
- data/spec/optional_targets/slack_spec.rb +0 -2
- data/spec/rails_app/Rakefile +9 -0
- data/spec/rails_app/app/assets/config/manifest.js +3 -0
- data/spec/rails_app/app/assets/images/.keep +0 -0
- data/spec/rails_app/app/controllers/admins_controller.rb +21 -0
- data/spec/rails_app/app/controllers/application_controller.rb +1 -1
- data/spec/rails_app/app/controllers/articles_controller.rb +6 -3
- data/spec/rails_app/app/controllers/spa_controller.rb +7 -0
- data/spec/rails_app/app/controllers/users/notifications_controller.rb +0 -65
- data/spec/rails_app/app/controllers/users/notifications_with_devise_controller.rb +0 -73
- data/spec/rails_app/app/controllers/users/subscriptions_controller.rb +0 -77
- data/spec/rails_app/app/controllers/users/subscriptions_with_devise_controller.rb +0 -85
- data/spec/rails_app/app/controllers/users_controller.rb +26 -0
- data/spec/rails_app/app/javascript/App.vue +40 -0
- data/spec/rails_app/app/javascript/components/DeviseTokenAuth.vue +82 -0
- data/spec/rails_app/app/javascript/components/Top.vue +98 -0
- data/spec/rails_app/app/javascript/components/notifications/Index.vue +200 -0
- data/spec/rails_app/app/javascript/components/notifications/Notification.vue +133 -0
- data/spec/rails_app/app/javascript/components/notifications/NotificationContent.vue +122 -0
- data/spec/rails_app/app/javascript/components/subscriptions/Index.vue +279 -0
- data/spec/rails_app/app/javascript/components/subscriptions/NewSubscription.vue +112 -0
- data/spec/rails_app/app/javascript/components/subscriptions/NotificationKey.vue +141 -0
- data/spec/rails_app/app/javascript/components/subscriptions/Subscription.vue +226 -0
- data/spec/rails_app/app/javascript/config/development.js +5 -0
- data/spec/rails_app/app/javascript/config/environment.js +7 -0
- data/spec/rails_app/app/javascript/config/production.js +5 -0
- data/spec/rails_app/app/javascript/config/test.js +5 -0
- data/spec/rails_app/app/javascript/packs/application.js +18 -0
- data/spec/rails_app/app/javascript/packs/spa.js +14 -0
- data/spec/rails_app/app/javascript/router/index.js +73 -0
- data/spec/rails_app/app/javascript/store/index.js +37 -0
- data/spec/rails_app/app/models/admin.rb +16 -15
- data/spec/rails_app/app/models/article.rb +26 -21
- data/spec/rails_app/app/models/comment.rb +24 -71
- data/spec/rails_app/app/models/dummy/dummy_group.rb +8 -0
- data/spec/rails_app/app/models/dummy/dummy_notifiable_target.rb +8 -0
- data/spec/rails_app/app/models/user.rb +44 -20
- data/spec/rails_app/app/views/activity_notification/notifications/default/article/_update.html.erb +146 -0
- data/spec/rails_app/app/views/articles/index.html.erb +51 -7
- data/spec/rails_app/app/views/articles/show.html.erb +1 -1
- data/spec/rails_app/app/views/layouts/_header.html.erb +8 -10
- data/spec/rails_app/app/views/spa/index.html.erb +2 -0
- data/spec/rails_app/babel.config.js +72 -0
- data/spec/rails_app/bin/webpack +18 -0
- data/spec/rails_app/bin/webpack-dev-server +18 -0
- data/spec/rails_app/config/application.rb +18 -2
- data/spec/rails_app/config/dynamoid.rb +11 -3
- data/spec/rails_app/config/environment.rb +2 -1
- data/spec/rails_app/config/environments/development.rb +5 -0
- data/spec/rails_app/config/environments/production.rb +6 -0
- data/spec/rails_app/config/environments/test.rb +5 -0
- data/spec/rails_app/config/initializers/activity_notification.rb +11 -3
- data/spec/rails_app/config/initializers/copy_it.aws.rb.template +6 -0
- data/spec/rails_app/config/initializers/devise_token_auth.rb +55 -0
- data/spec/rails_app/config/initializers/mysql.rb +9 -0
- data/spec/rails_app/config/locales/activity_notification.en.yml +2 -2
- data/spec/rails_app/config/routes.rb +37 -1
- data/spec/rails_app/config/webpack/development.js +5 -0
- data/spec/rails_app/config/webpack/environment.js +7 -0
- data/spec/rails_app/config/webpack/loaders/vue.js +6 -0
- data/spec/rails_app/config/webpack/production.js +5 -0
- data/spec/rails_app/config/webpack/test.js +5 -0
- data/spec/rails_app/config/webpacker.yml +97 -0
- data/spec/rails_app/db/migrate/20191201000000_add_tokens_to_users.rb +10 -0
- data/spec/rails_app/db/schema.rb +4 -1
- data/spec/rails_app/db/seeds.rb +10 -2
- data/spec/rails_app/lib/custom_optional_targets/raise_error.rb +14 -0
- data/spec/rails_app/package.json +23 -0
- data/spec/rails_app/postcss.config.js +12 -0
- data/spec/roles/acts_as_group_spec.rb +0 -2
- data/spec/roles/acts_as_notifiable_spec.rb +6 -8
- data/spec/roles/acts_as_notifier_spec.rb +0 -2
- data/spec/roles/acts_as_target_spec.rb +0 -4
- data/spec/spec_helper.rb +7 -15
- data/spec/version_spec.rb +31 -0
- metadata +191 -13
@@ -1,75 +1,2 @@
|
|
1
1
|
class Users::NotificationsWithDeviseController < ActivityNotification::NotificationsWithDeviseController
|
2
|
-
# GET /:target_type/:target_id/notifications
|
3
|
-
# def index
|
4
|
-
# super
|
5
|
-
# end
|
6
|
-
|
7
|
-
# POST /:target_type/:target_id/notifications/open_all
|
8
|
-
# def open_all
|
9
|
-
# super
|
10
|
-
# end
|
11
|
-
|
12
|
-
# GET /:target_type/:target_id/notifications/:id
|
13
|
-
# def show
|
14
|
-
# super
|
15
|
-
# end
|
16
|
-
|
17
|
-
# DELETE /:target_type/:target_id/notifications/:id
|
18
|
-
# def destroy
|
19
|
-
# super
|
20
|
-
# end
|
21
|
-
|
22
|
-
# POST /:target_type/:target_id/notifications/:id/open
|
23
|
-
# def open
|
24
|
-
# super
|
25
|
-
# end
|
26
|
-
|
27
|
-
# GET /:target_type/:target_id/notifications/:id/move
|
28
|
-
# def move
|
29
|
-
# super
|
30
|
-
# end
|
31
|
-
|
32
|
-
# No action routing
|
33
|
-
# This method needs to be public since it is called from view helper
|
34
|
-
# def target_view_path
|
35
|
-
# super
|
36
|
-
# end
|
37
|
-
|
38
|
-
# protected
|
39
|
-
|
40
|
-
# def set_target
|
41
|
-
# super
|
42
|
-
# end
|
43
|
-
|
44
|
-
# def set_notification
|
45
|
-
# super
|
46
|
-
# end
|
47
|
-
|
48
|
-
# def set_index_options
|
49
|
-
# super
|
50
|
-
# end
|
51
|
-
|
52
|
-
# def load_notification_index(options = {})
|
53
|
-
# super(options)
|
54
|
-
# end
|
55
|
-
|
56
|
-
# def controller_path
|
57
|
-
# super
|
58
|
-
# end
|
59
|
-
|
60
|
-
# def set_view_prefixes
|
61
|
-
# super
|
62
|
-
# end
|
63
|
-
|
64
|
-
# def return_back_or_ajax
|
65
|
-
# super
|
66
|
-
# end
|
67
|
-
|
68
|
-
# def authenticate_devise_resource!
|
69
|
-
# super
|
70
|
-
# end
|
71
|
-
|
72
|
-
# def authenticate_target!
|
73
|
-
# super
|
74
|
-
# end
|
75
2
|
end
|
@@ -1,79 +1,2 @@
|
|
1
1
|
class Users::SubscriptionsController < ActivityNotification::SubscriptionsController
|
2
|
-
# GET /:target_type/:target_id/subscriptions
|
3
|
-
# def index
|
4
|
-
# super
|
5
|
-
# end
|
6
|
-
|
7
|
-
# POST /:target_type/:target_id/subscriptions
|
8
|
-
# def create
|
9
|
-
# super
|
10
|
-
# end
|
11
|
-
|
12
|
-
# GET /:target_type/:target_id/subscriptions/:id
|
13
|
-
# def show
|
14
|
-
# super
|
15
|
-
# end
|
16
|
-
|
17
|
-
# DELETE /:target_type/:target_id/subscriptions/:id
|
18
|
-
# def destroy
|
19
|
-
# super
|
20
|
-
# end
|
21
|
-
|
22
|
-
# POST /:target_type/:target_id/subscriptions/:id/subscribe
|
23
|
-
# def subscribe
|
24
|
-
# super
|
25
|
-
# end
|
26
|
-
|
27
|
-
# POST /:target_type/:target_id/subscriptions/:id/unsubscribe
|
28
|
-
# def unsubscribe
|
29
|
-
# super
|
30
|
-
# end
|
31
|
-
|
32
|
-
# POST /:target_type/:target_id/subscriptions/:id/subscribe_to_email
|
33
|
-
# def subscribe_to_email
|
34
|
-
# super
|
35
|
-
# end
|
36
|
-
|
37
|
-
# POST /:target_type/:target_id/subscriptions/:id/unsubscribe_to_email
|
38
|
-
# def unsubscribe_to_email
|
39
|
-
# super
|
40
|
-
# end
|
41
|
-
|
42
|
-
# protected
|
43
|
-
|
44
|
-
# def set_target
|
45
|
-
# super
|
46
|
-
# end
|
47
|
-
|
48
|
-
# def set_subscription
|
49
|
-
# super
|
50
|
-
# end
|
51
|
-
|
52
|
-
# def subscription_params
|
53
|
-
# super
|
54
|
-
# end
|
55
|
-
|
56
|
-
# def set_index_options
|
57
|
-
# super
|
58
|
-
# end
|
59
|
-
|
60
|
-
# def load_subscription_index(options = {})
|
61
|
-
# super(options)
|
62
|
-
# end
|
63
|
-
|
64
|
-
# def controller_path
|
65
|
-
# super
|
66
|
-
# end
|
67
|
-
|
68
|
-
# def target_view_path
|
69
|
-
# super
|
70
|
-
# end
|
71
|
-
|
72
|
-
# def set_view_prefixes
|
73
|
-
# super
|
74
|
-
# end
|
75
|
-
|
76
|
-
# def return_back_or_ajax
|
77
|
-
# super
|
78
|
-
# end
|
79
2
|
end
|
@@ -1,87 +1,2 @@
|
|
1
1
|
class Users::SubscriptionsWithDeviseController < ActivityNotification::SubscriptionsWithDeviseController
|
2
|
-
# GET /:target_type/:target_id/subscriptions
|
3
|
-
# def index
|
4
|
-
# super
|
5
|
-
# end
|
6
|
-
|
7
|
-
# POST /:target_type/:target_id/subscriptions
|
8
|
-
# def create
|
9
|
-
# super
|
10
|
-
# end
|
11
|
-
|
12
|
-
# GET /:target_type/:target_id/subscriptions/:id
|
13
|
-
# def show
|
14
|
-
# super
|
15
|
-
# end
|
16
|
-
|
17
|
-
# DELETE /:target_type/:target_id/subscriptions/:id
|
18
|
-
# def destroy
|
19
|
-
# super
|
20
|
-
# end
|
21
|
-
|
22
|
-
# POST /:target_type/:target_id/subscriptions/:id/subscribe
|
23
|
-
# def subscribe
|
24
|
-
# super
|
25
|
-
# end
|
26
|
-
|
27
|
-
# POST /:target_type/:target_id/subscriptions/:id/unsubscribe
|
28
|
-
# def unsubscribe
|
29
|
-
# super
|
30
|
-
# end
|
31
|
-
|
32
|
-
# POST /:target_type/:target_id/subscriptions/:id/subscribe_to_email
|
33
|
-
# def subscribe_to_email
|
34
|
-
# super
|
35
|
-
# end
|
36
|
-
|
37
|
-
# POST /:target_type/:target_id/subscriptions/:id/unsubscribe_to_email
|
38
|
-
# def unsubscribe_to_email
|
39
|
-
# super
|
40
|
-
# end
|
41
|
-
|
42
|
-
# protected
|
43
|
-
|
44
|
-
# def set_target
|
45
|
-
# super
|
46
|
-
# end
|
47
|
-
|
48
|
-
# def set_subscription
|
49
|
-
# super
|
50
|
-
# end
|
51
|
-
|
52
|
-
# def subscription_params
|
53
|
-
# super
|
54
|
-
# end
|
55
|
-
|
56
|
-
# def set_index_options
|
57
|
-
# super
|
58
|
-
# end
|
59
|
-
|
60
|
-
# def load_subscription_index(options = {})
|
61
|
-
# super(options)
|
62
|
-
# end
|
63
|
-
|
64
|
-
# def controller_path
|
65
|
-
# super
|
66
|
-
# end
|
67
|
-
|
68
|
-
# def target_view_path
|
69
|
-
# super
|
70
|
-
# end
|
71
|
-
|
72
|
-
# def set_view_prefixes
|
73
|
-
# super
|
74
|
-
# end
|
75
|
-
|
76
|
-
# def return_back_or_ajax
|
77
|
-
# super
|
78
|
-
# end
|
79
|
-
|
80
|
-
# def authenticate_devise_resource!
|
81
|
-
# super
|
82
|
-
# end
|
83
|
-
|
84
|
-
# def authenticate_target!
|
85
|
-
# super
|
86
|
-
# end
|
87
2
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class UsersController < ApplicationController
|
2
|
+
before_action :set_user, only: [:show]
|
3
|
+
|
4
|
+
# GET /users
|
5
|
+
def index
|
6
|
+
render json: {
|
7
|
+
users: User.all
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
# GET /users/:id
|
12
|
+
def show
|
13
|
+
render json: @user
|
14
|
+
end
|
15
|
+
|
16
|
+
# GET /users/find
|
17
|
+
def find
|
18
|
+
render json: User.find_by_email!(params[:email])
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
# Use callbacks to share common setup or constraints between actions.
|
23
|
+
def set_user
|
24
|
+
@user = User.find(params[:id])
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<template>
|
2
|
+
<div>
|
3
|
+
<router-view />
|
4
|
+
</div>
|
5
|
+
</template>
|
6
|
+
|
7
|
+
<script>
|
8
|
+
import Vue from 'vue'
|
9
|
+
import VueMoment from 'vue-moment'
|
10
|
+
import moment from 'moment-timezone'
|
11
|
+
import VuePluralize from 'vue-pluralize'
|
12
|
+
import ActionCableVue from 'actioncable-vue'
|
13
|
+
import axios from 'axios'
|
14
|
+
import env from './config/environment'
|
15
|
+
|
16
|
+
axios.defaults.baseURL = "/api/v2"
|
17
|
+
|
18
|
+
Vue.use(VueMoment, { moment })
|
19
|
+
Vue.use(VuePluralize)
|
20
|
+
Vue.use(ActionCableVue, {
|
21
|
+
debug: true,
|
22
|
+
debugLevel: 'error',
|
23
|
+
connectionUrl: env.ACTION_CABLE_CONNECTION_URL,
|
24
|
+
connectImmediately: true
|
25
|
+
})
|
26
|
+
|
27
|
+
export default {
|
28
|
+
name: 'App',
|
29
|
+
mounted () {
|
30
|
+
if (this.$store.getters.userSignedIn) {
|
31
|
+
for (var authHeader of Object.keys(this.$store.getters.authHeaders)) {
|
32
|
+
axios.defaults.headers.common[authHeader] = this.$store.getters.authHeaders[authHeader];
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
</script>
|
38
|
+
|
39
|
+
<style scoped>
|
40
|
+
</style>
|
@@ -0,0 +1,82 @@
|
|
1
|
+
<template>
|
2
|
+
<div id="login">
|
3
|
+
<h2>Log in</h2>
|
4
|
+
<form class="new_user" @submit.prevent="login">
|
5
|
+
<div class="field">
|
6
|
+
<label for="user_email">Email</label><br />
|
7
|
+
<input v-model="loginParams.email" autofocus="autofocus" autocomplete="email" type="email" value="" name="user[email]" id="user_email" />
|
8
|
+
</div>
|
9
|
+
<div class="field">
|
10
|
+
<label for="user_password">Password</label><br />
|
11
|
+
<input v-model="loginParams.password" autocomplete="current-password" type="password" name="user[password]" id="user_password" />
|
12
|
+
</div>
|
13
|
+
<div class="actions">
|
14
|
+
<input type="submit" name="commit" value="Log in" data-disable-with="Log in" />
|
15
|
+
</div>
|
16
|
+
</form>
|
17
|
+
</div>
|
18
|
+
</template>
|
19
|
+
|
20
|
+
<script>
|
21
|
+
import axios from 'axios'
|
22
|
+
|
23
|
+
export default {
|
24
|
+
name: 'DeviseTokenAuth',
|
25
|
+
props: {
|
26
|
+
isLogout: {
|
27
|
+
type: Boolean,
|
28
|
+
default: false
|
29
|
+
}
|
30
|
+
},
|
31
|
+
data () {
|
32
|
+
return {
|
33
|
+
loginParams: {
|
34
|
+
email: "",
|
35
|
+
password: ""
|
36
|
+
}
|
37
|
+
}
|
38
|
+
},
|
39
|
+
mounted () {
|
40
|
+
if (this.isLogout) {
|
41
|
+
this.logout();
|
42
|
+
}
|
43
|
+
},
|
44
|
+
methods: {
|
45
|
+
login () {
|
46
|
+
axios
|
47
|
+
.post('/auth/sign_in', { email: this.loginParams.email, password: this.loginParams.password })
|
48
|
+
.then(response => {
|
49
|
+
if (response.status == 200) {
|
50
|
+
let authHeaders = {};
|
51
|
+
for (let authHeader of ['access-token', 'client', 'uid']) {
|
52
|
+
authHeaders[authHeader] = response.headers[authHeader];
|
53
|
+
axios.defaults.headers.common[authHeader] = authHeaders[authHeader];
|
54
|
+
}
|
55
|
+
this.$store.commit('signIn', { user: response.data.data, authHeaders: authHeaders });
|
56
|
+
if (this.$route.query.redirect) {
|
57
|
+
this.$router.push(this.$route.query.redirect);
|
58
|
+
} else {
|
59
|
+
this.$router.push('/');
|
60
|
+
}
|
61
|
+
}
|
62
|
+
})
|
63
|
+
.catch (error => {
|
64
|
+
console.log("Authentication failed");
|
65
|
+
if (error.response.status == 401) {
|
66
|
+
this.$router.go({path: this.$router.currentRoute.path});
|
67
|
+
}
|
68
|
+
})
|
69
|
+
},
|
70
|
+
logout () {
|
71
|
+
for (var authHeader of Object.keys(this.$store.getters.authHeaders)) {
|
72
|
+
delete axios.defaults.headers.common[authHeader];
|
73
|
+
}
|
74
|
+
this.$store.commit('signOut');
|
75
|
+
this.$router.push('/');
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
</script>
|
80
|
+
|
81
|
+
<style scoped>
|
82
|
+
</style>
|
@@ -0,0 +1,98 @@
|
|
1
|
+
<template>
|
2
|
+
<div>
|
3
|
+
<section>
|
4
|
+
<h1>Authentecated User</h1>
|
5
|
+
<div class="list_wrapper">
|
6
|
+
<div class="list_image"></div>
|
7
|
+
<div class="list_description_wrapper">
|
8
|
+
<div class="list_description">
|
9
|
+
<div v-if="userSignedIn">
|
10
|
+
<span>{{ currentUser.name }}</span> · {{ currentUser.email }} · <router-link v-bind:to="{ path: '/logout' }">Logout</router-link><br>
|
11
|
+
</div>
|
12
|
+
<div v-else>
|
13
|
+
<span>Not logged in</span> · <router-link v-bind:to="{ path: '/login' }">Login</router-link><br>
|
14
|
+
</div>
|
15
|
+
<router-link v-bind:to="{ name : 'AuthenticatedUserNotificationsIndex' }">Notifications</router-link> /
|
16
|
+
<router-link v-bind:to="{ name : 'AuthenticatedUserSubscriptionsIndex' }">Subscriptions</router-link>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
</section>
|
21
|
+
|
22
|
+
<section>
|
23
|
+
<h1>Listing Users</h1>
|
24
|
+
<div v-for="user in users" :key="`${user.id}`" class="list_wrapper">
|
25
|
+
<div class="list_image"></div>
|
26
|
+
<div class="list_description_wrapper">
|
27
|
+
<p class="list_description">
|
28
|
+
<span>{{ user.name }}</span> · {{ user.email }}<br>
|
29
|
+
<router-link v-bind:to="{ name : 'UnauthenticatedTargetNotificationsIndex', params : { target_type: 'users', target_id: user.id, target: user }}">Notifications</router-link> /
|
30
|
+
<router-link v-bind:to="{ name : 'UnauthenticatedTargetSubscriptionsIndex', params : { target_type: 'users', target_id: user.id, target: user }}">Subscriptions</router-link>
|
31
|
+
</p>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
</section>
|
35
|
+
|
36
|
+
<section>
|
37
|
+
<h1>Authentecated User as Admin</h1>
|
38
|
+
<div class="list_wrapper">
|
39
|
+
<div class="list_image"></div>
|
40
|
+
<div class="list_description_wrapper">
|
41
|
+
<div class="list_description">
|
42
|
+
<div v-if="userSignedIn">
|
43
|
+
<span>{{ currentUser.name }}</span> · {{ currentUser.email }} · <span v-if="currentUser.admin">(admin)</span><span v-else>(not admin)</span><br>
|
44
|
+
</div>
|
45
|
+
<div v-else>
|
46
|
+
<span>Not logged in</span> · <router-link v-bind:to="{ path: '/login' }">Login</router-link><br>
|
47
|
+
</div>
|
48
|
+
<router-link v-bind:to="{ name : 'AuthenticatedAdminNotificationsIndex' }">Notifications</router-link> /
|
49
|
+
<router-link v-bind:to="{ name : 'AuthenticatedAdminSubscriptionsIndex' }">Subscriptions</router-link>
|
50
|
+
</div>
|
51
|
+
</div>
|
52
|
+
</div>
|
53
|
+
</section>
|
54
|
+
|
55
|
+
<section>
|
56
|
+
<h1>Listing Admins</h1>
|
57
|
+
<div v-for="admin in admins" :key="`${admin.id}`" class="list_wrapper">
|
58
|
+
<div class="list_image"></div>
|
59
|
+
<div class="list_description_wrapper">
|
60
|
+
<p class="list_description">
|
61
|
+
<span>{{ admin.user.name }}</span> · {{ admin.user.email }}<br>
|
62
|
+
<router-link v-bind:to="{ name : 'UnauthenticatedTargetNotificationsIndex', params : { target_type: 'admins', target_id: admin.id, target: admin }}">Notifications</router-link> /
|
63
|
+
<router-link v-bind:to="{ name : 'UnauthenticatedTargetSubscriptionsIndex', params : { target_type: 'admins', target_id: admin.id, target: admin }}">Subscriptions</router-link>
|
64
|
+
</p>
|
65
|
+
</div>
|
66
|
+
</div>
|
67
|
+
</section>
|
68
|
+
</div>
|
69
|
+
</template>
|
70
|
+
|
71
|
+
<script>
|
72
|
+
import axios from 'axios'
|
73
|
+
|
74
|
+
export default {
|
75
|
+
name: 'Top',
|
76
|
+
data () {
|
77
|
+
return {
|
78
|
+
userSignedIn: this.$store.getters.userSignedIn,
|
79
|
+
currentUser: this.$store.getters.currentUser,
|
80
|
+
users: [],
|
81
|
+
admins: []
|
82
|
+
}
|
83
|
+
},
|
84
|
+
mounted () {
|
85
|
+
axios
|
86
|
+
.get('/users')
|
87
|
+
.then(response => {
|
88
|
+
this.users = response.data.users;
|
89
|
+
this.admins = this.users
|
90
|
+
.filter(user => user.admin)
|
91
|
+
.map(user => Object.assign(Object.create(user.admin), { user: user }))
|
92
|
+
})
|
93
|
+
}
|
94
|
+
}
|
95
|
+
</script>
|
96
|
+
|
97
|
+
<style scoped>
|
98
|
+
</style>
|