hello-rails 0.0.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (235) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +97 -0
  4. data/Rakefile +23 -0
  5. data/app/controllers/hello/application_controller.rb +27 -0
  6. data/app/controllers/hello/authentication/sessions_controller.rb +81 -0
  7. data/app/controllers/hello/authentication/sign_in_controller.rb +39 -0
  8. data/app/controllers/hello/authentication/sudo_mode_controller.rb +40 -0
  9. data/app/controllers/hello/concerns/authentication/sign_in.rb +44 -0
  10. data/app/controllers/hello/concerns/management/forgot_password.rb +45 -0
  11. data/app/controllers/hello/concerns/management/reset_password.rb +33 -0
  12. data/app/controllers/hello/concerns/registration/sign_up.rb +64 -0
  13. data/app/controllers/hello/internationalization/locale_controller.rb +28 -0
  14. data/app/controllers/hello/management/accesses_controller.rb +29 -0
  15. data/app/controllers/hello/management/confirm_emails_controller.rb +41 -0
  16. data/app/controllers/hello/management/emails_controller.rb +67 -0
  17. data/app/controllers/hello/management/forgot_password_controller.rb +41 -0
  18. data/app/controllers/hello/management/passwords_controller.rb +57 -0
  19. data/app/controllers/hello/management/profiles_controller.rb +71 -0
  20. data/app/controllers/hello/management/reset_password_controller.rb +53 -0
  21. data/app/controllers/hello/registration/sign_up_controller.rb +63 -0
  22. data/app/helpers/hello/application_helper.rb +5 -0
  23. data/app/mailers/hello/mailer.rb +26 -0
  24. data/app/models/access.rb +2 -0
  25. data/app/models/credential.rb +2 -0
  26. data/app/models/email_credential.rb +2 -0
  27. data/app/models/password_credential.rb +2 -0
  28. data/app/models/user.rb +2 -0
  29. data/app/views/hello/authentication/_sign_in.html.erb +64 -0
  30. data/app/views/hello/authentication/new_session.html.erb +4 -0
  31. data/app/views/hello/authentication/sessions.html.erb +36 -0
  32. data/app/views/hello/authentication/sign_in.html.erb +3 -0
  33. data/app/views/hello/authentication/sudo_mode.html.erb +37 -0
  34. data/app/views/hello/internationalization/locales.html.erb +7 -0
  35. data/app/views/hello/mailer/confirm_email.html.erb +12 -0
  36. data/app/views/hello/mailer/forgot_password.html.erb +12 -0
  37. data/app/views/hello/mailer/welcome.html.erb +11 -0
  38. data/app/views/hello/management/accesses.html.erb +47 -0
  39. data/app/views/hello/management/cancel.html.erb +14 -0
  40. data/app/views/hello/management/email_credentials/expired_confirmation_token.html.erb +1 -0
  41. data/app/views/hello/management/email_credentials/index.html.erb +84 -0
  42. data/app/views/hello/management/password_credentials/_forgot_form.html.erb +17 -0
  43. data/app/views/hello/management/password_credentials/_reset_form.html.erb +39 -0
  44. data/app/views/hello/management/password_credentials/forgot.html.erb +10 -0
  45. data/app/views/hello/management/password_credentials/forgot_success.html.erb +26 -0
  46. data/app/views/hello/management/password_credentials/reset.html.erb +3 -0
  47. data/app/views/hello/management/password_credentials/show.html.erb +25 -0
  48. data/app/views/hello/management/user.html.erb +73 -0
  49. data/app/views/hello/registration/_sign_up.html.erb +86 -0
  50. data/app/views/hello/registration/sign_up.html.erb +3 -0
  51. data/app/views/hello/registration/sign_up_widget.html.erb +3 -0
  52. data/app/views/hello/shared/_errors.html.erb +11 -0
  53. data/app/views/hello/shared/_flash.html.erb +8 -0
  54. data/app/views/hello/shared/_nav_pills.html.erb +15 -0
  55. data/app/views/hello/shared/_session_expiration.html.erb +15 -0
  56. data/app/views/hello/shared/_settings.html.erb +41 -0
  57. data/config/locales/hello.en.yml +69 -0
  58. data/config/locales/hello.es.yml +71 -0
  59. data/config/locales/hello.fr.yml +71 -0
  60. data/config/locales/hello.pl.yml +71 -0
  61. data/config/locales/hello.pt-BR.yml +71 -0
  62. data/config/locales/hello.zh-CN.yml +71 -0
  63. data/config/locales/hello.zh-TW.yml +71 -0
  64. data/config/routes.rb +74 -0
  65. data/db/migrate/1_create_credentials.rb +17 -0
  66. data/db/migrate/2_create_accesses.rb +15 -0
  67. data/db/migrate/3_create_users.rb +23 -0
  68. data/lib/generators/hello/concerns/USAGE +8 -0
  69. data/lib/generators/hello/concerns/concerns_generator.rb +10 -0
  70. data/lib/generators/hello/from_devise/USAGE +8 -0
  71. data/lib/generators/hello/from_devise/from_devise_generator.rb +13 -0
  72. data/lib/generators/hello/from_devise/templates/from_devise.migration.rb +39 -0
  73. data/lib/generators/hello/install/USAGE +8 -0
  74. data/lib/generators/hello/install/install_generator.rb +94 -0
  75. data/lib/generators/hello/install/templates/application.html.erb +35 -0
  76. data/lib/generators/hello/install/templates/hello_helper.rb +16 -0
  77. data/lib/generators/hello/install/templates/initializer.rb +24 -0
  78. data/lib/generators/hello/install/templates/models/concerns/user/authorization.rb +21 -0
  79. data/lib/generators/hello/install/templates/models/user.rb +9 -0
  80. data/lib/generators/hello/install/templates/onboarding/index.html.erb +5 -0
  81. data/lib/generators/hello/install/templates/onboarding/onboarding_controller.rb +33 -0
  82. data/lib/generators/hello/install/templates/root/index.html.erb +7 -0
  83. data/lib/generators/hello/install/templates/root/root_controller.rb +6 -0
  84. data/lib/generators/hello/install/templates/users/controllers/users_controller.rb +71 -0
  85. data/lib/generators/hello/install/templates/users/views/users/index.html.erb +29 -0
  86. data/lib/generators/hello/install/templates/users/views/users/list.html.erb +35 -0
  87. data/lib/generators/hello/install/templates/users/views/users/new.html.erb +60 -0
  88. data/lib/generators/hello/install/templates/users/views/users/show.html.erb +74 -0
  89. data/lib/generators/hello/locales/USAGE +12 -0
  90. data/lib/generators/hello/locales/locales_generator.rb +64 -0
  91. data/lib/generators/hello/views/USAGE +8 -0
  92. data/lib/generators/hello/views/views_generator.rb +9 -0
  93. data/lib/hello-rails.rb +1 -0
  94. data/lib/hello.rb +36 -0
  95. data/lib/hello/CHANGES.md +26 -0
  96. data/lib/hello/business.rb +47 -0
  97. data/lib/hello/business/authentication/sign_in.rb +92 -0
  98. data/lib/hello/business/authentication/sign_out.rb +8 -0
  99. data/lib/hello/business/authentication/sudo_mode_authentication.rb +25 -0
  100. data/lib/hello/business/authentication/sudo_mode_expiration.rb +17 -0
  101. data/lib/hello/business/base.rb +33 -0
  102. data/lib/hello/business/internationalization/update_locale.rb +33 -0
  103. data/lib/hello/business/management/add_email.rb +19 -0
  104. data/lib/hello/business/management/cancel_account.rb +22 -0
  105. data/lib/hello/business/management/confirm_email.rb +36 -0
  106. data/lib/hello/business/management/forgot_password.rb +47 -0
  107. data/lib/hello/business/management/remove_email.rb +19 -0
  108. data/lib/hello/business/management/reset_password.rb +34 -0
  109. data/lib/hello/business/management/send_confirmation_email.rb +40 -0
  110. data/lib/hello/business/management/unlink_access.rb +8 -0
  111. data/lib/hello/business/management/update_profile.rb +44 -0
  112. data/lib/hello/business/registration/sign_up.rb +159 -0
  113. data/lib/hello/configuration.rb +12 -0
  114. data/lib/hello/encryptors.rb +6 -0
  115. data/lib/hello/encryptors/complex.rb +25 -0
  116. data/lib/hello/encryptors/simple.rb +27 -0
  117. data/lib/hello/engine.rb +23 -0
  118. data/lib/hello/errors.rb +12 -0
  119. data/lib/hello/locales.rb +238 -0
  120. data/lib/hello/middleware.rb +13 -0
  121. data/lib/hello/rails_active_record.rb +10 -0
  122. data/lib/hello/rails_active_record/access.rb +65 -0
  123. data/lib/hello/rails_active_record/credential.rb +51 -0
  124. data/lib/hello/rails_active_record/email_credential.rb +60 -0
  125. data/lib/hello/rails_active_record/password_credential.rb +70 -0
  126. data/lib/hello/rails_active_record/user.rb +99 -0
  127. data/lib/hello/rails_controller.rb +124 -0
  128. data/lib/hello/rails_controller/restrict_by_role.rb +79 -0
  129. data/lib/hello/rails_helper.rb +35 -0
  130. data/lib/hello/request_manager.rb +14 -0
  131. data/lib/hello/request_manager/abstract.rb +77 -0
  132. data/lib/hello/request_manager/factory.rb +32 -0
  133. data/lib/hello/request_manager/stateful.rb +53 -0
  134. data/lib/hello/request_manager/stateful/finder.rb +58 -0
  135. data/lib/hello/request_manager/stateful/session_wrapper.rb +37 -0
  136. data/lib/hello/request_manager/stateless.rb +35 -0
  137. data/lib/hello/time_zones.rb +7 -0
  138. data/lib/hello/utils.rb +11 -0
  139. data/lib/hello/utils/device_name.rb +34 -0
  140. data/lib/hello/version.rb +4 -0
  141. data/lib/tasks/hello_tasks.rake +4 -0
  142. data/spec/bdd/hello/authentication/authorization/authorization_role_restriction_spec.rb +291 -0
  143. data/spec/bdd/hello/authentication/authorization/authorization_router_constraints_spec.rb +41 -0
  144. data/spec/bdd/hello/authentication/authorization/authorization_sensitive_restriction_spec.rb +84 -0
  145. data/spec/bdd/hello/authentication/authorization/bdd.yml +1 -0
  146. data/spec/bdd/hello/authentication/bdd.yml +1 -0
  147. data/spec/bdd/hello/authentication/classic_sign_in_spec.rb +264 -0
  148. data/spec/bdd/hello/authentication/manage_sessions_spec.rb +292 -0
  149. data/spec/bdd/hello/authentication/sign_out_spec.rb +159 -0
  150. data/spec/bdd/hello/bdd.yml +1 -0
  151. data/spec/bdd/hello/internalionalization/anyone_can_change_their_locale/bdd.yml +1 -0
  152. data/spec/bdd/hello/internalionalization/anyone_can_change_their_locale/change_locale_on_the_locale_page_spec.rb +90 -0
  153. data/spec/bdd/hello/internalionalization/anyone_can_change_their_locale/change_locale_on_the_profile_page_spec.rb +64 -0
  154. data/spec/bdd/hello/internalionalization/anyone_can_change_their_locale/change_locale_on_the_sign_in_form_spec.rb +31 -0
  155. data/spec/bdd/hello/internalionalization/anyone_can_change_their_locale/change_locale_on_the_sign_up_form_spec.rb +34 -0
  156. data/spec/bdd/hello/internalionalization/anyone_can_change_their_timezone/bdd.yml +1 -0
  157. data/spec/bdd/hello/internalionalization/anyone_can_change_their_timezone/change_timezone_on_the_profile_page_spec.rb +14 -0
  158. data/spec/bdd/hello/internalionalization/anyone_can_change_their_timezone/change_timezone_on_the_sign_in_form_spec.rb +14 -0
  159. data/spec/bdd/hello/internalionalization/anyone_can_change_their_timezone/change_timezone_on_the_sign_up_form_spec.rb +14 -0
  160. data/spec/bdd/hello/internalionalization/bdd.yml +1 -0
  161. data/spec/bdd/hello/management/bdd.yml +1 -0
  162. data/spec/bdd/hello/management/cancel_account_spec.rb +128 -0
  163. data/spec/bdd/hello/management/manage_email_credentials/bdd.yml +1 -0
  164. data/spec/bdd/hello/management/manage_email_credentials/manage_email_credentials_emails_api_spec.rb +7 -0
  165. data/spec/bdd/hello/management/manage_email_credentials/manage_email_credentials_emails_page_spec.rb +252 -0
  166. data/spec/bdd/hello/management/manage_password_credentials/bdd.yml +1 -0
  167. data/spec/bdd/hello/management/manage_password_credentials/manage_password_forgot_password_spec.rb +68 -0
  168. data/spec/bdd/hello/management/manage_password_credentials/manage_password_page_spec.rb +60 -0
  169. data/spec/bdd/hello/management/manage_password_credentials/manage_password_reset_password_spec.rb +145 -0
  170. data/spec/bdd/hello/management/manage_profile/bdd.yml +1 -0
  171. data/spec/bdd/hello/management/manage_profile/manage_profile_api_spec.rb +7 -0
  172. data/spec/bdd/hello/management/manage_profile/manage_profile_page_spec.rb +65 -0
  173. data/spec/bdd/hello/management/manage_social_credentials/bdd.yml +1 -0
  174. data/spec/bdd/hello/management/manage_social_credentials/manage_social_credentials_pending_spec.rb +7 -0
  175. data/spec/bdd/hello/management/unlink_sessions_spec.rb +59 -0
  176. data/spec/bdd/hello/other/bdd.yml +1 -0
  177. data/spec/bdd/hello/other/create_user_spec.rb +70 -0
  178. data/spec/bdd/hello/other/impersonate_user_spec.rb +58 -0
  179. data/spec/bdd/hello/other/list_users_spec.rb +86 -0
  180. data/spec/bdd/hello/registration/bdd.yml +1 -0
  181. data/spec/bdd/hello/registration/classic_sign_up_spec.rb +228 -0
  182. data/spec/bdd/hello/registration/onboarding_process_spec.rb +101 -0
  183. data/spec/bdd/hello/support.rb +62 -0
  184. data/spec/business/hello/authentication/sign_in_spec.rb +72 -0
  185. data/spec/business/hello/registration/sign_up_spec.rb +258 -0
  186. data/spec/controllers/authentication_spec.rb +97 -0
  187. data/spec/controllers/localization_spec.rb +65 -0
  188. data/spec/controllers/request_can_carry_an_access_token_spec.rb +223 -0
  189. data/spec/fixtures/hello/password_mailer/confirmation +3 -0
  190. data/spec/fixtures/hello/password_mailer/forgot +3 -0
  191. data/spec/fixtures/hello/password_mailer/sign_up +3 -0
  192. data/spec/mailers/hello/mailer_spec.rb +53 -0
  193. data/spec/models/access_spec.rb +19 -0
  194. data/spec/models/credential_spec.rb +9 -0
  195. data/spec/models/email_credential_spec.rb +163 -0
  196. data/spec/models/hello/sign_up_model_spec.rb +64 -0
  197. data/spec/models/password_credential_spec.rb +75 -0
  198. data/spec/models/user_spec.rb +93 -0
  199. data/spec/others/configuration_spec.rb +25 -0
  200. data/spec/others/encryptors/complex_spec.rb +26 -0
  201. data/spec/others/encryptors/simple_spec.rb +21 -0
  202. data/spec/others/helper_spec.rb +10 -0
  203. data/spec/others/localization_consistency_spec.rb +73 -0
  204. data/spec/requests/forgot_password_spec.rb +36 -0
  205. data/spec/requests/reset_password_spec.rb +7 -0
  206. data/spec/requests/security/user_spec.rb +19 -0
  207. data/spec/routing/hello/accesses_routing_spec.rb +17 -0
  208. data/spec/routing/hello/emails_routing_spec.rb +37 -0
  209. data/spec/routing/hello/locale_routing_spec.rb +17 -0
  210. data/spec/routing/hello/profile_routing_spec.rb +29 -0
  211. data/spec/routing/hello/registration_routing_spec.rb +23 -0
  212. data/spec/routing/hello/sign_out_routing_spec.rb +11 -0
  213. data/spec/routing/hello/sudo_mode_routing_spec.rb +23 -0
  214. data/spec/routing/hello/users_routing_spec.rb +15 -0
  215. data/spec/spec_helper.rb +9 -0
  216. data/spec/spec_helper/codeclimate.rb +2 -0
  217. data/spec/spec_helper/configure_rspec.rb +23 -0
  218. data/spec/spec_helper/create_database.rb +5 -0
  219. data/spec/spec_helper/dummy_and_test_dependencies.rb +17 -0
  220. data/spec/spec_helper/support.rb +1 -0
  221. data/spec/support/factories.rb +60 -0
  222. data/spec/support/feature_injection.rb +118 -0
  223. data/spec/support/features/feature_support_given.rb +46 -0
  224. data/spec/support/features/feature_support_then.rb +43 -0
  225. data/spec/support/helpers/aliases.rb +76 -0
  226. data/spec/support/helpers/configuration.rb +6 -0
  227. data/spec/support/helpers/current.rb +16 -0
  228. data/spec/support/helpers/expect.rb +61 -0
  229. data/spec/support/helpers/given.rb +49 -0
  230. data/spec/support/helpers/shortcuts.rb +24 -0
  231. data/spec/support/helpers/then.rb +29 -0
  232. data/spec/support/helpers/when.rb +108 -0
  233. data/spec/support/requests/request_support.rb +8 -0
  234. data/spec/utils/device_name_spec.rb +228 -0
  235. metadata +562 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3502b6ca704668b91fc1476d655b0c901a5cb919
