arcadex 1.1.3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. checksums.yaml +4 -4
  2. data/db/migrate/20141020173616_add_max_uses_to_arcadex_tokens.rb +5 -0
  3. data/lib/arcadex/authentication.rb +45 -51
  4. data/lib/arcadex/create.rb +2 -1
  5. data/lib/arcadex/header.rb +8 -21
  6. data/lib/arcadex/version.rb +1 -1
  7. data/test/dummy/db/development.sqlite3 +0 -0
  8. data/test/dummy/db/schema.rb +2 -1
  9. data/test/dummy/db/test.sqlite3 +0 -0
  10. data/test/dummy/log/development.log +15 -0
  11. data/test/dummy/log/test.log +35 -0
  12. data/test/test_app/Gemfile +77 -0
  13. data/test/test_app/Gemfile.lock +281 -0
  14. data/test/test_app/README.md +1 -0
  15. data/test/test_app/Rakefile +6 -0
  16. data/test/test_app/app/admin/arcadex_token.rb +94 -0
  17. data/test/test_app/app/admin/dashboard.rb +69 -0
  18. data/test/test_app/app/admin/defcon_admin_user.rb +99 -0
  19. data/test/test_app/app/admin/people_user.rb +83 -0
  20. data/test/test_app/app/assets/javascripts/active_admin.js.coffee +1 -0
  21. data/test/test_app/app/assets/javascripts/application.js +16 -0
  22. data/test/test_app/app/assets/stylesheets/active_admin.css.scss +17 -0
  23. data/test/test_app/app/assets/stylesheets/application.css +13 -0
  24. data/test/test_app/app/controllers/api/v1/api_controller.rb +71 -0
  25. data/test/test_app/app/controllers/app_index_controller.rb +4 -0
  26. data/test/test_app/app/controllers/application_controller.rb +21 -0
  27. data/test/test_app/app/helpers/application_helper.rb +2 -0
  28. data/test/test_app/app/views/app_index/app.html.erb +0 -0
  29. data/test/test_app/app/views/layouts/app_index.html.erb +9 -0
  30. data/test/test_app/app/views/layouts/application.html.erb +14 -0
  31. data/test/test_app/bin/bundle +3 -0
  32. data/test/test_app/bin/rails +4 -0
  33. data/test/test_app/bin/rake +4 -0
  34. data/test/test_app/config.ru +4 -0
  35. data/test/test_app/config/application.rb +27 -0
  36. data/test/test_app/config/boot.rb +4 -0
  37. data/test/test_app/config/database.yml +25 -0
  38. data/test/test_app/config/environment.rb +5 -0
  39. data/test/test_app/config/environments/development.rb +29 -0
  40. data/test/test_app/config/environments/production.rb +80 -0
  41. data/test/test_app/config/environments/test.rb +36 -0
  42. data/test/test_app/config/initializers/active_admin.rb +252 -0
  43. data/test/test_app/config/initializers/backtrace_silencers.rb +7 -0
  44. data/test/test_app/config/initializers/filter_parameter_logging.rb +4 -0
  45. data/test/test_app/config/initializers/inflections.rb +16 -0
  46. data/test/test_app/config/initializers/mime_types.rb +5 -0
  47. data/test/test_app/config/initializers/secret_token.rb +12 -0
  48. data/test/test_app/config/initializers/session_store.rb +3 -0
  49. data/test/test_app/config/initializers/wrap_parameters.rb +14 -0
  50. data/test/test_app/config/locales/en.yml +23 -0
  51. data/test/test_app/config/routes.rb +66 -0
  52. data/test/test_app/config/schedule.rb +20 -0
  53. data/test/test_app/db/development.sqlite3 +0 -0
  54. data/test/test_app/db/migrate/20141016225515_create_active_admin_comments.rb +19 -0
  55. data/test/test_app/db/migrate/20141016225555_create_people_users.people.rb +14 -0
  56. data/test/test_app/db/migrate/20141016225556_create_arcadex_tokens.arcadex.rb +12 -0
  57. data/test/test_app/db/migrate/20141016225557_add_index_to_token.arcadex.rb +6 -0
  58. data/test/test_app/db/migrate/20141016225558_add_first_ip_address_to_arcadex_tokens.arcadex.rb +6 -0
  59. data/test/test_app/db/migrate/20141016225559_add_current_ip_address_to_arcadex_tokens.arcadex.rb +6 -0
  60. data/test/test_app/db/migrate/20141016225560_add_times_used_to_arcadex_tokens.arcadex.rb +6 -0
  61. data/test/test_app/db/migrate/20141016225561_add_expiration_minutes_to_arcadex_tokens.arcadex.rb +6 -0
  62. data/test/test_app/db/migrate/20141016225562_create_defcon_admin_users.defcon.rb +16 -0
  63. data/test/test_app/db/migrate/20141016225563_add_index_to_defcon_admin_users.defcon.rb +6 -0
  64. data/test/test_app/db/migrate/20141016225564_add_email_to_defcon_admin_users.defcon.rb +7 -0
  65. data/test/test_app/db/migrate/20141020173805_add_max_uses_to_arcadex_tokens.arcadex.rb +6 -0
  66. data/test/test_app/db/production.sqlite3 +0 -0
  67. data/test/test_app/db/schema.rb +73 -0
  68. data/test/test_app/db/seeds.rb +10 -0
  69. data/test/test_app/db/test.sqlite3 +0 -0
  70. data/test/test_app/engines/people/Gemfile +14 -0
  71. data/test/test_app/engines/people/Gemfile.lock +81 -0
  72. data/test/test_app/engines/people/MIT-LICENSE +20 -0
  73. data/test/test_app/engines/people/README.md +1 -0
  74. data/test/test_app/engines/people/Rakefile +34 -0
  75. data/test/test_app/engines/people/app/assets/javascripts/people/application.js +13 -0
  76. data/test/test_app/engines/people/app/assets/javascripts/people/users.js +2 -0
  77. data/test/test_app/engines/people/app/assets/stylesheets/people/application.css +13 -0
  78. data/test/test_app/engines/people/app/assets/stylesheets/people/users.css +4 -0
  79. data/test/test_app/engines/people/app/assets/stylesheets/scaffold.css +56 -0
  80. data/test/test_app/engines/people/app/controllers/people/api/v1/application_controller.rb +5 -0
  81. data/test/test_app/engines/people/app/controllers/people/api/v1/users_controller.rb +169 -0
  82. data/test/test_app/engines/people/app/controllers/people/application_controller.rb +4 -0
  83. data/test/test_app/engines/people/app/controllers/people/users_controller.rb +62 -0
  84. data/test/test_app/engines/people/app/helpers/people/application_helper.rb +4 -0
  85. data/test/test_app/engines/people/app/helpers/people/users_helper.rb +4 -0
  86. data/test/test_app/engines/people/app/models/people/user.rb +9 -0
  87. data/test/test_app/engines/people/app/models/people/v1/user.rb +32 -0
  88. data/test/test_app/engines/people/app/serializers/people/v1/user_serializer.rb +43 -0
  89. data/test/test_app/engines/people/app/views/layouts/people/default/application.html.erb +14 -0
  90. data/test/test_app/engines/people/app/views/people/users/_form.html.erb +29 -0
  91. data/test/test_app/engines/people/app/views/people/users/edit.html.erb +6 -0
  92. data/test/test_app/engines/people/app/views/people/users/index.html.erb +31 -0
  93. data/test/test_app/engines/people/app/views/people/users/new.html.erb +5 -0
  94. data/test/test_app/engines/people/app/views/people/users/show.html.erb +19 -0
  95. data/test/test_app/engines/people/bin/rails +12 -0
  96. data/test/test_app/engines/people/config/routes.rb +28 -0
  97. data/test/test_app/engines/people/db/migrate/20141016225548_create_people_users.rb +13 -0
  98. data/test/test_app/engines/people/lib/people.rb +4 -0
  99. data/test/test_app/engines/people/lib/people/engine.rb +5 -0
  100. data/test/test_app/engines/people/lib/people/version.rb +3 -0
  101. data/test/test_app/engines/people/lib/tasks/people_tasks.rake +4 -0
  102. data/test/test_app/engines/people/people.gemspec +33 -0
  103. data/test/test_app/engines/people/test/controllers/people/users_controller_test.rb +51 -0
  104. data/test/test_app/engines/people/test/dummy/README.rdoc +28 -0
  105. data/test/test_app/engines/people/test/dummy/Rakefile +6 -0
  106. data/test/test_app/engines/people/test/dummy/app/assets/javascripts/application.js +13 -0
  107. data/test/test_app/engines/people/test/dummy/app/assets/stylesheets/application.css +13 -0
  108. data/test/test_app/engines/people/test/dummy/app/controllers/application_controller.rb +5 -0
  109. data/test/test_app/engines/people/test/dummy/app/helpers/application_helper.rb +2 -0
  110. data/test/test_app/engines/people/test/dummy/app/views/layouts/application.html.erb +14 -0
  111. data/test/test_app/engines/people/test/dummy/bin/bundle +3 -0
  112. data/test/test_app/engines/people/test/dummy/bin/rails +4 -0
  113. data/test/test_app/engines/people/test/dummy/bin/rake +4 -0
  114. data/test/test_app/engines/people/test/dummy/config.ru +4 -0
  115. data/test/test_app/engines/people/test/dummy/config/application.rb +23 -0
  116. data/test/test_app/engines/people/test/dummy/config/boot.rb +5 -0
  117. data/test/test_app/engines/people/test/dummy/config/database.yml +25 -0
  118. data/test/test_app/engines/people/test/dummy/config/environment.rb +5 -0
  119. data/test/test_app/engines/people/test/dummy/config/environments/development.rb +29 -0
  120. data/test/test_app/engines/people/test/dummy/config/environments/production.rb +80 -0
  121. data/test/test_app/engines/people/test/dummy/config/environments/test.rb +36 -0
  122. data/test/test_app/engines/people/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  123. data/test/test_app/engines/people/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  124. data/test/test_app/engines/people/test/dummy/config/initializers/inflections.rb +16 -0
  125. data/test/test_app/engines/people/test/dummy/config/initializers/mime_types.rb +5 -0
  126. data/test/test_app/engines/people/test/dummy/config/initializers/secret_token.rb +12 -0
  127. data/test/test_app/engines/people/test/dummy/config/initializers/session_store.rb +3 -0
  128. data/test/test_app/engines/people/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  129. data/test/test_app/engines/people/test/dummy/config/locales/en.yml +23 -0
  130. data/test/test_app/engines/people/test/dummy/config/routes.rb +4 -0
  131. data/test/test_app/engines/people/test/dummy/public/404.html +58 -0
  132. data/test/test_app/engines/people/test/dummy/public/422.html +58 -0
  133. data/test/test_app/engines/people/test/dummy/public/500.html +57 -0
  134. data/test/test_app/engines/people/test/dummy/public/favicon.ico +0 -0
  135. data/test/test_app/engines/people/test/fixtures/people/users.yml +11 -0
  136. data/test/test_app/engines/people/test/helpers/people/users_helper_test.rb +6 -0
  137. data/test/test_app/engines/people/test/integration/navigation_test.rb +10 -0
  138. data/test/test_app/engines/people/test/models/people/user_test.rb +9 -0
  139. data/test/test_app/engines/people/test/people_test.rb +7 -0
  140. data/test/test_app/engines/people/test/test_helper.rb +15 -0
  141. data/test/test_app/gems/authorization/Gemfile +14 -0
  142. data/test/test_app/gems/authorization/Gemfile.lock +81 -0
  143. data/test/test_app/gems/authorization/MIT-LICENSE +20 -0
  144. data/test/test_app/gems/authorization/README.rdoc +3 -0
  145. data/test/test_app/gems/authorization/Rakefile +32 -0
  146. data/test/test_app/gems/authorization/authorization.gemspec +22 -0
  147. data/test/test_app/gems/authorization/lib/authorization.rb +4 -0
  148. data/test/test_app/gems/authorization/lib/authorization/people/v1/user.rb +90 -0
  149. data/test/test_app/gems/authorization/lib/authorization/version.rb +3 -0
  150. data/test/test_app/gems/authorization/lib/tasks/authorization_tasks.rake +4 -0
  151. data/test/test_app/gems/authorization/test/authorization_test.rb +7 -0
  152. data/test/test_app/gems/authorization/test/dummy/README.rdoc +28 -0
  153. data/test/test_app/gems/authorization/test/dummy/Rakefile +6 -0
  154. data/test/test_app/gems/authorization/test/dummy/app/assets/javascripts/application.js +13 -0
  155. data/test/test_app/gems/authorization/test/dummy/app/assets/stylesheets/application.css +13 -0
  156. data/test/test_app/gems/authorization/test/dummy/app/controllers/application_controller.rb +5 -0
  157. data/test/test_app/gems/authorization/test/dummy/app/helpers/application_helper.rb +2 -0
  158. data/test/test_app/gems/authorization/test/dummy/app/views/layouts/application.html.erb +14 -0
  159. data/test/test_app/gems/authorization/test/dummy/bin/bundle +3 -0
  160. data/test/test_app/gems/authorization/test/dummy/bin/rails +4 -0
  161. data/test/test_app/gems/authorization/test/dummy/bin/rake +4 -0
  162. data/test/test_app/gems/authorization/test/dummy/config.ru +4 -0
  163. data/test/test_app/gems/authorization/test/dummy/config/application.rb +23 -0
  164. data/test/test_app/gems/authorization/test/dummy/config/boot.rb +5 -0
  165. data/test/test_app/gems/authorization/test/dummy/config/database.yml +25 -0
  166. data/test/test_app/gems/authorization/test/dummy/config/environment.rb +5 -0
  167. data/test/test_app/gems/authorization/test/dummy/config/environments/development.rb +29 -0
  168. data/test/test_app/gems/authorization/test/dummy/config/environments/production.rb +80 -0
  169. data/test/test_app/gems/authorization/test/dummy/config/environments/test.rb +36 -0
  170. data/test/test_app/gems/authorization/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  171. data/test/test_app/gems/authorization/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  172. data/test/test_app/gems/authorization/test/dummy/config/initializers/inflections.rb +16 -0
  173. data/test/test_app/gems/authorization/test/dummy/config/initializers/mime_types.rb +5 -0
  174. data/test/test_app/gems/authorization/test/dummy/config/initializers/secret_token.rb +12 -0
  175. data/test/test_app/gems/authorization/test/dummy/config/initializers/session_store.rb +3 -0
  176. data/test/test_app/gems/authorization/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  177. data/test/test_app/gems/authorization/test/dummy/config/locales/en.yml +23 -0
  178. data/test/test_app/gems/authorization/test/dummy/config/routes.rb +56 -0
  179. data/test/test_app/gems/authorization/test/dummy/public/404.html +58 -0
  180. data/test/test_app/gems/authorization/test/dummy/public/422.html +58 -0
  181. data/test/test_app/gems/authorization/test/dummy/public/500.html +57 -0
  182. data/test/test_app/gems/authorization/test/dummy/public/favicon.ico +0 -0
  183. data/test/test_app/gems/authorization/test/test_helper.rb +15 -0
  184. data/test/test_app/log/development.log +79 -0
  185. data/test/test_app/log/production.log +12 -0
  186. data/test/test_app/log/test.log +13884 -0
  187. data/test/test_app/public/404.html +58 -0
  188. data/test/test_app/public/422.html +58 -0
  189. data/test/test_app/public/500.html +57 -0
  190. data/test/test_app/public/favicon.ico +0 -0
  191. data/test/test_app/public/robots.txt +5 -0
  192. data/test/test_app/spec/controllers/app_index_controller_spec.rb +12 -0
  193. data/test/test_app/spec/engines/people/api/v1/models/user_spec.rb +61 -0
  194. data/test/test_app/spec/engines/people/api/v1/requests/user_spec.rb +244 -0
  195. data/test/test_app/spec/engines/people/api/v1/routing/user_spec.rb +91 -0
  196. data/test/test_app/spec/factories/people_user_1_factory.rb +14 -0
  197. data/test/test_app/spec/rails_helper.rb +47 -0
  198. data/test/test_app/spec/spec_helper.rb +78 -0
  199. data/test/test_app/spec/support/factory_girl.rb +16 -0
  200. data/test/test_app/spec/support/request_helpers.rb +7 -0
  201. metadata +381 -2
