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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +30 -0
- data/app/assets/javascripts/user_plane/application.js +13 -0
- data/app/assets/stylesheets/user_plane/application.css +15 -0
- data/app/concerns/null_object_persistable.rb +62 -0
- data/app/controllers/user/confirm_email_addresses_controller.rb +17 -0
- data/app/controllers/user/details_controller.rb +48 -0
- data/app/controllers/user/invites_controller.rb +69 -0
- data/app/controllers/user/reset_passwords_controller.rb +50 -0
- data/app/controllers/user/sign_ins_controller.rb +53 -0
- data/app/controllers/user/sign_ups_controller.rb +47 -0
- data/app/controllers/user_plane/application_controller.rb +5 -0
- data/app/helpers/user_plane/application_helper.rb +4 -0
- data/app/mailers/user_plane/application_mailer.rb +8 -0
- data/app/mailers/user_plane/invite_mailer.rb +14 -0
- data/app/mailers/user_plane/verification_mailer.rb +25 -0
- data/app/models/session_manager.rb +100 -0
- data/app/models/user.rb +5 -0
- data/app/models/user/account.rb +26 -0
- data/app/models/user/confirm_email_address.rb +55 -0
- data/app/models/user/guest.rb +18 -0
- data/app/models/user/identities.rb +5 -0
- data/app/models/user/identities/email.rb +98 -0
- data/app/models/user/identities/email_verification.rb +70 -0
- data/app/models/user/identities/facebook.rb +5 -0
- data/app/models/user/identities/github.rb +5 -0
- data/app/models/user/identities/id_token.rb +7 -0
- data/app/models/user/identities/o_auth.rb +67 -0
- data/app/models/user/identities/o_auth_endpoint.rb +28 -0
- data/app/models/user/identities/twitter.rb +5 -0
- data/app/models/user/identity.rb +26 -0
- data/app/models/user/reset_password.rb +59 -0
- data/app/models/user/send_password_reset.rb +25 -0
- data/app/models/user/send_sign_up_invite.rb +27 -0
- data/app/models/user/sign_in.rb +42 -0
- data/app/models/user/sign_up.rb +47 -0
- data/app/models/user/sign_up_invites.rb +5 -0
- data/app/models/user/sign_up_invites/invite.rb +46 -0
- data/app/models/user/sign_up_invites/stack.rb +22 -0
- data/app/models/user/sign_up_with_invite.rb +45 -0
- data/app/models/user/suspension.rb +7 -0
- data/app/models/user/update_details.rb +103 -0
- data/app/views/layouts/user_plane/application.html.erb +14 -0
- data/app/views/user/details/edit.html.erb +37 -0
- data/app/views/user/invites/edit.html.erb +34 -0
- data/app/views/user/invites/new.html.erb +21 -0
- data/app/views/user/reset_passwords/edit.html.erb +26 -0
- data/app/views/user/reset_passwords/new.html.erb +21 -0
- data/app/views/user/sign_ins/new.html.erb +25 -0
- data/app/views/user/sign_ups/new.html.erb +33 -0
- data/app/views/user_plane/invite_mailer/invite.html.erb +2 -0
- data/app/views/user_plane/invite_mailer/invite.text.erb +3 -0
- data/app/views/user_plane/verification_mailer/address_verification.html.erb +2 -0
- data/app/views/user_plane/verification_mailer/address_verification.text.erb +4 -0
- data/app/views/user_plane/verification_mailer/password_reset.html.erb +2 -0
- data/app/views/user_plane/verification_mailer/password_reset.text.erb +4 -0
- data/config/initializers/inflections.rb +3 -0
- data/config/locales/en.yml +63 -0
- data/config/locales/it.yml +62 -0
- data/config/routes.rb +5 -0
- data/db/migrate/20121128143404_create_user_accounts.rb +11 -0
- data/db/migrate/20121226202553_create_user_identities_o_auths.rb +12 -0
- data/db/migrate/20121226203032_create_user_identities_emails.rb +13 -0
- data/db/migrate/20121227144617_create_user_identities_email_verifications.rb +15 -0
- data/db/migrate/20130113120152_create_user_identities_id_tokens.rb +12 -0
- data/db/migrate/20141025230304_create_user_sign_up_invites_stacks.rb +10 -0
- data/db/migrate/20141025230500_create_user_sign_up_invites_invites.rb +13 -0
- data/db/migrate/20141026230208_create_user_suspensions.rb +13 -0
- data/lib/generators/user_plane/view/details_generator.rb +22 -0
- data/lib/generators/user_plane/view/helpers.rb +68 -0
- data/lib/generators/user_plane/view/invites_generator.rb +23 -0
- data/lib/generators/user_plane/view/reset_passwords_generator.rb +22 -0
- data/lib/generators/user_plane/view/sign_ins_generator.rb +18 -0
- data/lib/generators/user_plane/view/sign_ups_generator.rb +22 -0
- data/lib/generators/user_plane/views_generator.rb +32 -0
- data/lib/tasks/user_plane_tasks.rake +4 -0
- data/lib/user_plane.rb +43 -0
- data/lib/user_plane/command.rb +24 -0
- data/lib/user_plane/engine.rb +27 -0
- data/lib/user_plane/fresh_validator.rb +9 -0
- data/lib/user_plane/omniauth.rb +50 -0
- data/lib/user_plane/redirect_to_sign_in.rb +22 -0
- data/lib/user_plane/route_concerns.rb +167 -0
- data/lib/user_plane/session_manager_concern.rb +9 -0
- data/lib/user_plane/signed_in_constraint.rb +11 -0
- data/lib/user_plane/token_segment.rb +52 -0
- data/lib/user_plane/version.rb +3 -0
- data/spec/controllers/user/confirm_email_addresses_controller_spec.rb +5 -0
- data/spec/controllers/user/details_controller_spec.rb +5 -0
- data/spec/controllers/user/invites_controller_spec.rb +19 -0
- data/spec/controllers/user/reset_passwords_controller_spec.rb +5 -0
- data/spec/controllers/user/sign_ins_controller_spec.rb +34 -0
- data/spec/controllers/user/sign_ups_controller_spec.rb +5 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +7 -0
- data/spec/dummy/app/controllers/welcome_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +30 -0
- data/spec/dummy/app/views/welcome/index.html.erb +1 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +30 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +49 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +78 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/assets.rb +8 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/user_plane.rb +5 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +43 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/db/schema.rb +101 -0
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/log/test.log +20185 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/-pOuxJZhYk_qXqMNKgm23KfvzyUW71NynNLlcNBOubE.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/3AV9ywHBH56Leqey5LeznxK9vu4HD8fF3zSTk4MiDJA.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/5fzR1G0D8ukHkPkLXsUu6rP6qV82aIdx3hugKkDy6nM.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/9bKtJ2lkHPqtboGfbyknZ1OyH4xYO-aml7U3qhv-3kk.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/HjDmE9SFP2wimdNHU8Nff9cm3vFZ5soO1iw7Jdlb6z8.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/J9j6OdatarYW7VzVCVttmGphOhJKL0QXasdheyrgsTE.cache +2 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/KqrOQSlg0Th0N3XXx-h4p5BVJCfN0D8rRLoA9VxvXrc.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/UCB1W65KwVU8ttOY8jnPRDp8HyyYYEjeTwwPD6R4qy8.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/YmMSaaBmIcNZWPVF9jXcGBi-kwEzMuxzwPT_Zrcj1Bo.cache +2 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/g3wU8ajFWb5ZLPvujEt5l9DesbFCiAwqjx1WQgwTtHA.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/i5pp88VHKoqlxQJdgmQd_lkgX1-4em_uHqNDjQ4nyHA.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/jL74yXjxf8cb6Olkjbw1C28MH_HbZe221l8AI6WVeH0.cache +3 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/puh7X4rfS3eDN9oHTXoQdAgqxivonrwAAdYZ4UB3GIg.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/qxPWFIWnE6gOCY-SsdBJe7Cgm5D3YUwaEne78Y7XdRg.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/rM9s67WgzKMZ1bRhUdA0yhPZDlyRE5a1kmdt7cS6m4c.cache +3 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/rVoG8EHlrCOgY4ZkzOj64f0jiTcbteQ_SYNzq9RqY0I.cache +0 -0
- data/spec/fabricators/user_account_fabricator.rb +11 -0
- data/spec/fabricators/user_guest_fabricator.rb +2 -0
- data/spec/fabricators/user_identities_email_fabricator.rb +8 -0
- data/spec/fabricators/user_identities_email_verification_fabricator.rb +5 -0
- data/spec/fabricators/user_identities_id_token_fabricator.rb +2 -0
- data/spec/fabricators/user_sign_up_fabricator.rb +51 -0
- data/spec/fabricators/user_sign_up_invites_invite_fabricator.rb +3 -0
- data/spec/fabricators/user_sign_up_invites_stack_fabricator.rb +4 -0
- data/spec/fabricators/user_suspension_fabricator.rb +4 -0
- data/spec/fabricators/user_update_detail_fabricator.rb +2 -0
- data/spec/features/user_plane/user_plane_invites_spec.rb +31 -0
- data/spec/features/user_plane/user_plane_reset_passwords_spec.rb +31 -0
- data/spec/features/user_plane/user_plane_sign_ins_spec.rb +44 -0
- data/spec/features/user_plane/user_plane_signed_in_only_spec.rb +31 -0
- data/spec/features/user_plane/user_plane_update_details_spec.rb +43 -0
- data/spec/fixtures/user_plane/invite_mailer/invite +3 -0
- data/spec/fixtures/user_plane/verification_mailer/address_verification +3 -0
- data/spec/fixtures/user_plane/verification_mailer/password_reset +3 -0
- data/spec/lib/generators/views_generator_spec.rb +16 -0
- data/spec/lib/route_concerns_spec.rb +54 -0
- data/spec/mailers/previews/user_plane/invite_mailer_preview.rb +11 -0
- data/spec/mailers/previews/user_plane/verification_mailer_preview.rb +16 -0
- data/spec/mailers/user_plane/invite_mailer_spec.rb +25 -0
- data/spec/mailers/user_plane/verification_mailer_spec.rb +52 -0
- data/spec/models/session_manager_spec.rb +28 -0
- data/spec/models/user/account_spec.rb +26 -0
- data/spec/models/user/confirm_email_address_spec.rb +101 -0
- data/spec/models/user/guest_spec.rb +5 -0
- data/spec/models/user/identities/email_spec.rb +5 -0
- data/spec/models/user/identities/email_verification_spec.rb +42 -0
- data/spec/models/user/identities/facebook_spec.rb +5 -0
- data/spec/models/user/identities/github_spec.rb +5 -0
- data/spec/models/user/identities/id_token_spec.rb +5 -0
- data/spec/models/user/identities/o_auth_spec.rb +12 -0
- data/spec/models/user/identities/twitter_spec.rb +5 -0
- data/spec/models/user/reset_password_spec.rb +141 -0
- data/spec/models/user/send_password_reset_spec.rb +44 -0
- data/spec/models/user/send_sign_up_invite_spec.rb +30 -0
- data/spec/models/user/sign_in_spec.rb +31 -0
- data/spec/models/user/sign_up_invites/invite_spec.rb +13 -0
- data/spec/models/user/sign_up_invites/stack_spec.rb +21 -0
- data/spec/models/user/sign_up_spec.rb +58 -0
- data/spec/models/user/sign_up_with_invite_spec.rb +83 -0
- data/spec/models/user/suspension_spec.rb +5 -0
- data/spec/models/user/update_details_spec.rb +98 -0
- data/spec/routing/invites_spec.rb +49 -0
- data/spec/routing/reset_passwords_spec.rb +31 -0
- data/spec/routing/sign_ins_spec.rb +36 -0
- data/spec/routing/update_details_spec.rb +30 -0
- data/spec/shared_contexts/feature_helpers.rb +12 -0
- data/spec/shared_contexts/routing.rb +8 -0
- data/spec/shared_contexts/user.rb +67 -0
- data/spec/spec_helper.rb +38 -0
- data/spec/support/fabrication.rb +7 -0
- data/spec/support/omniauth.rb +4 -0
- metadata +770 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5624848f2ad9569de727b25af51328499aeae07a
|
4
|
+
data.tar.gz: 03b7d97b7e15432f289fb0e07f66ae8eff984df6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d11d52b16c08618076e567ede1ac2e16d4370381ba02e2deb8a9f963cda3c884397273d76ac50beef4170e7c73f37c228c90c79b128ead53ea916ecbdf238cff
|
7
|
+
data.tar.gz: 8ea4c65ec24f4e8222e1c87cdce52ec891a4b63fa16100d1fe168b84a144214ccbb2202422911616e7d34018cd4c420656fea4ae396df610d3491adbc7555f33
|
data/MIT-LICENSE
ADDED
@@ -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.
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'UserPlane'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
load 'rails/tasks/statistics.rake'
|
21
|
+
|
22
|
+
Bundler::GemHelper.install_tasks
|
23
|
+
|
24
|
+
|
25
|
+
require 'rspec/core'
|
26
|
+
require 'rspec/core/rake_task'
|
27
|
+
|
28
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
29
|
+
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
30
|
+
task :default => :spec
|
@@ -0,0 +1,13 @@
|
|
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_tree .
|
@@ -0,0 +1,15 @@
|
|
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 bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module NullObjectPersistable
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
def self.mimics_persistence_from(real_model_class)
|
6
|
+
@real_model_class = real_model_class
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.real_model_class
|
10
|
+
@real_model_class
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.table_name
|
14
|
+
@real_model_class.to_s.tableize
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.primary_key
|
18
|
+
"id"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def real_model_class
|
23
|
+
self.class.real_model_class
|
24
|
+
end
|
25
|
+
|
26
|
+
def id
|
27
|
+
end
|
28
|
+
|
29
|
+
def [](*)
|
30
|
+
end
|
31
|
+
|
32
|
+
def []=(*)
|
33
|
+
end
|
34
|
+
|
35
|
+
def has_attribute? attribute
|
36
|
+
real_model_class.new().has_attribute? attribute
|
37
|
+
end
|
38
|
+
|
39
|
+
def is_a?(klass)
|
40
|
+
if klass == real_model_class
|
41
|
+
true
|
42
|
+
else
|
43
|
+
super
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def destroyed?
|
48
|
+
false
|
49
|
+
end
|
50
|
+
|
51
|
+
def new_record?
|
52
|
+
false
|
53
|
+
end
|
54
|
+
|
55
|
+
def persisted?
|
56
|
+
false
|
57
|
+
end
|
58
|
+
|
59
|
+
def marked_for_destruction?
|
60
|
+
false
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_dependency "user_plane/application_controller"
|
2
|
+
|
3
|
+
module User
|
4
|
+
class ConfirmEmailAddressesController < ApplicationController
|
5
|
+
|
6
|
+
def update
|
7
|
+
@confirm_email_address = ConfirmEmailAddress.new(code: params[:code])
|
8
|
+
|
9
|
+
if @confirm_email_address.perform
|
10
|
+
redirect_to root_url, notice: :signed_in
|
11
|
+
else
|
12
|
+
render 'edit'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require_dependency "user_plane/application_controller"
|
2
|
+
|
3
|
+
module User
|
4
|
+
class DetailsController < ApplicationController
|
5
|
+
|
6
|
+
cattr_accessor :permitted do
|
7
|
+
[:name, :password, :password_confirmation, :email]
|
8
|
+
end
|
9
|
+
|
10
|
+
before_action :initialize_update_details
|
11
|
+
|
12
|
+
def edit
|
13
|
+
@update_details
|
14
|
+
end
|
15
|
+
|
16
|
+
def update
|
17
|
+
@update_details.attributes = update_details_params
|
18
|
+
|
19
|
+
if @update_details.perform
|
20
|
+
if email_verification = @update_details.email_verification
|
21
|
+
confirm_email_address = User::ConfirmEmailAddress.new(verification: email_verification)
|
22
|
+
confirm_mail = UserPlane::VerificationMailer.address_verification(confirm_email_address)
|
23
|
+
confirm_mail.deliver_now
|
24
|
+
flash[:warning] = t('.address_change_warning',
|
25
|
+
address: email_verification.recipient)
|
26
|
+
end
|
27
|
+
render 'edit', notice: t('.success')
|
28
|
+
else
|
29
|
+
render 'edit'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# TODO: add an action to add facebook authentication
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def initialize_update_details
|
38
|
+
@update_details = UpdateDetails.new(account: session_manager.account)
|
39
|
+
end
|
40
|
+
|
41
|
+
def update_details_params
|
42
|
+
# TODO: drive the permitted
|
43
|
+
params.require(:user_update_details).
|
44
|
+
permit(*self.class.permitted)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require_dependency "user_plane/application_controller"
|
2
|
+
|
3
|
+
module User
|
4
|
+
class InvitesController < ApplicationController
|
5
|
+
|
6
|
+
def new
|
7
|
+
@send_sign_up_invite = SendSignUpInvite.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def create
|
11
|
+
@send_sign_up_invite = SendSignUpInvite.new(params[:send_sign_up_invite])
|
12
|
+
|
13
|
+
if @send_sign_up_invite.perform
|
14
|
+
invite_email = UserPlane::InviteMailer.invite(@send_sign_up_invite.invite)
|
15
|
+
invite_email.deliver_now
|
16
|
+
|
17
|
+
redirect_to :new, notice: :success
|
18
|
+
else
|
19
|
+
render 'new'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def edit
|
24
|
+
@sign_up_with_invite = SignUpWithInvite.new(code: params[:code])
|
25
|
+
@sign_up_with_invite.email = @sign_up_with_invite.invite.recipient
|
26
|
+
end
|
27
|
+
|
28
|
+
def update
|
29
|
+
@sign_up_with_invite = SignUpWithInvite.new(sign_up_params).sign_up_with(Identities::Email)
|
30
|
+
|
31
|
+
perform_sign_up @sign_up_with_invite
|
32
|
+
end
|
33
|
+
|
34
|
+
def oauth_callback
|
35
|
+
# TODO: do I need to check the provider param? There is on in oauth_data
|
36
|
+
# and one in params.
|
37
|
+
oauth_data = request.env["omniauth.auth"]
|
38
|
+
oauth_error = request.env["omniauth.error"]
|
39
|
+
|
40
|
+
#FIXME: the way the user_name is inferred might work for facebook only
|
41
|
+
oauth_params = {oauth_data: oauth_data,
|
42
|
+
oauth_error: oauth_error,
|
43
|
+
user_name: oauth_data[:info][:nickname],
|
44
|
+
code: params[:sign_up_with_invite_code]}
|
45
|
+
# TODO: The host app should be able to do a sign_up here instead
|
46
|
+
@sign_up_with_invite = SignUpWithInvite.new(oauth_params).sign_up_with(Identities::OAuth)
|
47
|
+
|
48
|
+
perform_sign_up @sign_up_with_invite
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def sign_up_params
|
55
|
+
params.require(:user_sign_up_with_invite).
|
56
|
+
permit(:email, :password, :password_confirmation, :user_name, :code)
|
57
|
+
end
|
58
|
+
|
59
|
+
def perform_sign_up sign_up
|
60
|
+
if sign_up.perform
|
61
|
+
session_manager.identity = sign_up.identity
|
62
|
+
redirect_to root_url, notice: t('.success')
|
63
|
+
else
|
64
|
+
render 'edit'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_dependency "user_plane/application_controller"
|
2
|
+
|
3
|
+
module User
|
4
|
+
class ResetPasswordsController < ApplicationController
|
5
|
+
|
6
|
+
def new
|
7
|
+
@send_password_reset = SendPasswordReset.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def create
|
11
|
+
@send_password_reset = SendPasswordReset.new(send_password_reset_params)
|
12
|
+
|
13
|
+
# silent failure on password reset?
|
14
|
+
if @send_password_reset.identity and @send_password_reset.perform
|
15
|
+
reset_password = User::ResetPassword.new(verification: @send_password_reset.verification)
|
16
|
+
reset_mail = UserPlane::VerificationMailer.password_reset(reset_password)
|
17
|
+
reset_mail.deliver_now
|
18
|
+
redirect_to root_url, notice: t('.success', address: @send_password_reset.email)
|
19
|
+
else
|
20
|
+
flash[:notice] = t('.failure', address: @send_password_reset.email)
|
21
|
+
render 'new'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def edit
|
26
|
+
@reset_password = ResetPassword.new(code: params[:code])
|
27
|
+
end
|
28
|
+
|
29
|
+
def update
|
30
|
+
@reset_password = ResetPassword.new(reset_password_params)
|
31
|
+
if @reset_password.perform
|
32
|
+
redirect_to root_url, notice: t('.success')
|
33
|
+
else
|
34
|
+
render 'edit'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def reset_password_params
|
41
|
+
params.require(:user_reset_password).
|
42
|
+
permit(:code, :password, :password_confirmation)
|
43
|
+
end
|
44
|
+
|
45
|
+
def send_password_reset_params
|
46
|
+
params.require(:user_send_password_reset).
|
47
|
+
permit(:email)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require_dependency "user_plane/application_controller"
|
2
|
+
|
3
|
+
module User
|
4
|
+
class SignInsController < ApplicationController
|
5
|
+
|
6
|
+
def new
|
7
|
+
session_manager.sign_out
|
8
|
+
@sign_in = SignIn.new()
|
9
|
+
end
|
10
|
+
|
11
|
+
def create
|
12
|
+
@sign_in = SignIn.new(sign_in_params).sign_in_with(Identities::Email)
|
13
|
+
|
14
|
+
perform_sign_in @sign_in
|
15
|
+
end
|
16
|
+
|
17
|
+
def oauth_callback
|
18
|
+
# TODO: do I need to check the provider param? There is on in oauth_data
|
19
|
+
# and one in params.
|
20
|
+
oauth_data = request.env["omniauth.auth"]
|
21
|
+
oauth_error = request.env["omniauth.error"]
|
22
|
+
|
23
|
+
# TODO: The host app should be able to do a sign_up here instead
|
24
|
+
@sign_in = SignIn.new(oauth_data: oauth_data,
|
25
|
+
oauth_error: oauth_error).sign_in_with(Identities::OAuth)
|
26
|
+
|
27
|
+
perform_sign_in @sign_in
|
28
|
+
end
|
29
|
+
|
30
|
+
def destroy
|
31
|
+
session_manager.sign_out
|
32
|
+
redirect_to root_url, notice: t('.success')
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def sign_in_params
|
38
|
+
params.require(:user_sign_in).permit(:email, :password)
|
39
|
+
end
|
40
|
+
|
41
|
+
def perform_sign_in sign_in
|
42
|
+
if sign_in.perform
|
43
|
+
session_manager.remember_page nil
|
44
|
+
session_manager.identity = sign_in.identity
|
45
|
+
redirect_to session_manager.previous_page || root_url,
|
46
|
+
notice: t('.success')
|
47
|
+
else
|
48
|
+
render 'new'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require_dependency "user_plane/application_controller"
|
2
|
+
|
3
|
+
module User
|
4
|
+
class SignUpsController < ApplicationController
|
5
|
+
|
6
|
+
def new
|
7
|
+
@sign_up = SignUp.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def create
|
11
|
+
@sign_up = SignUp.new(sign_up_params).sign_up_with(Identities::Email)
|
12
|
+
|
13
|
+
perform_sign_up @sign_up
|
14
|
+
end
|
15
|
+
|
16
|
+
def oauth_callback
|
17
|
+
# TODO: do I need to check the provider param? There is on in oauth_data
|
18
|
+
# and one in params.
|
19
|
+
oauth_data = request.env["omniauth.auth"]
|
20
|
+
|
21
|
+
# FIXME: the way the user_name is inferred might work for facebook only
|
22
|
+
oauth_params = {oauth_data: oauth_data,
|
23
|
+
user_name: oauth_data[:info][:nickname]}
|
24
|
+
# TODO: The host app should be able to do a sign_up here instead
|
25
|
+
@sign_up = SignUp.new(oauth_params).sign_in_with(Identities::OAuth)
|
26
|
+
|
27
|
+
perform_sign_up @sign_up
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def sign_up_params
|
33
|
+
params.require(:user_sign_up).
|
34
|
+
permit(:email, :password, :password_confirmation, :user_name)
|
35
|
+
end
|
36
|
+
|
37
|
+
def perform_sign_up sign_up
|
38
|
+
if sign_up.perform
|
39
|
+
session_manager.identity = sign_up.identity
|
40
|
+
redirect_to root_url, notice: t('.success')
|
41
|
+
else
|
42
|
+
render 'new'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|