user_plane 0.0.15

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 (205) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +30 -0
  4. data/app/assets/javascripts/user_plane/application.js +13 -0
  5. data/app/assets/stylesheets/user_plane/application.css +15 -0
  6. data/app/concerns/null_object_persistable.rb +62 -0
  7. data/app/controllers/user/confirm_email_addresses_controller.rb +17 -0
  8. data/app/controllers/user/details_controller.rb +48 -0
  9. data/app/controllers/user/invites_controller.rb +69 -0
  10. data/app/controllers/user/reset_passwords_controller.rb +50 -0
  11. data/app/controllers/user/sign_ins_controller.rb +53 -0
  12. data/app/controllers/user/sign_ups_controller.rb +47 -0
  13. data/app/controllers/user_plane/application_controller.rb +5 -0
  14. data/app/helpers/user_plane/application_helper.rb +4 -0
  15. data/app/mailers/user_plane/application_mailer.rb +8 -0
  16. data/app/mailers/user_plane/invite_mailer.rb +14 -0
  17. data/app/mailers/user_plane/verification_mailer.rb +25 -0
  18. data/app/models/session_manager.rb +100 -0
  19. data/app/models/user.rb +5 -0
  20. data/app/models/user/account.rb +26 -0
  21. data/app/models/user/confirm_email_address.rb +55 -0
  22. data/app/models/user/guest.rb +18 -0
  23. data/app/models/user/identities.rb +5 -0
  24. data/app/models/user/identities/email.rb +98 -0
  25. data/app/models/user/identities/email_verification.rb +70 -0
  26. data/app/models/user/identities/facebook.rb +5 -0
  27. data/app/models/user/identities/github.rb +5 -0
  28. data/app/models/user/identities/id_token.rb +7 -0
  29. data/app/models/user/identities/o_auth.rb +67 -0
  30. data/app/models/user/identities/o_auth_endpoint.rb +28 -0
  31. data/app/models/user/identities/twitter.rb +5 -0
  32. data/app/models/user/identity.rb +26 -0
  33. data/app/models/user/reset_password.rb +59 -0
  34. data/app/models/user/send_password_reset.rb +25 -0
  35. data/app/models/user/send_sign_up_invite.rb +27 -0
  36. data/app/models/user/sign_in.rb +42 -0
  37. data/app/models/user/sign_up.rb +47 -0
  38. data/app/models/user/sign_up_invites.rb +5 -0
  39. data/app/models/user/sign_up_invites/invite.rb +46 -0
  40. data/app/models/user/sign_up_invites/stack.rb +22 -0
  41. data/app/models/user/sign_up_with_invite.rb +45 -0
  42. data/app/models/user/suspension.rb +7 -0
  43. data/app/models/user/update_details.rb +103 -0
  44. data/app/views/layouts/user_plane/application.html.erb +14 -0
  45. data/app/views/user/details/edit.html.erb +37 -0
  46. data/app/views/user/invites/edit.html.erb +34 -0
  47. data/app/views/user/invites/new.html.erb +21 -0
  48. data/app/views/user/reset_passwords/edit.html.erb +26 -0
  49. data/app/views/user/reset_passwords/new.html.erb +21 -0
  50. data/app/views/user/sign_ins/new.html.erb +25 -0
  51. data/app/views/user/sign_ups/new.html.erb +33 -0
  52. data/app/views/user_plane/invite_mailer/invite.html.erb +2 -0
  53. data/app/views/user_plane/invite_mailer/invite.text.erb +3 -0
  54. data/app/views/user_plane/verification_mailer/address_verification.html.erb +2 -0
  55. data/app/views/user_plane/verification_mailer/address_verification.text.erb +4 -0
  56. data/app/views/user_plane/verification_mailer/password_reset.html.erb +2 -0
  57. data/app/views/user_plane/verification_mailer/password_reset.text.erb +4 -0
  58. data/config/initializers/inflections.rb +3 -0
  59. data/config/locales/en.yml +63 -0
  60. data/config/locales/it.yml +62 -0
  61. data/config/routes.rb +5 -0
  62. data/db/migrate/20121128143404_create_user_accounts.rb +11 -0
  63. data/db/migrate/20121226202553_create_user_identities_o_auths.rb +12 -0
  64. data/db/migrate/20121226203032_create_user_identities_emails.rb +13 -0
  65. data/db/migrate/20121227144617_create_user_identities_email_verifications.rb +15 -0
  66. data/db/migrate/20130113120152_create_user_identities_id_tokens.rb +12 -0
  67. data/db/migrate/20141025230304_create_user_sign_up_invites_stacks.rb +10 -0
  68. data/db/migrate/20141025230500_create_user_sign_up_invites_invites.rb +13 -0
  69. data/db/migrate/20141026230208_create_user_suspensions.rb +13 -0
  70. data/lib/generators/user_plane/view/details_generator.rb +22 -0
  71. data/lib/generators/user_plane/view/helpers.rb +68 -0
  72. data/lib/generators/user_plane/view/invites_generator.rb +23 -0
  73. data/lib/generators/user_plane/view/reset_passwords_generator.rb +22 -0
  74. data/lib/generators/user_plane/view/sign_ins_generator.rb +18 -0
  75. data/lib/generators/user_plane/view/sign_ups_generator.rb +22 -0
  76. data/lib/generators/user_plane/views_generator.rb +32 -0
  77. data/lib/tasks/user_plane_tasks.rake +4 -0
  78. data/lib/user_plane.rb +43 -0
  79. data/lib/user_plane/command.rb +24 -0
  80. data/lib/user_plane/engine.rb +27 -0
  81. data/lib/user_plane/fresh_validator.rb +9 -0
  82. data/lib/user_plane/omniauth.rb +50 -0
  83. data/lib/user_plane/redirect_to_sign_in.rb +22 -0
  84. data/lib/user_plane/route_concerns.rb +167 -0
  85. data/lib/user_plane/session_manager_concern.rb +9 -0
  86. data/lib/user_plane/signed_in_constraint.rb +11 -0
  87. data/lib/user_plane/token_segment.rb +52 -0
  88. data/lib/user_plane/version.rb +3 -0
  89. data/spec/controllers/user/confirm_email_addresses_controller_spec.rb +5 -0
  90. data/spec/controllers/user/details_controller_spec.rb +5 -0
  91. data/spec/controllers/user/invites_controller_spec.rb +19 -0
  92. data/spec/controllers/user/reset_passwords_controller_spec.rb +5 -0
  93. data/spec/controllers/user/sign_ins_controller_spec.rb +34 -0
  94. data/spec/controllers/user/sign_ups_controller_spec.rb +5 -0
  95. data/spec/dummy/README.rdoc +28 -0
  96. data/spec/dummy/Rakefile +6 -0
  97. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  98. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  99. data/spec/dummy/app/controllers/application_controller.rb +7 -0
  100. data/spec/dummy/app/controllers/welcome_controller.rb +3 -0
  101. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  102. data/spec/dummy/app/views/layouts/application.html.erb +30 -0
  103. data/spec/dummy/app/views/welcome/index.html.erb +1 -0
  104. data/spec/dummy/bin/bundle +3 -0
  105. data/spec/dummy/bin/rails +4 -0
  106. data/spec/dummy/bin/rake +4 -0
  107. data/spec/dummy/config.ru +4 -0
  108. data/spec/dummy/config/application.rb +30 -0
  109. data/spec/dummy/config/boot.rb +5 -0
  110. data/spec/dummy/config/database.yml +49 -0
  111. data/spec/dummy/config/environment.rb +5 -0
  112. data/spec/dummy/config/environments/development.rb +37 -0
  113. data/spec/dummy/config/environments/production.rb +78 -0
  114. data/spec/dummy/config/environments/test.rb +39 -0
  115. data/spec/dummy/config/initializers/assets.rb +8 -0
  116. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  117. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  118. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  119. data/spec/dummy/config/initializers/inflections.rb +16 -0
  120. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  121. data/spec/dummy/config/initializers/session_store.rb +3 -0
  122. data/spec/dummy/config/initializers/user_plane.rb +5 -0
  123. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  124. data/spec/dummy/config/locales/en.yml +23 -0
  125. data/spec/dummy/config/routes.rb +43 -0
  126. data/spec/dummy/config/secrets.yml +22 -0
  127. data/spec/dummy/db/schema.rb +101 -0
  128. data/spec/dummy/log/development.log +0 -0
  129. data/spec/dummy/log/test.log +20185 -0
  130. data/spec/dummy/public/404.html +67 -0
  131. data/spec/dummy/public/422.html +67 -0
  132. data/spec/dummy/public/500.html +66 -0
  133. data/spec/dummy/public/favicon.ico +0 -0
  134. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/-pOuxJZhYk_qXqMNKgm23KfvzyUW71NynNLlcNBOubE.cache +0 -0
  135. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/3AV9ywHBH56Leqey5LeznxK9vu4HD8fF3zSTk4MiDJA.cache +1 -0
  136. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/5fzR1G0D8ukHkPkLXsUu6rP6qV82aIdx3hugKkDy6nM.cache +0 -0
  137. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/9bKtJ2lkHPqtboGfbyknZ1OyH4xYO-aml7U3qhv-3kk.cache +0 -0
  138. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/HjDmE9SFP2wimdNHU8Nff9cm3vFZ5soO1iw7Jdlb6z8.cache +0 -0
  139. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/J9j6OdatarYW7VzVCVttmGphOhJKL0QXasdheyrgsTE.cache +2 -0
  140. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/KqrOQSlg0Th0N3XXx-h4p5BVJCfN0D8rRLoA9VxvXrc.cache +1 -0
  141. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/UCB1W65KwVU8ttOY8jnPRDp8HyyYYEjeTwwPD6R4qy8.cache +1 -0
  142. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/YmMSaaBmIcNZWPVF9jXcGBi-kwEzMuxzwPT_Zrcj1Bo.cache +2 -0
  143. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/g3wU8ajFWb5ZLPvujEt5l9DesbFCiAwqjx1WQgwTtHA.cache +1 -0
  144. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/i5pp88VHKoqlxQJdgmQd_lkgX1-4em_uHqNDjQ4nyHA.cache +0 -0
  145. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/jL74yXjxf8cb6Olkjbw1C28MH_HbZe221l8AI6WVeH0.cache +3 -0
  146. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/puh7X4rfS3eDN9oHTXoQdAgqxivonrwAAdYZ4UB3GIg.cache +1 -0
  147. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/qxPWFIWnE6gOCY-SsdBJe7Cgm5D3YUwaEne78Y7XdRg.cache +1 -0
  148. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/rM9s67WgzKMZ1bRhUdA0yhPZDlyRE5a1kmdt7cS6m4c.cache +3 -0
  149. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/rVoG8EHlrCOgY4ZkzOj64f0jiTcbteQ_SYNzq9RqY0I.cache +0 -0
  150. data/spec/fabricators/user_account_fabricator.rb +11 -0
  151. data/spec/fabricators/user_guest_fabricator.rb +2 -0
  152. data/spec/fabricators/user_identities_email_fabricator.rb +8 -0
  153. data/spec/fabricators/user_identities_email_verification_fabricator.rb +5 -0
  154. data/spec/fabricators/user_identities_id_token_fabricator.rb +2 -0
  155. data/spec/fabricators/user_sign_up_fabricator.rb +51 -0
  156. data/spec/fabricators/user_sign_up_invites_invite_fabricator.rb +3 -0
  157. data/spec/fabricators/user_sign_up_invites_stack_fabricator.rb +4 -0
  158. data/spec/fabricators/user_suspension_fabricator.rb +4 -0
  159. data/spec/fabricators/user_update_detail_fabricator.rb +2 -0
  160. data/spec/features/user_plane/user_plane_invites_spec.rb +31 -0
  161. data/spec/features/user_plane/user_plane_reset_passwords_spec.rb +31 -0
  162. data/spec/features/user_plane/user_plane_sign_ins_spec.rb +44 -0
  163. data/spec/features/user_plane/user_plane_signed_in_only_spec.rb +31 -0
  164. data/spec/features/user_plane/user_plane_update_details_spec.rb +43 -0
  165. data/spec/fixtures/user_plane/invite_mailer/invite +3 -0
  166. data/spec/fixtures/user_plane/verification_mailer/address_verification +3 -0
  167. data/spec/fixtures/user_plane/verification_mailer/password_reset +3 -0
  168. data/spec/lib/generators/views_generator_spec.rb +16 -0
  169. data/spec/lib/route_concerns_spec.rb +54 -0
  170. data/spec/mailers/previews/user_plane/invite_mailer_preview.rb +11 -0
  171. data/spec/mailers/previews/user_plane/verification_mailer_preview.rb +16 -0
  172. data/spec/mailers/user_plane/invite_mailer_spec.rb +25 -0
  173. data/spec/mailers/user_plane/verification_mailer_spec.rb +52 -0
  174. data/spec/models/session_manager_spec.rb +28 -0
  175. data/spec/models/user/account_spec.rb +26 -0
  176. data/spec/models/user/confirm_email_address_spec.rb +101 -0
  177. data/spec/models/user/guest_spec.rb +5 -0
  178. data/spec/models/user/identities/email_spec.rb +5 -0
  179. data/spec/models/user/identities/email_verification_spec.rb +42 -0
  180. data/spec/models/user/identities/facebook_spec.rb +5 -0
  181. data/spec/models/user/identities/github_spec.rb +5 -0
  182. data/spec/models/user/identities/id_token_spec.rb +5 -0
  183. data/spec/models/user/identities/o_auth_spec.rb +12 -0
  184. data/spec/models/user/identities/twitter_spec.rb +5 -0
  185. data/spec/models/user/reset_password_spec.rb +141 -0
  186. data/spec/models/user/send_password_reset_spec.rb +44 -0
  187. data/spec/models/user/send_sign_up_invite_spec.rb +30 -0
  188. data/spec/models/user/sign_in_spec.rb +31 -0
  189. data/spec/models/user/sign_up_invites/invite_spec.rb +13 -0
  190. data/spec/models/user/sign_up_invites/stack_spec.rb +21 -0
  191. data/spec/models/user/sign_up_spec.rb +58 -0
  192. data/spec/models/user/sign_up_with_invite_spec.rb +83 -0
  193. data/spec/models/user/suspension_spec.rb +5 -0
  194. data/spec/models/user/update_details_spec.rb +98 -0
  195. data/spec/routing/invites_spec.rb +49 -0
  196. data/spec/routing/reset_passwords_spec.rb +31 -0
  197. data/spec/routing/sign_ins_spec.rb +36 -0
  198. data/spec/routing/update_details_spec.rb +30 -0
  199. data/spec/shared_contexts/feature_helpers.rb +12 -0
  200. data/spec/shared_contexts/routing.rb +8 -0
  201. data/spec/shared_contexts/user.rb +67 -0
  202. data/spec/spec_helper.rb +38 -0
  203. data/spec/support/fabrication.rb +7 -0
  204. data/spec/support/omniauth.rb +4 -0
  205. metadata +770 -0