@@ -0,0 +1 @@
1
+ # Describe your application here
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ TestApp::Application.load_tasks
@@ -0,0 +1,94 @@
1
+ ActiveAdmin.register Arcadex::Token do
2
+
3
+ menu :label => "Tokens"
4
+ config.per_page = 30
5
+
6
+ form do |f|
7
+ f.semantic_errors # shows errors on :base
8
+ #f.inputs # builds an input field for every attribute
9
+ f.inputs do
10
+ f.input :id
11
+ f.input :imageable_id
12
+ f.input :imageable_type
13
+ f.input :times_used
14
+ f.input :first_ip_address
15
+ f.input :current_ip_address
16
+ f.input :auth_token
17
+ f.input :expiration_minutes
18
+ f.input :updated_at
19
+ f.input :created_at
20
+ end
21
+ f.actions # adds the 'Submit' and 'Cancel' buttons
22
+ end
23
+
24
+ controller do
25
+ def create
26
+ @token = ::Arcadex::Token.new(token_params)
27
+ if @token.save
28
+ flash[:notice] = "Created Successfully!"
29
+ redirect_to resource_path @token
30
+ else
31
+ flash[:notice] = "#{@token.errors.full_messages}"
32
+ redirect_to new_resource_path @token
33
+ #super
34
+ #render :new
35
+ end
36
+ end
37
+
38
+ def update
39
+ @token = ::Arcadex::Token.find(params[:id])
40
+ if @token.update(token_params)
41
+ flash[:notice] = "Updated Successfully!"
42
+ redirect_to resource_path @token
43
+ else
44
+ flash.now[:notice] = "#{@token.errors.full_messages}"
45
+ render :edit
46
+ #super
47
+ end
48
+ end
49
+
50
+ def destroy
51
+ @token = ::Arcadex::Token.find(params[:id])
52
+ @token.destroy
53
+ flash.now[:notice] = "Deleted Successfully!"
54
+ render :index
55
+ end
56
+
57
+ private
58
+
59
+ def token_params
60
+ params.require(:token).permit(:times_used,:imageable_id,:imageable_type,:password_confirmation,:first_ip_address,:current_ip_address,:auth_token,:expiration_minutes)
61
+ end
62
+ end
63
+
64
+ index do
65
+ column :id
66
+ column :imageable_id
67
+ column :imageable_type
68
+ column :times_used
69
+ column :first_ip_address
70
+ column :current_ip_address
71
+ column :auth_token
72
+ column :expiration_minutes
73
+ column :updated_at
74
+ column :created_at
75
+ actions
76
+ end
77
+
78
+ show do
79
+ attributes_table do
80
+ row :id
81
+ row :imageable_id
82
+ row :imageable_type
83
+ row :times_used
84
+ row :first_ip_address
85
+ row :current_ip_address
86
+ row :auth_token
87
+ row :expiration_minutes
88
+ row :updated_at
89
+ row :created_at
90
+ end
91
+ end
92
+
93
+
94
+ end
@@ -0,0 +1,69 @@
1
+ ActiveAdmin.register_page "Dashboard" do
2
+
3
+ menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") }
4
+
5
+ content title: proc{ I18n.t("active_admin.dashboard") } do
6
+
7
+ columns do
8
+
9
+ column do
10
+ panel "Recent Signups" do
11
+ table_for ::People::User.order("created_at desc").limit(30) do
12
+ column :username do |user|
13
+ link_to user.username, admin_people_user_path(user)
14
+ end
15
+ column :email
16
+ column :created_at
17
+ end
18
+ strong { link_to "View All Users", admin_people_users_path }
19
+ end
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+ end
26
+
27
+ =begin
28
+ columns do
29
+ column do
30
+ panel "Recent Signups" do
31
+ ul do
32
+ ::People::User.recent(30).map do |user|
33
+ li link_to(user.username, resource_path(user))
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ =end
40
+
41
+ =begin
42
+
43
+ div class: "blank_slate_container", id: "dashboard_default_message" do
44
+ span class: "blank_slate" do
45
+ span I18n.t("active_admin.dashboard_welcome.welcome")
46
+ small I18n.t("active_admin.dashboard_welcome.call_to_action")
47
+ end
48
+ end
49
+ =end
50
+ # Here is an example of a simple dashboard with columns and panels.
51
+ #
52
+ # columns do
53
+ # column do
54
+ # panel "Recent Posts" do
55
+ # ul do
56
+ # Post.recent(5).map do |post|
57
+ # li link_to(post.title, admin_post_path(post))
58
+ # end
59
+ # end
60
+ # end
61
+ # end
62
+
63
+ # column do
64
+ # panel "Info" do
65
+ # para "Welcome to ActiveAdmin."
66
+ # end
67
+ # end
68
+ # end
69
+ # content
@@ -0,0 +1,99 @@
1
+ ActiveAdmin.register Defcon::AdminUser do
2
+
3
+ menu :label => "AdminUsers"
4
+ config.per_page = 30
5
+
6
+ form do |f|
7
+ f.semantic_errors # shows errors on :base
8
+ #f.inputs # builds an input field for every attribute
9
+ f.inputs do
10
+ f.input :id
11
+ f.input :username
12
+ f.input :password
13
+ f.input :password_confirmation
14
+ f.input :email
15
+ f.input :read_only
16
+ f.input :attempts
17
+ f.input :max_attempts
18
+ f.input :master
19
+ f.input :updated_at
20
+ f.input :created_at
21
+ end
22
+ f.actions # adds the 'Submit' and 'Cancel' buttons
23
+ end
24
+
25
+ controller do
26
+ def create
27
+ @admin_user = ::Defcon::AdminUser.new(admin_user_params)
28
+ if @admin_user.save
29
+ flash[:notice] = "Created Successfully!"
30
+ redirect_to resource_path @admin_user
31
+ else
32
+ flash[:notice] = "#{@admin_user.errors.full_messages}"
33
+ redirect_to new_resource_path @admin_user
34
+ #super
35
+ #render :new
36
+ end
37
+ end
38
+
39
+ def update
40
+ @admin_user = ::Defcon::AdminUser.find(params[:id])
41
+ if @admin_user.update(admin_user_params)
42
+ flash[:notice] = "Updated Successfully!"
43
+ redirect_to resource_path @admin_user
44
+ else
45
+ flash.now[:notice] = "#{@admin_user.errors.full_messages}"
46
+ render :edit
47
+ #super
48
+ end
49
+ end
50
+
51
+ def destroy
52
+ =begin
53
+ @admin_user = ::Defcon::AdminUser.find(params[:id])
54
+ @admin_user.destroy
55
+ flash.now[:notice] = "Deleted Successfully!"
56
+ render :index
57
+ =end
58
+ flash.now[:notice] = "Deleting an Admin is serious business, update your policy first"
59
+ render :index
60
+ end
61
+
62
+ private
63
+
64
+ def admin_user_params
65
+ params.require(:admin_user).permit(:username,:email,:password,:password_confirmation,:read_only,:attempts,:max_attempts,:master)
66
+ end
67
+ end
68
+
69
+ index do
70
+ column :id
71
+ column :username
72
+ column :email
73
+ column :password_digest
74
+ column :read_only
75
+ column :attempts
76
+ column :max_attempts
77
+ column :master
78
+ column :updated_at
79
+ column :created_at
80
+ actions
81
+ end
82
+
83
+ show do
84
+ attributes_table do
85
+ row :id
86
+ row :username
87
+ row :email
88
+ row :password_digest
89
+ row :read_only
90
+ row :attempts
91
+ row :max_attempts
92
+ row :master
93
+ row :updated_at
94
+ row :created_at
95
+ end
96
+ end
97
+
98
+
99
+ end
@@ -0,0 +1,83 @@
1
+ ActiveAdmin.register People::User do
2
+
3
+ menu :label => "Users"
4
+ config.per_page = 30
5
+
6
+ form do |f|
7
+ f.semantic_errors # shows errors on :base
8
+ #f.inputs # builds an input field for every attribute
9
+ f.inputs do
10
+ f.input :id
11
+ f.input :username
12
+ f.input :email
13
+ f.input :password
14
+ f.input :password_confirmation
15
+ f.input :updated_at
16
+ f.input :created_at
17
+ end
18
+ f.actions # adds the 'Submit' and 'Cancel' buttons
19
+ end
20
+
21
+ controller do
22
+ def create
23
+ @user = ::People::V1::User.new(user_params)
24
+ if @user.save
25
+ flash[:notice] = "Created Successfully!"
26
+ redirect_to resource_path @user
27
+ else
28
+ flash[:notice] = "#{@user.errors.full_messages}"
29
+ redirect_to new_resource_path @user
30
+ #super
31
+ #render :new
32
+ end
33
+ end
34
+
35
+ def update
36
+ @user = ::People::V1::User.find(params[:id])
37
+ if @user.update(user_params)
38
+ flash[:notice] = "Updated Successfully!"
39
+ redirect_to resource_path @user
40
+ else
41
+ flash.now[:notice] = "#{@user.errors.full_messages}"
42
+ render :edit
43
+ #super
44
+ end
45
+ end
46
+
47
+ def destroy
48
+ @user = ::People::V1::User.find(params[:id])
49
+ @user.destroy
50
+ flash.now[:notice] = "Deleted Successfully!"
51
+ render :index
52
+ end
53
+
54
+ private
55
+
56
+ def user_params
57
+ params.require(:user).permit(:username,:email,:password,:password_confirmation)
58
+ end
59
+ end
60
+
61
+ index do
62
+ column :id
63
+ column :username
64
+ column :email
65
+ column :password_digest
66
+ column :updated_at
67
+ column :created_at
68
+ actions
69
+ end
70
+
71
+ show do
72
+ attributes_table do
73
+ row :id
74
+ row :username
75
+ row :email
76
+ row :password_digest
77
+ row :updated_at
78
+ row :created_at
79
+ end
80
+ end
81
+
82
+
83
+ end
@@ -0,0 +1 @@
1
+ #= require active_admin/base
@@ -0,0 +1,16 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require turbolinks
16
+ //= require_tree .
@@ -0,0 +1,17 @@
1
+ // SASS variable overrides must be declared before loading up Active Admin's styles.
2
+ //
3
+ // To view the variables that Active Admin provides, take a look at
4
+ // `app/assets/stylesheets/active_admin/mixins/_variables.css.scss` in the
5
+ // Active Admin source.
6
+ //
7
+ // For example, to change the sidebar width:
8
+ // $sidebar-width: 242px;
9
+
10
+ // Active Admin's got SASS!
11
+ @import "active_admin/mixins";
12
+ @import "active_admin/base";
13
+
14
+ // Overriding any non-variable SASS must be done after the fact.
15
+ // For example, to change the default status-tag color:
16
+ //
17
+ // .status_tag { background: #6090DB; }
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,71 @@
1
+ class Api::V1::ApiController < ::ActionController::API
2
+
3
+ before_action :authenticate_user
4
+ after_filter :cors_set_access_control_headers
5
+ skip_before_filter :authenticate_user, :only => [:route_options]
6
+
7
+ def route_options
8
+ cors_preflight_check
9
+ end
10
+
11
+ private
12
+
13
+ def authenticate_user
14
+ set_hash
15
+ if @instance_hash.nil?
16
+ render :json => {errors: "User is not logged in, register or log in"} , status: :unauthorized
17
+ end
18
+ end
19
+
20
+ def authenticate_password
21
+ if current_user.nil?
22
+ return true
23
+ end
24
+ if !current_user.authenticate(params[:user][:password])
25
+ return true
26
+ else
27
+ return false
28
+ end
29
+ end
30
+
31
+ def set_hash
32
+ #["current_owner","current_token"] Make this true to check for email also
33
+ @instance_hash = ::Arcadex::Authentication.get_instance(params,request,"Auth-Token")
34
+ #@instance_hash = ::Arcadex::Authentication.authenticate_owner_with_index(params,request,"Auth-Token","Email","email")
35
+ end
36
+
37
+ def current_user
38
+ if !@instance_hash.nil?
39
+ return @instance_hash["current_owner"]
40
+ else
41
+ return nil
42
+ end
43
+ end
44
+
45
+ def current_token
46
+ if !@instance_hash.nil?
47
+ return @instance_hash["current_token"]
48
+ else
49
+ return nil
50
+ end
51
+ end
52
+
53
+ def cors_set_access_control_headers
54
+ response.headers['Access-Control-Allow-Origin'] = '*'
55
+ response.headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, PATCH, DELETE, OPTIONS'
56
+ response.headers['Access-Control-Allow-Headers'] = '*, Origin, Content-Type, Accept, Authorization, Token, Auth-Token, Email'
57
+ response.headers['Access-Control-Expose-Headers'] = '*'
58
+ response.headers['Access-Control-Max-Age'] = "1728000"
59
+ end
60
+
61
+ def cors_preflight_check
62
+ #if request.method == 'OPTIONS'
63
+ request.headers['Access-Control-Allow-Origin'] = '*'
64
+ request.headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, PATCH, DELETE, OPTIONS'
65
+ request.headers['Access-Control-Allow-Headers'] = '*, X-Requested-With, X-Prototype-Version, Token, Auth-Token, Email'
66
+ request.headers['Access-Control-Max-Age'] = '1728000'
67
+ render :text => '', :content_type => 'text/plain'
68
+ #end
69
+ end
70
+
71
+ end