simple_user 0.1.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. checksums.yaml +15 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +35 -0
  4. data/Rakefile +40 -0
  5. data/app/assets/javascripts/simple_user/application.js +15 -0
  6. data/app/assets/javascripts/simple_user/facebook_connect.js.erb +33 -0
  7. data/app/assets/stylesheets/simple_user/application.css +13 -0
  8. data/app/controllers/simple_user/admin_users/registrations_controller.rb +7 -0
  9. data/app/controllers/simple_user/admin_users/sessions_controller.rb +20 -0
  10. data/app/controllers/simple_user/admin_users_controller.rb +134 -0
  11. data/app/controllers/simple_user/application_controller.rb +7 -0
  12. data/app/controllers/simple_user/auth_controller.rb +26 -0
  13. data/app/controllers/simple_user/users/registrations_controller.rb +5 -0
  14. data/app/controllers/simple_user/users/sessions_controller.rb +41 -0
  15. data/app/controllers/simple_user/users_controller.rb +88 -0
  16. data/app/helpers/simple_user/application_helper.rb +13 -0
  17. data/app/helpers/simple_user/links_helper.rb +9 -0
  18. data/app/models/ability.rb +25 -0
  19. data/app/models/role.rb +18 -0
  20. data/app/models/simple_user/admin_user.rb +48 -0
  21. data/app/models/simple_user/authentication.rb +9 -0
  22. data/app/models/simple_user/user.rb +92 -0
  23. data/app/views/layouts/simple_user/application.html.erb +28 -0
  24. data/app/views/simple_user/admin_users/_form.html.erb +15 -0
  25. data/app/views/simple_user/admin_users/confirmations/new.html.erb +16 -0
  26. data/app/views/simple_user/admin_users/edit.html.erb +6 -0
  27. data/app/views/simple_user/admin_users/index.html.erb +27 -0
  28. data/app/views/simple_user/admin_users/mailer/confirmation_instructions.html.erb +5 -0
  29. data/app/views/simple_user/admin_users/mailer/reset_password_instructions.html.erb +8 -0
  30. data/app/views/simple_user/admin_users/mailer/unlock_instructions.html.erb +7 -0
  31. data/app/views/simple_user/admin_users/new.html.erb +5 -0
  32. data/app/views/simple_user/admin_users/passwords/edit.html.erb +19 -0
  33. data/app/views/simple_user/admin_users/passwords/new.html.erb +15 -0
  34. data/app/views/simple_user/admin_users/registrations/edit.html.erb +28 -0
  35. data/app/views/simple_user/admin_users/registrations/new.html.erb +18 -0
  36. data/app/views/simple_user/admin_users/sessions/new.html.erb +15 -0
  37. data/app/views/simple_user/admin_users/shared/_links.erb +25 -0
  38. data/app/views/simple_user/admin_users/show.html.erb +15 -0
  39. data/app/views/simple_user/admin_users/unlocks/new.html.erb +16 -0
  40. data/app/views/simple_user/application/_menu_admin_users.html.erb +15 -0
  41. data/app/views/simple_user/application/_menu_users.html.erb +9 -0
  42. data/app/views/simple_user/users/_form.html.erb +14 -0
  43. data/app/views/simple_user/users/confirmations/new.html.erb +16 -0
  44. data/app/views/simple_user/users/edit.html.erb +6 -0
  45. data/app/views/simple_user/users/index.html.erb +31 -0
  46. data/app/views/simple_user/users/mailer/confirmation_instructions.html.erb +5 -0
  47. data/app/views/simple_user/users/mailer/reset_password_instructions.html.erb +8 -0
  48. data/app/views/simple_user/users/mailer/unlock_instructions.html.erb +7 -0
  49. data/app/views/simple_user/users/new.html.erb +5 -0
  50. data/app/views/simple_user/users/passwords/edit.html.erb +19 -0
  51. data/app/views/simple_user/users/passwords/new.html.erb +15 -0
  52. data/app/views/simple_user/users/registrations/edit.html.erb +30 -0
  53. data/app/views/simple_user/users/registrations/new.html.erb +20 -0
  54. data/app/views/simple_user/users/sessions/new.html.erb +15 -0
  55. data/app/views/simple_user/users/shared/_links.erb +25 -0
  56. data/app/views/simple_user/users/show.html.erb +25 -0
  57. data/app/views/simple_user/users/unlocks/new.html.erb +16 -0
  58. data/config/initializers/devise.rb +243 -0
  59. data/config/initializers/omniauth.rb +7 -0
  60. data/config/initializers/rolify.rb +8 -0
  61. data/config/locales/devise.en.yml +59 -0
  62. data/config/routes.rb +39 -0
  63. data/db/migrate/20130312215459_devise_create_simple_user_users.rb +50 -0
  64. data/db/migrate/20130312215519_devise_create_simple_user_admin_users.rb +48 -0
  65. data/db/migrate/20130312215950_create_simple_user_authentications.rb +13 -0
  66. data/db/migrate/20130312226960_rolify_create_roles.rb +19 -0
  67. data/db/seed.rb +9 -0
  68. data/lib/generators/simple_user/generate_views/generate_views_generator.rb +12 -0
  69. data/lib/generators/simple_user/install/install_generator.rb +20 -0
  70. data/lib/generators/simple_user/install/templates/devise_config.yml +1 -0
  71. data/lib/generators/simple_user/install/templates/fb_config.yml +3 -0
  72. data/lib/generators/simple_user/install/templates/simple_user.yml +3 -0
  73. data/lib/simple_user.rb +4 -0
  74. data/lib/simple_user/engine.rb +48 -0
  75. data/lib/simple_user/version.rb +3 -0
  76. data/lib/tasks/simple_user_tasks.rake +16 -0
  77. data/test/dummy/README.rdoc +261 -0
  78. data/test/dummy/Rakefile +7 -0
  79. data/test/dummy/app/assets/javascripts/application.js +16 -0
  80. data/test/dummy/app/assets/javascripts/welcome.js +2 -0
  81. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  82. data/test/dummy/app/assets/stylesheets/welcome.css +4 -0
  83. data/test/dummy/app/controllers/application_controller.rb +31 -0
  84. data/test/dummy/app/controllers/welcome_controller.rb +4 -0
  85. data/test/dummy/app/helpers/application_helper.rb +2 -0
  86. data/test/dummy/app/helpers/welcome_helper.rb +2 -0
  87. data/test/dummy/app/views/admin_users/_form.html.erb +15 -0
  88. data/test/dummy/app/views/admin_users/confirmations/new.html.erb +16 -0
  89. data/test/dummy/app/views/admin_users/edit.html.erb +6 -0
  90. data/test/dummy/app/views/admin_users/index.html.erb +27 -0
  91. data/test/dummy/app/views/admin_users/mailer/confirmation_instructions.html.erb +5 -0
  92. data/test/dummy/app/views/admin_users/mailer/reset_password_instructions.html.erb +8 -0
  93. data/test/dummy/app/views/admin_users/mailer/unlock_instructions.html.erb +7 -0
  94. data/test/dummy/app/views/admin_users/new.html.erb +5 -0
  95. data/test/dummy/app/views/admin_users/passwords/edit.html.erb +19 -0
  96. data/test/dummy/app/views/admin_users/passwords/new.html.erb +15 -0
  97. data/test/dummy/app/views/admin_users/registrations/edit.html.erb +28 -0
  98. data/test/dummy/app/views/admin_users/registrations/new.html.erb +18 -0
  99. data/test/dummy/app/views/admin_users/sessions/new.html.erb +15 -0
  100. data/test/dummy/app/views/admin_users/shared/_links.erb +25 -0
  101. data/test/dummy/app/views/admin_users/show.html.erb +15 -0
  102. data/test/dummy/app/views/admin_users/unlocks/new.html.erb +16 -0
  103. data/test/dummy/app/views/application/_menu_admin_users.html.erb +15 -0
  104. data/test/dummy/app/views/application/_menu_users.html.erb +9 -0
  105. data/test/dummy/app/views/layouts/application.html.erb +28 -0
  106. data/test/dummy/app/views/simple_user/admin_users/_form.html.erb +15 -0
  107. data/test/dummy/app/views/simple_user/admin_users/confirmations/new.html.erb +16 -0
  108. data/test/dummy/app/views/simple_user/admin_users/edit.html.erb +6 -0
  109. data/test/dummy/app/views/simple_user/admin_users/index.html.erb +27 -0
  110. data/test/dummy/app/views/simple_user/admin_users/mailer/confirmation_instructions.html.erb +5 -0
  111. data/test/dummy/app/views/simple_user/admin_users/mailer/reset_password_instructions.html.erb +8 -0
  112. data/test/dummy/app/views/simple_user/admin_users/mailer/unlock_instructions.html.erb +7 -0
  113. data/test/dummy/app/views/simple_user/admin_users/new.html.erb +5 -0
  114. data/test/dummy/app/views/simple_user/admin_users/passwords/edit.html.erb +19 -0
  115. data/test/dummy/app/views/simple_user/admin_users/passwords/new.html.erb +15 -0
  116. data/test/dummy/app/views/simple_user/admin_users/registrations/edit.html.erb +28 -0
  117. data/test/dummy/app/views/simple_user/admin_users/registrations/new.html.erb +18 -0
  118. data/test/dummy/app/views/simple_user/admin_users/sessions/new.html.erb +15 -0
  119. data/test/dummy/app/views/simple_user/admin_users/shared/_links.erb +25 -0
  120. data/test/dummy/app/views/simple_user/admin_users/show.html.erb +15 -0
  121. data/test/dummy/app/views/simple_user/admin_users/unlocks/new.html.erb +16 -0
  122. data/test/dummy/app/views/simple_user/application/_menu_admin_users.html.erb +15 -0
  123. data/test/dummy/app/views/simple_user/application/_menu_users.html.erb +9 -0
  124. data/test/dummy/app/views/simple_user/users/_form.html.erb +14 -0
  125. data/test/dummy/app/views/simple_user/users/confirmations/new.html.erb +16 -0
  126. data/test/dummy/app/views/simple_user/users/edit.html.erb +6 -0
  127. data/test/dummy/app/views/simple_user/users/index.html.erb +31 -0
  128. data/test/dummy/app/views/simple_user/users/mailer/confirmation_instructions.html.erb +5 -0
  129. data/test/dummy/app/views/simple_user/users/mailer/reset_password_instructions.html.erb +8 -0
  130. data/test/dummy/app/views/simple_user/users/mailer/unlock_instructions.html.erb +7 -0
  131. data/test/dummy/app/views/simple_user/users/new.html.erb +5 -0
  132. data/test/dummy/app/views/simple_user/users/passwords/edit.html.erb +19 -0
  133. data/test/dummy/app/views/simple_user/users/passwords/new.html.erb +15 -0
  134. data/test/dummy/app/views/simple_user/users/registrations/edit.html.erb +30 -0
  135. data/test/dummy/app/views/simple_user/users/registrations/new.html.erb +20 -0
  136. data/test/dummy/app/views/simple_user/users/sessions/new.html.erb +15 -0
  137. data/test/dummy/app/views/simple_user/users/shared/_links.erb +25 -0
  138. data/test/dummy/app/views/simple_user/users/show.html.erb +25 -0
  139. data/test/dummy/app/views/simple_user/users/unlocks/new.html.erb +16 -0
  140. data/test/dummy/app/views/welcome/index.html.erb +3 -0
  141. data/test/dummy/config.ru +4 -0
  142. data/test/dummy/config/application.rb +59 -0
  143. data/test/dummy/config/boot.rb +10 -0
  144. data/test/dummy/config/database.yml +25 -0
  145. data/test/dummy/config/devise_config.yml +1 -0
  146. data/test/dummy/config/environment.rb +5 -0
  147. data/test/dummy/config/environments/development.rb +37 -0
  148. data/test/dummy/config/environments/production.rb +67 -0
  149. data/test/dummy/config/environments/test.rb +37 -0
  150. data/test/dummy/config/fb_config.yml +3 -0
  151. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  152. data/test/dummy/config/initializers/inflections.rb +15 -0
  153. data/test/dummy/config/initializers/mime_types.rb +5 -0
  154. data/test/dummy/config/initializers/secret_token.rb +7 -0
  155. data/test/dummy/config/initializers/session_store.rb +8 -0
  156. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  157. data/test/dummy/config/locales/en.yml +5 -0
  158. data/test/dummy/config/routes.rb +7 -0
  159. data/test/dummy/db/development.sqlite3 +0 -0
  160. data/test/dummy/db/migrate/20130314021609_devise_create_simple_user_users.simple_user.rb +51 -0
  161. data/test/dummy/db/migrate/20130314021610_devise_create_simple_user_admin_users.simple_user.rb +49 -0
  162. data/test/dummy/db/migrate/20130314021611_create_simple_user_authentications.simple_user.rb +14 -0
  163. data/test/dummy/db/migrate/20130314021612_rolify_create_simple_user_roles.simple_user.rb +20 -0
  164. data/test/dummy/db/migrate/20130314222446_devise_create_simple_user_users.simple_user.rb +51 -0
  165. data/test/dummy/db/migrate/20130314222447_devise_create_simple_user_admin_users.simple_user.rb +49 -0
  166. data/test/dummy/db/migrate/20130314222448_create_simple_user_authentications.simple_user.rb +14 -0
  167. data/test/dummy/db/migrate/20130314222449_rolify_create_roles.simple_user.rb +20 -0
  168. data/test/dummy/db/schema.rb +87 -0
  169. data/test/dummy/log/development.log +100 -0
  170. data/test/dummy/public/404.html +26 -0
  171. data/test/dummy/public/422.html +26 -0
  172. data/test/dummy/public/500.html +25 -0
  173. data/test/dummy/public/favicon.ico +0 -0
  174. data/test/dummy/script/rails +6 -0
  175. data/test/dummy/test/functional/welcome_controller_test.rb +9 -0
  176. data/test/dummy/test/unit/helpers/welcome_helper_test.rb +4 -0
  177. data/test/dummy/tmp/cache/assets/C43/6A0/sprockets%2F9112a8a5c58f114023075f00ab994366 +0 -0
  178. data/test/dummy/tmp/cache/assets/C7B/190/sprockets%2F37b103f4623089af1456b90830fe941c +0 -0
  179. data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  180. data/test/dummy/tmp/cache/assets/D13/C60/sprockets%2F2dedb8177c20286c4259c1d58c5646cc +0 -0
  181. data/test/dummy/tmp/cache/assets/D21/5D0/sprockets%2Fe2c4f946939f2d7d0b42d86383755cae +0 -0
  182. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  183. data/test/dummy/tmp/cache/assets/D3E/F40/sprockets%2F25a167c7563d6fe8ec6b13ec1ac09274 +0 -0
  184. data/test/dummy/tmp/cache/assets/D43/A50/sprockets%2Fa41b368b71464f0a4feb19b6f875e44e +0 -0
  185. data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  186. data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  187. data/test/dummy/tmp/cache/assets/D92/950/sprockets%2Fcda629d2e4e4583027facd41bf1ea406 +0 -0
  188. data/test/dummy/tmp/cache/assets/DA0/140/sprockets%2F25f485eb0a9f28b68e69ab1c0f57c0da +0 -0
  189. data/test/dummy/tmp/cache/assets/DCF/BD0/sprockets%2Fc8b53c6aae12e5a5be5fe8db5472a793 +0 -0
  190. data/test/dummy/tmp/cache/assets/DD2/810/sprockets%2Fdc8aca3689d6b6e14aa38b7c88a46bc3 +0 -0
  191. data/test/dummy/tmp/cache/assets/DD8/CE0/sprockets%2F5de7f141c1d9dc26ce8af1ad6246d99f +0 -0
  192. data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  193. data/test/dummy/tmp/cache/assets/E02/930/sprockets%2Fec83bf6c33e43fb6a5cf38a52df8c60e +0 -0
  194. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  195. data/test/dummy/tmp/cache/assets/E2A/CE0/sprockets%2F17bd5e2fd8a5fd2d834c9dadfd102c2f +0 -0
  196. data/test/fixtures/simple_user/admin_users.yml +11 -0
  197. data/test/fixtures/simple_user/authentications.yml +13 -0
  198. data/test/fixtures/simple_user/users.yml +11 -0
  199. data/test/integration/navigation_test.rb +10 -0
  200. data/test/simple_user_test.rb +7 -0
  201. data/test/test_helper.rb +15 -0
  202. data/test/unit/simple_user/admin_user_test.rb +9 -0
  203. data/test/unit/simple_user/authentication_test.rb +9 -0
  204. data/test/unit/simple_user/user_test.rb +9 -0
  205. metadata +516 -0
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YjliMDI4Yjk2ODYxMWQ1ZjZhMjY1NDhkNDUyZDA0ZTU4MWE5ZTRhMw==
5
+ data.tar.gz: !binary |-
6
+ Y2RiYzJiYTVkOTE2YTBmYzA5ZTMxNGI2NDI4YmNmYWYxYjMwZmUwMA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NTM4NDljMjU5ZmU2NWZlM2I0NWZlMzU3ZmM0YzMwNjIyOWQ5MmMyNjc1ZTUz
10
+ YTA3NzU1OWEzZWRlMDAzYWU0MmE0YWJjZTVjYjY5ZDJmMGU5MDIyMWI3YjA0
11
+ ODVlZmViMjJkY2ZmYTIwNzczNTE5ZTI0MmQ0ZTY3Y2M0ODFlOTA=
12
+ data.tar.gz: !binary |-
13
+ N2ViY2VmY2E1NTA1NDNjYTU1YjlhZmYxY2Y0ZTEyZGY0NjBkZjgyMTViNjdk
14
+ ODljMTRlMTYwMzRjMTFkNDY3MjJmOGU2MzE2ZjdiNTZkYTFiNzY2MWUzYjUw
15
+ NDUxOTA5ZGNhMDE2ZTcxN2YwNDU0OTYwYzcyNTYyYWYzYzNkZDQ=
@@ -0,0 +1,20 @@
1
+ Copyright 2013 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,35 @@
1
+ = SimpleUser
2
+
3
+ Manage users and admins with Devise and Omniauth-Facebook.
4
+
5
+ Make avaiable to your users for loggin with Devise or Facebook, and manage them and your admins. Each admin is related to roles with Rolify, and manages authorization with CanCan.
6
+
7
+
8
+ == Installation
9
+
10
+ 1. Add to your gemfile: <tt>gem 'simple_user', :git => 'git://github.com/pablomarti/simple_user.git'</tt>
11
+
12
+ 2. Run <tt>bundle</tt>
13
+
14
+ 3. Execute: <tt>rails generate simple_user:install</tt>
15
+
16
+ 4. Run migrations: <tt>rake db:migrate</tt>
17
+
18
+ 5. Run seeds: <tt>rake db:seed</tt>
19
+
20
+ 6. Add to your routes.rb: <tt>mount SimpleUser::Engine => "/simple_user", :as => "simple_user"</tt>
21
+
22
+ 7. Watch the test/dummy for an example of the links
23
+
24
+
25
+ == TODO
26
+
27
+ 1. List the methods for the links
28
+
29
+ 2. Explain integration with models of the parent app
30
+
31
+ 3. Integrate Twitter
32
+
33
+ 4. Ingrate Google
34
+
35
+ 5. Remove unnecessary files and codes (rake task, omniauth, ...)
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'SimpleUser'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+
28
+ Bundler::GemHelper.install_tasks
29
+
30
+ require 'rake/testtask'
31
+
32
+ Rake::TestTask.new(:test) do |t|
33
+ t.libs << 'lib'
34
+ t.libs << 'test'
35
+ t.pattern = 'test/**/*_test.rb'
36
+ t.verbose = false
37
+ end
38
+
39
+
40
+ task :default => :test
@@ -0,0 +1,15 @@
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
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,33 @@
1
+ (function() {
2
+ jQuery(function() {
3
+ $('body').prepend('<div id="fb-root"></div>');
4
+ return $.ajax({
5
+ url: "" + window.location.protocol + "//connect.facebook.net/en_US/all.js",
6
+ dataType: 'script',
7
+ cache: true
8
+ });
9
+ });
10
+
11
+ window.fbAsyncInit = function() {
12
+ FB.init({
13
+ appId: "<%= ENV['FACEBOOK_KEY'] %>",
14
+ cookie: true
15
+ });
16
+ $('#sign_in').click(function(e) {
17
+ e.preventDefault();
18
+ FB.login(function(response) {
19
+ if (response.authResponse) {
20
+ return window.location = '/simple_user/auth/facebook/callback';
21
+ }
22
+ }, {scope: 'email,user_birthday'});
23
+ });
24
+ return $('#sign_out').click(function(e) {
25
+ FB.getLoginStatus(function(response) {
26
+ if (response.authResponse) {
27
+ return FB.logout();
28
+ }
29
+ });
30
+ return true;
31
+ });
32
+ };
33
+ }).call(this);
@@ -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,7 @@
1
+ module SimpleUser
2
+ class AdminUsers::RegistrationsController < Devise::RegistrationsController
3
+
4
+ layout ENV['ADMIN_LAYOUT']
5
+
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ module SimpleUser
2
+ class AdminUsers::SessionsController < Devise::SessionsController
3
+
4
+ layout ENV['ADMIN_LAYOUT']
5
+
6
+ protected
7
+
8
+ def after_sign_in_path_for(resource)
9
+ if resource.banned?
10
+ sign_out resource
11
+ flash.delete(:notice)
12
+ flash[:error] = "This account has been suspended."
13
+ root_path
14
+ else
15
+ ENV['ADMIN_PATH']
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,134 @@
1
+ module SimpleUser
2
+ class AdminUsersController < ApplicationController
3
+
4
+ layout ENV['ADMIN_LAYOUT']
5
+
6
+ before_filter :authenticate_admin_user!
7
+ before_filter :authorize_admin_user_manager
8
+
9
+ def index
10
+ @admin_users = AdminUser.get_editable_admins_except(current_admin_user.id)
11
+
12
+ respond_to do |format|
13
+ format.html # index.html.erb
14
+ format.json { render json: @admin_users }
15
+ end
16
+ end
17
+
18
+ def show
19
+ @admin_user = AdminUser.find(params[:id])
20
+
21
+ respond_to do |format|
22
+ format.html # show.html.erb
23
+ format.json { render json: @admin_user }
24
+ end
25
+ end
26
+
27
+ def new
28
+ @admin_user = AdminUser.new
29
+ @required_password = true
30
+
31
+ respond_to do |format|
32
+ format.html # new.html.erb
33
+ format.json { render json: @admin_user }
34
+ end
35
+ end
36
+
37
+ def edit
38
+ @admin_user = AdminUser.find(params[:id])
39
+
40
+ if @admin_user.has_role? :admin
41
+ flash[:error] = "Access denied"
42
+ redirect_to root_url
43
+ end
44
+
45
+ @admin_user.get_roles
46
+ @required_password = false
47
+ end
48
+
49
+ def create
50
+ @admin_user = AdminUser.new(params[:admin_user])
51
+ @required_password = true
52
+
53
+ roles = []
54
+ if can? :manage, Role
55
+ roles = params[:admin_user][:temporal_roles].split(",")
56
+ end
57
+ params[:admin_user].delete(:temporal_roles)
58
+
59
+ respond_to do |format|
60
+ if @admin_user.save
61
+ if can? :manage, Role
62
+ roles.map{ |role|
63
+ @admin_user.add_role role.strip
64
+ }
65
+ end
66
+
67
+ format.html { redirect_to @admin_user, notice: 'Admin was successfully created.' }
68
+ format.json { render json: @admin_user, status: :created, location: @admin_user }
69
+ else
70
+ format.html { render action: "new" }
71
+ format.json { render json: @admin_user.errors, status: :unprocessable_entity }
72
+ end
73
+ end
74
+ end
75
+
76
+ def update
77
+ @admin_user = AdminUser.find(params[:id])
78
+ @required_password = false
79
+
80
+ if @admin_user.has_role? :admin
81
+ flash[:error] = "Access denied"
82
+ redirect_to root_url
83
+ end
84
+
85
+ roles = []
86
+ if can? :manage, Role
87
+ roles = params[:admin_user][:temporal_roles].split(",")
88
+ end
89
+ params[:admin_user].delete(:temporal_roles)
90
+
91
+ if params[:admin_user][:password].blank?
92
+ params[:admin_user].delete(:password)
93
+ params[:admin_user].delete(:password_confirmation)
94
+ end
95
+
96
+ respond_to do |format|
97
+ if @admin_user.update_attributes(params[:admin_user])
98
+ if can? :manage, Role
99
+ @admin_user.roles.destroy_all
100
+
101
+ roles.map{ |role|
102
+ @admin_user.add_role role.strip
103
+ }
104
+ end
105
+
106
+ format.html { redirect_to @admin_user, notice: 'Admin was successfully updated.' }
107
+ format.json { head :no_content }
108
+ else
109
+ @admin_user.get_roles
110
+ format.html { render action: "edit" }
111
+ format.json { render json: @admin_user.errors, status: :unprocessable_entity }
112
+ end
113
+ end
114
+ end
115
+
116
+ def destroy
117
+ @admin_user = AdminUser.find(params[:id])
118
+ @admin_user.destroy
119
+
120
+ respond_to do |format|
121
+ format.html { redirect_to admin_users_url }
122
+ format.json { head :no_content }
123
+ end
124
+ end
125
+
126
+ def authorize_admin_user_manager
127
+ if !can? :manage, AdminUser
128
+ flash[:error] = "Access denied"
129
+ redirect_to root_url
130
+ end
131
+ end
132
+
133
+ end
134
+ end
@@ -0,0 +1,7 @@
1
+ module SimpleUser
2
+ class ApplicationController < ::ApplicationController
3
+
4
+ layout ENV['APPLICATION_LAYOUT']
5
+
6
+ end
7
+ end
@@ -0,0 +1,26 @@
1
+ module SimpleUser
2
+ class AuthController < ApplicationController
3
+
4
+ def create
5
+ auth = request.env["omniauth.auth"]
6
+ authentication = Authentication.find_by_provider_and_uid(auth['provider'], auth['uid'])
7
+
8
+ if authentication
9
+ flash[:notice] = "Signed in successfully."
10
+ sign_in(:user, authentication.user)
11
+ redirect_to root_url
12
+ else
13
+ user = User.build_new_auth(auth)
14
+ if user.save(:validate => false)
15
+ flash[:notice] = "Account created and signed in successfully."
16
+ sign_in(:user, user)
17
+ redirect_to root_url
18
+ else
19
+ flash[:error] = "Error while creating the user account. Please try again."
20
+ redirect_to root_url
21
+ end
22
+ end
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,5 @@
1
+ module SimpleUser
2
+ class Users::RegistrationsController < Devise::RegistrationsController
3
+
4
+ end
5
+ end
@@ -0,0 +1,41 @@
1
+ module SimpleUser
2
+ class Users::SessionsController < Devise::SessionsController
3
+
4
+ def create
5
+ self.resource = warden.authenticate!(auth_options)
6
+ #self.resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#failure")
7
+ set_flash_message(:notice, :signed_in) if is_navigational_format?
8
+ sign_in(resource_name, resource)
9
+ respond_with resource, :location => after_sign_in_path_for(resource)
10
+ end
11
+
12
+ #def failure
13
+ #return render :json => {:success => false, :errors => ["Login failed"]}
14
+ #end
15
+
16
+ protected
17
+
18
+ def after_sign_in_path_for(resource)
19
+ if resource.banned?
20
+ sign_out resource
21
+ flash.delete(:notice)
22
+ flash[:error] = "This account has been suspended."
23
+ root_path
24
+ else
25
+ super
26
+ end
27
+ end
28
+
29
+ def serialize_options(resource)
30
+ methods = resource_class.authentication_keys.dup
31
+ methods = methods.keys if methods.is_a?(Hash)
32
+ methods << :password if resource.respond_to?(:password)
33
+ { :methods => methods, :only => [:password] }
34
+ end
35
+
36
+ def auth_options
37
+ { :scope => resource_name, :recall => "#{controller_path}#new" }
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,88 @@
1
+ module SimpleUser
2
+ class UsersController < ApplicationController
3
+
4
+ layout ENV['ADMIN_LAYOUT']
5
+
6
+ before_filter :authenticate_admin_user!
7
+ before_filter :authorize_user_manager
8
+
9
+ def index
10
+ @users = User.all
11
+
12
+ respond_to do |format|
13
+ format.html # index.html.erb
14
+ format.json { render json: @users }
15
+ end
16
+ end
17
+
18
+ def show
19
+ @user = User.find(params[:id])
20
+
21
+ respond_to do |format|
22
+ format.html # show.html.erb
23
+ format.json { render json: @user }
24
+ end
25
+ end
26
+
27
+ def new
28
+ @user = User.new
29
+
30
+ respond_to do |format|
31
+ format.html # new.html.erb
32
+ format.json { render json: @user }
33
+ end
34
+ end
35
+
36
+ def edit
37
+ @user = User.find(params[:id])
38
+ end
39
+
40
+ def create
41
+ @user = User.new(params[:user])
42
+
43
+ respond_to do |format|
44
+ if @user.save
45
+ logger.debug "SAVE"
46
+ format.html { redirect_to @user, notice: 'User was successfully created.' }
47
+ format.json { render json: @user, status: :created, location: @user }
48
+ else
49
+ logger.debug "ERROR: #{@user.errors.inspect}"
50
+ format.html { render action: "new" }
51
+ format.json { render json: @user.errors, status: :unprocessable_entity }
52
+ end
53
+ end
54
+ end
55
+
56
+ def update
57
+ @user = User.find(params[:id])
58
+
59
+ respond_to do |format|
60
+ if @user.update_attributes(params[:user])
61
+ format.html { redirect_to @user, notice: 'User was successfully updated.' }
62
+ format.json { head :no_content }
63
+ else
64
+ format.html { render action: "edit" }
65
+ format.json { render json: @user.errors, status: :unprocessable_entity }
66
+ end
67
+ end
68
+ end
69
+
70
+ def destroy
71
+ @user = User.find(params[:id])
72
+ @user.destroy
73
+
74
+ respond_to do |format|
75
+ format.html { redirect_to users_url }
76
+ format.json { head :no_content }
77
+ end
78
+ end
79
+
80
+ def authorize_user_manager
81
+ if !can? :manage, User
82
+ flash[:error] = "Access denied"
83
+ redirect_to root_url
84
+ end
85
+ end
86
+
87
+ end
88
+ end