4
- data.tar.gz: ab3e8445e7e6638618a583e131cc98ddd4afec9d
3
+ metadata.gz: 3d623ee25f1fc28412e0a5fc5eed21dabfcfa960
4
+ data.tar.gz: 2ebf9a76d24e8774ddb50b3d4e819ebaf257181e
5
5
  SHA512:
6
- metadata.gz: 7a874db2f39c975c7d58cdff0391fef215785a90c7f843579b312469bfb3ab4689027bd7f4d8c04ce1003c580aca66d4aedb536164c3c9608249a67be8c91566
7
- data.tar.gz: 4f9391fd5cbc399ec41c8c61e95467bed1db92abb626fd7e55f0a1d970f14b678b3902ba24dc29a16e14b5020c49c89a791400b03123fe7e581ee236a9e1a40f
6
+ metadata.gz: 58560a0be5c927cd1acfd195441d247213f989e12b7af35096eb81e2a27f07011ff5775481662056df79495e432e8235c64b4da11a6ce3df838af16621167403
7
+ data.tar.gz: cf9c6068cad04ce290d4479736b31c8853ecd17d4f5f9109b44fcc64418f18098b33ce9a80c3d03ec1b2461bd0e3499acb763d29159ff8c45ff742c9811be736
@@ -0,0 +1,20 @@
1
+ Copyright 2014 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,97 @@
1
+ # Hello
2
+
3
+ A Rails Engine.<br>
4
+ Provides a set of valuable features for Registration, Authentication, Management and Internationalization.
5
+
6
+
7
+
8
+
9
+
10
+ ## Tested With The Latest
11
+
12
+ | <image width=16 src='https://www.ruby-lang.org/images/header-ruby-logo.png'> Ruby 2.3.0 | <image width=16 src='https://www.ruby-lang.org/images/header-ruby-logo.png'> Ruby 2.4.0-dev | <image width=16 src='https://upload.wikimedia.org/wikipedia/en/thumb/e/e9/Ruby_on_Rails.svg/16px-Ruby_on_Rails.svg.png'> Rails 4.2.6 | <image width=16 src='https://upload.wikimedia.org/wikipedia/en/thumb/e/e9/Ruby_on_Rails.svg/16px-Ruby_on_Rails.svg.png'> Rails 5.0.0-dev |
13
+ | :--- | :--- | :--- | :--- |
14
+
15
+
16
+
17
+
18
+
19
+ ## Status
20
+
21
+ | Is It Working? | Is It Tested? | Code Quality |
22
+ |:---|:---|:---|
23
+ | [![Master Build Status](https://api.travis-ci.org/hello-gem/hello.svg?branch=master)](https://travis-ci.org/hello-gem/hello) | [![Code Climate](https://codeclimate.com/github/hello-gem/hello/coverage.svg)](https://codeclimate.com/github/hello-gem/hello) | [![Code Climate](https://codeclimate.com/github/hello-gem/hello.svg)](https://codeclimate.com/github/hello-gem/hello) |
24
+ | **# of Downloads** | **Maintainance Status** | **Get Involved!** |
25
+ | [![Downloads](http://img.shields.io/gem/dt/hello.svg)](https://rubygems.org/gems/hello) | [![Dependency Status](https://gemnasium.com/badges/github.com/hello-gem/hello.svg)](https://gemnasium.com/github.com/hello-gem/hello) | [![GitHub Issues](https://img.shields.io/github/issues/hello-gem/hello.svg)](https://github.com/hello-gem/hello/issues) |
26
+
27
+
28
+
29
+
30
+
31
+
32
+ ## Install
33
+
34
+ ```ruby
35
+ Gemfile
36
+
37
+ gem 'hello-rails'
38
+ gem 'bcrypt' # bcrypt is a requirement
39
+ gem 'nav_lynx' # nav_lynx is optional, add it if you are using hello for the first time
40
+ ```
41
+
42
+ ```shell
43
+ Terminal
44
+
45
+ bundle install
46
+ bundle exec rails generate hello:install
47
+ bundle exec rake db:migrate
48
+ ```
49
+
50
+
51
+
52
+
53
+
54
+ ## How To
55
+
56
+ * Please read [Customizing](https://github.com/hello-gem/hello/blob/master/CUSTOMIZING.md)
57
+ * Chat: [Gitter chat](https://gitter.im/hello-gem/hello)
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+ ## Contributing
66
+
67
+ * Please read [Running Tests](https://github.com/hello-gem/hello/blob/master/gemfiles) and [Contributing](https://github.com/hello-gem/hello/blob/master/CONTRIBUTING.md)
68
+
69
+
70
+
71
+
72
+
73
+ ## Versions
74
+
75
+ [Semantic Versioning 2.0.0](http://semver.org)
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+ # Thank You
84
+
85
+ [Tim Lucas](https://github.com/toolmantim), [John Nunemaker](https://github.com/jnunemaker), [Dan Everton](https://github.com/deverton) and [Johan Andersson](https://github.com/rejeep) or their open source gem [user_agent_parser](https://github.com/toolmantim/user_agent_parser). As well as [Tobie Langel](https://github.com/tobie) and everybody involved in [BrowserScope](http://www.browserscope.org/) ([full list](https://code.google.com/p/browserscope/people/list)), as our device and browser detection derives from their open-source work.
86
+
87
+ [Iain Hecker](https://github.com/iain) for his open source gem [http_accept_language](https://github.com/iain/http_accept_language) that helps us understand browser's favorite locales.
88
+
89
+ [Brian Landau](https://github.com/brianjlandau) and [Ryan Foster](https://github.com/fosome) for [NavLynx](https://github.com/vigetlabs/nav_lynx) as well as everybody on the [Bootstrap Team](https://github.com/orgs/twbs/people) as we use these open source projects on our generated view code.
90
+
91
+
92
+
93
+
94
+
95
+ ## Copyright
96
+
97
+ Copyright 2013-2016 James Pinto – Released under [MIT License](http://www.opensource.org/licenses/MIT)
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env rake
2
+
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
8
+
9
+ APP_RAKEFILE = File.expand_path('../dummy/Rakefile', __FILE__)
10
+ load 'rails/tasks/engine.rake'
11
+
12
+ Bundler::GemHelper.install_tasks
13
+
14
+ Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each { |f| load f }
15
+
16
+ require 'rspec/core'
17
+ require 'rspec/core/rake_task'
18
+ require 'rspec/rails'
19
+
20
+ desc 'Run all specs in spec directory (excluding plugin specs)'
21
+ RSpec::Core::RakeTask.new(spec: 'app:db:test:prepare')
22
+
23
+ task default: :spec
@@ -0,0 +1,27 @@
1
+ class Hello::ApplicationController < ApplicationController
2
+ rescue_from Hello::Errors::JsonNotSupported do |exception|
3
+ render json: _json_data_for_exception(exception), status: :bad_request
4
+ end
5
+
6
+ rescue_from ActionController::ParameterMissing do |exception|
7
+ respond_to do |format|
8
+ format.html { fail exception }
9
+ format.json { render json: _json_data_for_exception(exception), status: :bad_request } # 400
10
+ end
11
+ end
12
+
13
+ private
14
+
15
+ # Don't override this at home, kids
16
+ def _json_data_for_exception(exception)
17
+ {
18
+ maintenance: false,
19
+ action: "#{controller_name}##{action_name}",
20
+ exception: {
21
+ class: exception.class.name,
22
+ message: exception.message,
23
+ # backtrace: exception.backtrace
24
+ }
25
+ }
26
+ end
27
+ end
@@ -0,0 +1,81 @@
1
+ module Hello
2
+ module Authentication
3
+ class SessionsController < ApplicationController
4
+ dont_kick_people
5
+
6
+ before_actions do
7
+ only(:index) { @accesses = current_accesses }
8
+ only(:show, :destroy) { @access = find_access! }
9
+ end
10
+
11
+ # GET /hello/sessions
12
+ def index
13
+ render_list
14
+ end
15
+
16
+ # GET /hello/sessions/new
17
+ def new
18
+ render_new
19
+ end
20
+
21
+ # GET /hello/sessions/1
22
+ def show
23
+ self.session_token = @access.token
24
+
25
+ business = Hello::Business::Authentication::SignIn.new
26
+
27
+ respond_to do |format|
28
+ format.html { redirect_to hello.sessions_path, notice: business.success_message }
29
+ format.json { head :reset_content }
30
+ end
31
+ end
32
+
33
+ # DELETE /hello/sessions/1
34
+ def destroy
35
+ sign_out!(@access)
36
+
37
+ business = Hello::Business::Authentication::SignOut.new
38
+
39
+ respond_to do |format|
40
+ format.html { redirect_to hello.sessions_path, notice: business.success_message }
41
+ format.json { head :reset_content }
42
+ end
43
+ end
44
+
45
+ # get /hello/sign_out
46
+ def sign_out
47
+ sign_out!
48
+
49
+ business = Hello::Business::Authentication::SignOut.new
50
+
51
+ respond_to do |format|
52
+ format.html { redirect_to '/', notice: business.success_message }
53
+ format.json { head :reset_content }
54
+ end
55
+ end
56
+
57
+ private
58
+
59
+ def find_access!
60
+ current_accesses.find { |at| at.id.to_s == params[:id] } || access_not_found!
61
+ end
62
+
63
+ def access_not_found!
64
+ # we can re use the sign out message here
65
+ business = Hello::Business::Authentication::SignOut.new
66
+ respond_to do |format|
67
+ format.html { redirect_to hello.sessions_path, notice: business.success_message }
68
+ format.json { head :reset_content }
69
+ end
70
+ end
71
+
72
+ def render_list
73
+ render 'hello/authentication/sessions'
74
+ end
75
+
76
+ def render_new
77
+ render 'hello/authentication/new_session'
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,39 @@
1
+ module Hello
2
+ module Authentication
3
+ # you really should be overriding concerns instead of this file
4
+ class SignInController < ApplicationController
5
+ include Hello::Concerns::Authentication::SignIn
6
+
7
+ kick :guest, only: [:authenticated]
8
+
9
+ before_actions do
10
+ only(:index, :authenticate) { @sign_in = Hello::Business::Authentication::SignIn.new }
11
+ end
12
+
13
+ # GET /hello/sign_in
14
+ def index
15
+ render_sign_in
16
+ end
17
+
18
+ # POST /hello/sign_in
19
+ def authenticate
20
+ if @sign_in.authenticate(sign_in_params[:login], sign_in_params[:password])
21
+ flash[:notice] = @sign_in.success_message
22
+ on_success
23
+ else
24
+ on_failure
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def sign_in_params
31
+ params.require(:sign_in)
32
+ end
33
+
34
+ def render_sign_in
35
+ render 'hello/authentication/sign_in'
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,40 @@
1
+ module Hello
2
+ module Authentication
3
+ class SudoModeController < ApplicationController
4
+ kick :guest, :onboarding
5
+
6
+ # GET /hello/sudo_mode
7
+ def form
8
+ render_sudo_mode_form
9
+ end
10
+
11
+ # PATCH /hello/sudo_mode
12
+ def authenticate
13
+ business = Business::Authentication::SudoModeAuthentication.new(current_access)
14
+
15
+ if business.authenticate!(password_param)
16
+ path_to_go = session[:url] || root_path
17
+ flash[:notice] = business.success_message
18
+ redirect_to path_to_go
19
+ else
20
+ flash.now[:alert] = business.alert_message
21
+ render_sudo_mode_form
22
+ end
23
+ end
24
+
25
+ # GET /hello/sudo_mode/expire
26
+ def expire
27
+ business = Business::Authentication::SudoModeExpiration.new(current_access)
28
+ business.expire!
29
+ flash[:notice] = business.success_message
30
+ redirect_to '/'
31
+ end
32
+
33
+ private
34
+
35
+ def password_param
36
+ params.require(:user)[:password]
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,44 @@
1
+ module Hello
2
+ module Concerns
3
+ module Authentication
4
+ module SignIn
5
+
6
+ def on_success
7
+ access_token = sign_in!(@sign_in.user, expires_at, sudo_mode_expires_at)
8
+
9
+ respond_to do |format|
10
+ format.html { redirect_to path_to_go }
11
+ format.json { render json: access_token.as_json_web_api, status: :created }
12
+ end
13
+ end
14
+
15
+ def on_failure
16
+ respond_to do |format|
17
+ format.html { render_sign_in }
18
+ format.json { render json: @sign_in.errors, status: :unprocessable_entity }
19
+ end
20
+ end
21
+
22
+
23
+ private
24
+
25
+ def expires_at
26
+ if params[:keep_me]
27
+ 30.days.from_now
28
+ else
29
+ 30.minutes.from_now
30
+ end
31
+ end
32
+
33
+ def sudo_mode_expires_at
34
+ Hello.configuration.sudo_expires_in.from_now
35
+ end
36
+
37
+ def path_to_go
38
+ session.delete(:url) || '/'
39
+ end
40
+
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,45 @@
1
+ module Hello
2
+ module Concerns
3
+ module Management
4
+ module ForgotPassword
5
+
6
+ def on_success
7
+ reset_token_and_deliver_emails!
8
+
9
+ respond_to do |format|
10
+ format.html { render_success }
11
+ format.json { render json: { sent: true }, status: :created }
12
+ end
13
+ end
14
+
15
+ def on_failure
16
+ respond_to do |format|
17
+ format.html { render_form }
18
+ format.json { render json: @forgot_password.errors, status: :unprocessable_entity }
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def reset_token_and_deliver_emails!
25
+ url = get_reset_password_url
26
+
27
+ emails.each do |email|
28
+ Mailer.forgot_password(email, @user, url).deliver
29
+ end
30
+ end
31
+
32
+ def emails
33
+ @user.email_credentials.map(&:email)
34
+ end
35
+
36
+ def get_reset_password_url
37
+ p = @user.main_password_credential
38
+ token = p.reset_verifying_token!
39
+ hello.reset_password_url(p.id, @user.id, token)
40
+ end
41
+
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,33 @@
1
+ module Hello
2
+ module Concerns
3
+ module Management
4
+ module ResetPassword
5
+
6
+ def on_success
7
+ access_token = sign_in!(@reset_password.user, expires_at, sudo_mode_expires_at)
8
+
9
+ redirect_to path_to_go
10
+ end
11
+
12
+ def on_failure
13
+ render_reset_form
14
+ end
15
+
16
+ private
17
+
18
+ def expires_at
19
+ 30.days.from_now
20
+ end
21
+
22
+ def sudo_mode_expires_at
23
+ Hello.configuration.sudo_expires_in.from_now
24
+ end
25
+
26
+ def path_to_go
27
+ '/'
28
+ end
29
+
30
+ end
31
+ end
32
+ end
33
+ end