devise_meteor 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.travis.yml +4 -0
  4. data/CODE_OF_CONDUCT.md +13 -0
  5. data/Gemfile +16 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +78 -0
  8. data/Rakefile +7 -0
  9. data/app/models/devise_meteor/meteor_profile.rb +12 -0
  10. data/app/models/devise_meteor/meteor_service.rb +16 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +7 -0
  13. data/devise_meteor.gemspec +37 -0
  14. data/lib/devise/strategies/meteor.rb +92 -0
  15. data/lib/devise_meteor/concerns/meteor_user_model.rb +148 -0
  16. data/lib/devise_meteor/engine.rb +10 -0
  17. data/lib/devise_meteor/railtie.rb +7 -0
  18. data/lib/devise_meteor/strategies/encrypter.rb +15 -0
  19. data/lib/devise_meteor/strategies/hasher.rb +91 -0
  20. data/lib/devise_meteor/strategies/strategy.rb +92 -0
  21. data/lib/devise_meteor/version.rb +3 -0
  22. data/lib/devise_meteor.rb +37 -0
  23. data/lib/generators/devise_meteor/install_generator.rb +16 -0
  24. data/lib/generators/templates/meteor_initializer.rb +12 -0
  25. data/spec/factories/users.rb +19 -0
  26. data/spec/models/meteor_authentication_spec.rb +261 -0
  27. data/spec/rails_helper.rb +72 -0
  28. data/spec/spec_helper.rb +92 -0
  29. data/spec/support/api_macros.rb +30 -0
  30. data/spec/support/controller_macros.rb +18 -0
  31. data/spec/support/devise_macros.rb +58 -0
  32. data/spec/support/omniauth_macros.rb +44 -0
  33. data/spec/support/request_macros.rb +13 -0
  34. data/spec/test_app/README.rdoc +3 -0
  35. data/spec/test_app/Rakefile +6 -0
  36. data/spec/test_app/app/assets/javascripts/application.js +13 -0
  37. data/spec/test_app/app/assets/stylesheets/application.css +15 -0
  38. data/spec/test_app/app/controllers/application_controller.rb +5 -0
  39. data/spec/test_app/app/controllers/products_controller.rb +89 -0
  40. data/spec/test_app/app/helpers/application_helper.rb +2 -0
  41. data/spec/test_app/app/models/user.rb +43 -0
  42. data/spec/test_app/app/views/layouts/application.html.erb +14 -0
  43. data/spec/test_app/app/views/products/_form.html.erb +29 -0
  44. data/spec/test_app/app/views/products/edit.html.erb +6 -0
  45. data/spec/test_app/app/views/products/index.html.erb +33 -0
  46. data/spec/test_app/app/views/products/new.html.erb +5 -0
  47. data/spec/test_app/app/views/products/show.html.erb +25 -0
  48. data/spec/test_app/bin/bundle +3 -0
  49. data/spec/test_app/bin/rails +4 -0
  50. data/spec/test_app/bin/rake +4 -0
  51. data/spec/test_app/bin/setup +29 -0
  52. data/spec/test_app/config/application.rb +28 -0
  53. data/spec/test_app/config/boot.rb +5 -0
  54. data/spec/test_app/config/environment.rb +5 -0
  55. data/spec/test_app/config/environments/development.rb +38 -0
  56. data/spec/test_app/config/environments/production.rb +77 -0
  57. data/spec/test_app/config/environments/test.rb +45 -0
  58. data/spec/test_app/config/initializers/assets.rb +11 -0
  59. data/spec/test_app/config/initializers/backtrace_silencers.rb +7 -0
  60. data/spec/test_app/config/initializers/cookies_serializer.rb +3 -0
  61. data/spec/test_app/config/initializers/devise.rb +268 -0
  62. data/spec/test_app/config/initializers/filter_parameter_logging.rb +4 -0
  63. data/spec/test_app/config/initializers/inflections.rb +16 -0
  64. data/spec/test_app/config/initializers/mime_types.rb +4 -0
  65. data/spec/test_app/config/initializers/secret_token.rb +3 -0
  66. data/spec/test_app/config/initializers/session_store.rb +3 -0
  67. data/spec/test_app/config/initializers/wrap_parameters.rb +9 -0
  68. data/spec/test_app/config/locales/en.yml +23 -0
  69. data/spec/test_app/config/mongoid.yml +80 -0
  70. data/spec/test_app/config/routes.rb +5 -0
  71. data/spec/test_app/config/secrets.yml +22 -0
  72. data/spec/test_app/config.ru +4 -0
  73. data/spec/test_app/lib/tasks/cucumber.rake +65 -0
  74. data/spec/test_app/log/test.log +23511 -0
  75. data/spec/test_app/public/404.html +67 -0
  76. data/spec/test_app/public/422.html +67 -0
  77. data/spec/test_app/public/500.html +66 -0
  78. data/spec/test_app/public/favicon.ico +0 -0
  79. metadata +350 -0
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,43 @@
1
+ class User
2
+ include Mongoid::Document
3
+
4
+ # Include default devise modules. Others available are:
5
+ devise :database_authenticatable, :registerable, :confirmable, :lockable, :timeoutable,
6
+ :recoverable, :trackable, :validatable
7
+
8
+ ## Database authenticatable
9
+ field :email, type: String, default: ""
10
+ field :encrypted_password, type: String, default: ""
11
+
12
+ ## Recoverable
13
+ field :reset_password_token, type: String
14
+ field :reset_password_sent_at, type: Time
15
+
16
+ ## Rememberable
17
+ field :remember_created_at, type: Time
18
+
19
+ ## Trackable
20
+ field :sign_in_count, type: Integer, default: 0
21
+ field :current_sign_in_at, type: Time
22
+ field :last_sign_in_at, type: Time
23
+ field :current_sign_in_ip, type: String
24
+ field :last_sign_in_ip, type: String
25
+
26
+ ## Confirmable
27
+ field :confirmation_token, type: String
28
+ field :confirmed_at, type: Time
29
+ field :confirmation_sent_at, type: Time
30
+ field :unconfirmed_email, type: String # Only if using reconfirmable
31
+
32
+ ## Lockable
33
+ field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
34
+ field :unlock_token, type: String # Only if unlock strategy is :email or :both
35
+ field :locked_at, type: Time
36
+
37
+ # authentication token
38
+ field :authentication_token, :type => String
39
+
40
+ # devise_meteor authentication
41
+ include DeviseMeteor::MeteorUserModel
42
+
43
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>TestApp</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,29 @@
1
+ <%= form_for(@product) do |f| %>
2
+ <% if @product.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@product.errors.count, "error") %> prohibited this product from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @product.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :product_title %><br />
16
+ <%= f.text_field :product_title %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :in_stock %><br />
20
+ <%= f.text_field :in_stock %>
21
+ </div>
22
+ <div class="field">
23
+ <%= f.label :net_price %><br />
24
+ <%= f.text_field :net_price %>
25
+ </div>
26
+ <div class="actions">
27
+ <%= f.submit %>
28
+ </div>
29
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing product</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @product %> |
6
+ <%= link_to 'Back', products_path %>
@@ -0,0 +1,33 @@
1
+ <h1>Listing products</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Title</th>
6
+ <th>Sku</th>
7
+ <th>Stock</th>
8
+ <th>Amount</th>
9
+ <th>Unit</th>
10
+ <th>Net price</th>
11
+ <th></th>
12
+ <th></th>
13
+ <th></th>
14
+ </tr>
15
+
16
+ <% @products.each do |product| %>
17
+ <tr>
18
+ <td><%= product.product_title %></td>
19
+ <td><%= product.sku %></td>
20
+ <td><%= product.in_stock %></td>
21
+ <td><%= product.amount %></td>
22
+ <td><%= product.unit %></td>
23
+ <td><%= product.net_price %></td>
24
+ <td><%= link_to 'Show', product %></td>
25
+ <td><%= link_to 'Edit', edit_product_path(product) %></td>
26
+ <td><%= link_to 'Destroy', product, method: :delete, data: { confirm: 'Are you sure?' } %></td>
27
+ </tr>
28
+ <% end %>
29
+ </table>
30
+
31
+ <br />
32
+
33
+ <%= link_to 'New User', new_product_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New product</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', products_path %>
@@ -0,0 +1,25 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>Product Title:</b>
5
+ <%= @product.product_title %>
6
+ </p>
7
+
8
+ <p>
9
+ <b>Sku:</b>
10
+ <%= @product.sku %>
11
+ </p>
12
+
13
+ <p>
14
+ <b>In Stock:</b>
15
+ <%= @product.in_stock %>
16
+ </p>
17
+
18
+ <p>
19
+ <b>Net price:</b>
20
+ <%= @product.net_price %>
21
+ </p>
22
+
23
+
24
+ <%= link_to 'Edit', edit_product_path(@product) %> |
25
+ <%= link_to 'Back', products_path %>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+
4
+ # path to your application root.
5
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+
7
+ Dir.chdir APP_ROOT do
8
+ # This script is a starting point to setup your application.
9
+ # Add necessary setup steps to this file:
10
+
11
+ puts "== Installing dependencies =="
12
+ system "gem install bundler --conservative"
13
+ system "bundle check || bundle install"
14
+
15
+ # puts "\n== Copying sample files =="
16
+ # unless File.exist?("config/database.yml")
17
+ # system "cp config/database.yml.sample config/database.yml"
18
+ # end
19
+
20
+ puts "\n== Preparing database =="
21
+ system "bin/rake db:setup"
22
+
23
+ puts "\n== Removing old logs and tempfiles =="
24
+ system "rm -f log/*"
25
+ system "rm -rf tmp/cache"
26
+
27
+ puts "\n== Restarting application server =="
28
+ system "touch tmp/restart.txt"
29
+ end
@@ -0,0 +1,28 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ # Pick the frameworks you want:
4
+ require "action_controller/railtie"
5
+ require "action_mailer/railtie"
6
+ require "action_view/railtie"
7
+ require "sprockets/railtie"
8
+
9
+ Bundler.require(*Rails.groups)
10
+ require "devise_meteor"
11
+
12
+ module TestApp
13
+ class Application < Rails::Application
14
+ # Settings in config/environments/* take precedence over those specified here.
15
+ # Application configuration should go into files in config/initializers
16
+ # -- all .rb files in that directory are automatically loaded.
17
+
18
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
19
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
20
+ # config.time_zone = 'Central Time (US & Canada)'
21
+
22
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
23
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
24
+ # config.i18n.default_locale = :de
25
+
26
+ end
27
+ end
28
+
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -0,0 +1,38 @@
1
+ TestApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports and disable caching.
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send.
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger.
20
+ config.active_support.deprecation = :log
21
+
22
+ # Debug mode disables concatenation and preprocessing of assets.
23
+ # This option may cause significant delays in view rendering with a large
24
+ # number of complex assets.
25
+ config.assets.debug = true
26
+
27
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
28
+ # yet still be able to expire them through the digest params.
29
+ config.assets.digest = true
30
+
31
+ # Adds additional error checking when serving assets at runtime.
32
+ # Checks for improperly declared sprockets dependencies.
33
+ # Raises helpful error messages.
34
+ config.assets.raise_runtime_errors = true
35
+
36
+ # Raises error for missing translations
37
+ # config.action_view.raise_on_missing_translations = true
38
+ end
@@ -0,0 +1,77 @@
1
+ TestApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # Code is not reloaded between requests.
5
+ config.cache_classes = true
6
+
7
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both threaded web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
13
+ # Full error reports are disabled and caching is turned on.
14
+ config.consider_all_requests_local = false
15
+ config.action_controller.perform_caching = true
16
+
17
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
+ # Add `rack-cache` to your Gemfile before enabling this.
19
+ # For large-scale production use, consider using a caching reverse proxy like
20
+ # NGINX, varnish or squid.
21
+ # config.action_dispatch.rack_cache = true
22
+
23
+ # Disable serving static files from the `/public` folder by default since
24
+ # Apache or NGINX already handles this.
25
+ config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
26
+
27
+ # Compress JavaScripts and CSS.
28
+ config.assets.js_compressor = :uglifier
29
+ # config.assets.css_compressor = :sass
30
+
31
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
32
+ config.assets.compile = false
33
+
34
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
35
+ # yet still be able to expire them through the digest params.
36
+ config.assets.digest = true
37
+
38
+ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
39
+
40
+ # Specifies the header that your server uses for sending files.
41
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
42
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
43
+
44
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
45
+ # config.force_ssl = true
46
+
47
+ # Use the lowest log level to ensure availability of diagnostic information
48
+ # when problems arise.
49
+ config.log_level = :debug
50
+
51
+ # Prepend all log lines with the following tags.
52
+ # config.log_tags = [ :subdomain, :uuid ]
53
+
54
+ # Use a different logger for distributed setups.
55
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
56
+
57
+ # Use a different cache store in production.
58
+ # config.cache_store = :mem_cache_store
59
+
60
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
61
+ # config.action_controller.asset_host = 'http://assets.example.com'
62
+
63
+ # Ignore bad email addresses and do not raise email delivery errors.
64
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
65
+ # config.action_mailer.raise_delivery_errors = false
66
+
67
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
68
+ # the I18n.default_locale when a translation cannot be found).
69
+ config.i18n.fallbacks = true
70
+
71
+ # Send deprecation notices to registered listeners.
72
+ config.active_support.deprecation = :notify
73
+
74
+ # Use default logging formatter so that PID and timestamp are not suppressed.
75
+ config.log_formatter = ::Logger::Formatter.new
76
+
77
+ end
@@ -0,0 +1,45 @@
1
+ TestApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ config.action_mailer.default_url_options = {:host => "localhost", port: 3000, :locale => I18n.locale}
5
+ # The test environment is used exclusively to run your application's
6
+ # test suite. You never need to work with it otherwise. Remember that
7
+ # your test database is "scratch space" for the test suite and is wiped
8
+ # and recreated between test runs. Don't rely on the data there!
9
+ config.cache_classes = true
10
+
11
+ # Do not eager load code on boot. This avoids loading your whole application
12
+ # just for the purpose of running a single test. If you are using a tool that
13
+ # preloads Rails for running tests, you may have to set it to true.
14
+ config.eager_load = false
15
+
16
+ # Configure static file server for tests with Cache-Control for performance.
17
+ config.serve_static_files = true
18
+ config.static_cache_control = 'public, max-age=3600'
19
+
20
+ # Show full error reports and disable caching.
21
+ config.consider_all_requests_local = true
22
+ config.action_controller.perform_caching = false
23
+
24
+ # Raise exceptions instead of rendering exception templates.
25
+ config.action_dispatch.show_exceptions = false
26
+
27
+ # Disable request forgery protection in test environment.
28
+ config.action_controller.allow_forgery_protection = false
29
+
30
+ # Tell Action Mailer not to deliver emails to the real world.
31
+ # The :test delivery method accumulates sent emails in the
32
+ config.action_mailer.raise_delivery_errors = false
33
+
34
+ # ActionMailer::Base.deliveries array.
35
+ config.action_mailer.delivery_method = :test
36
+
37
+ # Randomize the order test cases are executed.
38
+ config.active_support.test_order = :random
39
+
40
+ # Print deprecation notices to the stderr.
41
+ config.active_support.deprecation = :stderr
42
+
43
+ # Raises error for missing translations
44
+ # config.action_view.raise_on_missing_translations = true
45
+ end
@@ -0,0 +1,11 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Version of your assets, change this if you want to expire all your assets.
4
+ Rails.application.config.assets.version = '1.0'
5
+
6
+ # Add additional assets to the asset load path
7
+ # Rails.application.config.assets.paths << Emoji.images_path
8
+
9
+ # Precompile additional assets.
10
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
11
+ # Rails.application.config.assets.precompile += %w( search.js )
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!