@@ -0,0 +1,5 @@
1
+ module UserPlane
2
+ Engine.routes.draw do
3
+
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ class CreateUserAccounts < ActiveRecord::Migration
2
+ def change
3
+ create_table :user_accounts do |t|
4
+ t.string :name
5
+ t.string :uid
6
+
7
+ t.timestamps
8
+ end
9
+ add_index :user_accounts, :uid
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ class CreateUserIdentitiesOAuths < ActiveRecord::Migration
2
+ def change
3
+ create_table :user_identities_o_auths do |t|
4
+ t.references :account
5
+ t.string :provider
6
+ t.string :uid
7
+ t.string :handle
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ class CreateUserIdentitiesEmails < ActiveRecord::Migration
2
+ def change
3
+ create_table :user_identities_emails do |t|
4
+ t.references :account
5
+ t.string :address
6
+ t.string :password_digest
7
+
8
+ t.timestamps
9
+ end
10
+ add_index :user_identities_emails, :address
11
+ add_index :user_identities_emails, :password_digest
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ class CreateUserIdentitiesEmailVerifications < ActiveRecord::Migration
2
+ def change
3
+ create_table :user_identities_email_verifications do |t|
4
+ t.string :token
5
+ t.string :type
6
+ t.string :recipient
7
+ t.references :email
8
+ t.datetime :spent_at
9
+
10
+ t.timestamps
11
+ end
12
+ add_index :user_identities_email_verifications, :email_id
13
+ add_index :user_identities_email_verifications, :token
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ class CreateUserIdentitiesIdTokens < ActiveRecord::Migration
2
+ def change
3
+ create_table :user_identities_id_tokens do |t|
4
+ t.string :key
5
+ t.references :identity, :polymorphic => true
6
+
7
+ t.timestamps
8
+ end
9
+ add_index :user_identities_id_tokens, :identity_id
10
+ add_index :user_identities_id_tokens, :key
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ class CreateUserSignUpInvitesStacks < ActiveRecord::Migration
2
+ def change
3
+ create_table :user_sign_up_invites_stacks do |t|
4
+ t.references :owner, polymorphic: true
5
+ t.integer :remaining_invites
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ class CreateUserSignUpInvitesInvites < ActiveRecord::Migration
2
+ def change
3
+ create_table :user_sign_up_invites_invites do |t|
4
+ t.references :stack
5
+ t.references :sender
6
+ t.string :code
7
+ t.string :recipient
8
+ t.references :account
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ class CreateUserSuspensions < ActiveRecord::Migration
2
+ def change
3
+ create_table :user_suspensions do |t|
4
+ t.string :message
5
+ t.references :issuer
6
+ t.references :account
7
+
8
+ t.timestamps
9
+ end
10
+ add_index :user_suspensions, :issuer_id
11
+ add_index :user_suspensions, :account_id
12
+ end
13
+ end
@@ -0,0 +1,22 @@
1
+ require 'rails/generators'
2
+ require 'generators/user_plane/view/helpers'
3
+
4
+ module UserPlane # :nodoc:
5
+ module Generators # :nodoc:
6
+ module View
7
+ class DetailsGenerator < Rails::Generators::NamedBase # :nodoc:
8
+ include UserPlane::Generators::View::Helpers
9
+
10
+ def copy_view_files
11
+ create_root_folder
12
+
13
+ view_for_resource :edit, 'update_details', ['name:string',
14
+ 'email:string',
15
+ 'current_password:password',
16
+ 'password:password',
17
+ 'password_confirmation:password']
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,68 @@
1
+ require 'rails/generators/resource_helpers'
2
+
3
+ module UserPlane # :nodoc:
4
+ module Generators # :nodoc:
5
+ module View
6
+ module Helpers# :nodoc:
7
+ extend ActiveSupport::Concern
8
+
9
+ included do
10
+ include Rails::Generators::ResourceHelpers
11
+ # TODO: move this in classmethods
12
+ # source_root File.expand_path("../../templates", __FILE__)
13
+ hide!
14
+
15
+ class_option :skip_namespace, default: true
16
+
17
+ hook_for :template_engine, as: :scaffold do |template_engine|
18
+ source_paths.append template_engine.source_root
19
+ end
20
+ end
21
+
22
+ protected
23
+
24
+ def create_root_folder
25
+ empty_directory File.join("app/views", controller_file_path)
26
+ end
27
+
28
+ def view_for_resource view, model_name, attributes
29
+
30
+ self.name = model_name
31
+ self.attributes = attributes
32
+ assign_names! name
33
+ parse_attributes!
34
+ # FIXME: Using the NamesBase generator wrong, should make the views
35
+ # inherit from Base and implement the same methods used by the
36
+ # scaffold templates
37
+ @singular_table_name = name
38
+ @plural_table_name = name.pluralize
39
+
40
+ formats.each do |format|
41
+ templatename = filename_with_extensions('_form', format)
42
+ filename = filename_with_extensions(view, format)
43
+ template templatename, File.join("app/views", controller_file_path, filename)
44
+ end
45
+ end
46
+
47
+ attr_accessor :attributes, :name
48
+
49
+ def formats
50
+ [format]
51
+ end
52
+
53
+ def format
54
+ :html
55
+ end
56
+
57
+ def handler
58
+ options[:template_engine]
59
+ end
60
+
61
+ def filename_with_extensions(name, format = self.format)
62
+ [name, format, handler].compact.join(".")
63
+ end
64
+
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,23 @@
1
+ require 'rails/generators'
2
+ require 'generators/user_plane/view/helpers'
3
+
4
+ module UserPlane # :nodoc:
5
+ module Generators # :nodoc:
6
+ module View
7
+ class InvitesGenerator < Rails::Generators::NamedBase # :nodoc:
8
+ include UserPlane::Generators::View::Helpers
9
+
10
+ def copy_view_files
11
+ create_root_folder
12
+
13
+ view_for_resource :new, 'send_sign_up_invite', ['recipient:string']
14
+ #TODO: add a hidden field for the invite code
15
+ view_for_resource :edit, 'sign_up_with_invite', ['user_name:string',
16
+ 'email:string',
17
+ 'password:password',
18
+ 'password_confirmation:password']
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,22 @@
1
+ require 'rails/generators'
2
+ require 'generators/user_plane/view/helpers'
3
+
4
+ module UserPlane # :nodoc:
5
+ module Generators # :nodoc:
6
+ module View
7
+ class ResetPasswordsGenerator < Rails::Generators::NamedBase # :nodoc:
8
+ include UserPlane::Generators::View::Helpers
9
+
10
+ def copy_view_files
11
+ create_root_folder
12
+
13
+ view_for_resource :new, 'send_password_reset', ['email:string']
14
+ #TODO: add a hidden field for the password reset code
15
+ view_for_resource :edit, 'reset_password', ['password:password',
16
+ 'password_confirmation:password']
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,18 @@
1
+ require 'rails/generators'
2
+ require 'generators/user_plane/view/helpers'
3
+
4
+ module UserPlane # :nodoc:
5
+ module Generators # :nodoc:
6
+ module View
7
+ class SignInsGenerator < Rails::Generators::NamedBase # :nodoc:
8
+ include UserPlane::Generators::View::Helpers
9
+
10
+ def copy_view_files
11
+ create_root_folder
12
+
13
+ view_for_resource :new, 'sign_in', ['email:string', 'password:string']
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,22 @@
1
+ require 'rails/generators'
2
+ require 'generators/user_plane/view/helpers'
3
+
4
+ module UserPlane # :nodoc:
5
+ module Generators # :nodoc:
6
+ module View
7
+ class SignUpsGenerator < Rails::Generators::NamedBase # :nodoc:
8
+ include UserPlane::Generators::View::Helpers
9
+
10
+ def copy_view_files
11
+ create_root_folder
12
+
13
+ view_for_resource :new, 'sign_up', ['user_name:string',
14
+ 'email:string',
15
+ 'password:password',
16
+ 'password_confirmation:password']
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,32 @@
1
+ require 'rails/generators'
2
+
3
+ module UserPlane # :nodoc:
4
+ module Generators # :nodoc:
5
+ class ViewsGenerator < Rails::Generators::Base # :nodoc:
6
+
7
+ argument :namespace, default: 'user'
8
+ # TODO: make the views below optional
9
+
10
+ hook_for :'view:sign_ins', default: true do |invoked|
11
+ invoke invoked, ["#{namespace}/sign_ins"]
12
+ end
13
+
14
+ hook_for :'view:details', default: true do |invoked|
15
+ invoke invoked, ["#{namespace}/details"]
16
+ end
17
+
18
+ hook_for :'view:sign_ups', default: true do |invoked|
19
+ invoke invoked, ["#{namespace}/sign_ups"]
20
+ end
21
+
22
+ hook_for :'view:reset_passwords', default: true do |invoked|
23
+ invoke invoked, ["#{namespace}/reset_passwords"]
24
+ end
25
+
26
+ hook_for :'view:invites', default: true do |invoked|
27
+ invoke invoked, ["#{namespace}/invites"]
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :user_plane do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,43 @@
1
+ require 'active_support/dependencies'
2
+
3
+ require 'user_plane/signed_in_constraint'
4
+ require 'user_plane/route_concerns'
5
+ require 'user_plane/redirect_to_sign_in'
6
+ require 'user_plane/session_manager_concern'
7
+
8
+ require 'user_plane/engine'
9
+ require 'user_plane/token_segment'
10
+ require 'user_plane/fresh_validator'
11
+
12
+ require 'email_validator/strict'
13
+
14
+ require 'user_plane/command'
15
+ require 'support_segment'
16
+ require 'support_segment/sti_helpers'
17
+
18
+
19
+ module UserPlane
20
+ mattr_accessor :parent_controller
21
+ mattr_accessor :parent_mailer
22
+ mattr_accessor :redirect_to_sign_in
23
+
24
+ def self.parent_controller
25
+ @@parent_controller || '::ApplicationController'
26
+ end
27
+
28
+ def self.parent_mailer
29
+ @@parent_mailer || 'UserPlane::ApplicationMailer'
30
+ end
31
+
32
+ def self.send_emails_from
33
+ "accounts@#{Rails.configuration.action_mailer.default_url_options[:host]}"
34
+ end
35
+
36
+ def self.redirect_to_sign_in
37
+ @@redirect_to_sign_in ||= Rack::Builder.new do
38
+ use ActionDispatch::ShowExceptions, Rails.application.config.exceptions_app
39
+ use ActionDispatch::DebugExceptions, Rails.application
40
+ run RedirectToSignIn.new
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,24 @@
1
+ require 'imperator'
2
+
3
+ module UserPlane
4
+ class Command < Imperator::Command
5
+ include ActiveModel::Conversion
6
+
7
+ def perform_validations(options={}) # :nodoc:
8
+ options[:validate] == false || valid?
9
+ end
10
+
11
+ def perform(options={})
12
+ if perform_validations(options)
13
+ super()
14
+ true
15
+ else
16
+ false
17
+ end
18
+ end
19
+
20
+ def perform!(options={})
21
+ raise Imperator::InvalidCommandError.new("Command was invalid") unless perform(options)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,27 @@
1
+ module UserPlane
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace UserPlane
4
+
5
+ config.generators do |g|
6
+ g.test_framework :rspec, :fixture => false
7
+ g.fixture_replacement :fabrication, :dir => 'spec/fabricators'
8
+ g.assets false
9
+ g.helper false
10
+ end
11
+
12
+ initializer :append_migrations do |app|
13
+ unless app.root.to_s.match root.to_s
14
+ config.paths["db/migrate"].expanded.each do |expanded_path|
15
+ app.config.paths["db/migrate"] << expanded_path
16
+ end
17
+ end
18
+ end
19
+
20
+ initializer :'user_plane.controller_concern' do
21
+ ActiveSupport.on_load(:action_controller) do
22
+ include SessionManagerConcern
23
+ end
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,9 @@
1
+ require 'active_model/validations'
2
+
3
+ module UserPlane
4
+ class FreshValidator < ActiveModel::Validator
5
+ def validate(record)
6
+ record.errors.add(:created_at, 'has expired') if record.stale?
7
+ end
8
+ end
9
+ end