5 |
--------------------------------------------------------------------------------
/app/views/home/index.html.erb:
--------------------------------------------------------------------------------
1 |
2 | <%= javascript_pack_tag 'index' %>
3 | <%= stylesheet_pack_tag 'index' %>
4 |
--------------------------------------------------------------------------------
/app/views/layouts/application.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ReactDeviseSample
5 |
6 |
7 | <%= stylesheet_link_tag 'application', media: 'all' %>
8 | <%= javascript_include_tag 'application' %>
9 |
10 |
11 |
12 | <%= yield %>
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/views/layouts/mailer.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 | <%= yield %>
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/views/layouts/mailer.text.erb:
--------------------------------------------------------------------------------
1 | <%= yield %>
2 |
--------------------------------------------------------------------------------
/bin/bundle:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3 | load Gem.bin_path('bundler', 'bundle')
4 |
--------------------------------------------------------------------------------
/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | begin
3 | load File.expand_path('../spring', __FILE__)
4 | rescue LoadError => e
5 | raise unless e.message.include?('spring')
6 | end
7 | APP_PATH = File.expand_path('../config/application', __dir__)
8 | require_relative '../config/boot'
9 | require 'rails/commands'
10 |
--------------------------------------------------------------------------------
/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | begin
3 | load File.expand_path('../spring', __FILE__)
4 | rescue LoadError => e
5 | raise unless e.message.include?('spring')
6 | end
7 | require_relative '../config/boot'
8 | require 'rake'
9 | Rake.application.run
10 |
--------------------------------------------------------------------------------
/bin/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'pathname'
3 | require 'fileutils'
4 | include FileUtils
5 |
6 | # path to your application root.
7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8 |
9 | def system!(*args)
10 | system(*args) || abort("\n== Command #{args} failed ==")
11 | end
12 |
13 | chdir APP_ROOT do
14 | # This script is a starting point to setup your application.
15 | # Add necessary setup steps to this file.
16 |
17 | puts '== Installing dependencies =='
18 | system! 'gem install bundler --conservative'
19 | system('bundle check') || system!('bundle install')
20 |
21 | # Install JavaScript dependencies if using Yarn
22 | # system('bin/yarn')
23 |
24 |
25 | # puts "\n== Copying sample files =="
26 | # unless File.exist?('config/database.yml')
27 | # cp 'config/database.yml.sample', 'config/database.yml'
28 | # end
29 |
30 | puts "\n== Preparing database =="
31 | system! 'bin/rails db:setup'
32 |
33 | puts "\n== Removing old logs and tempfiles =="
34 | system! 'bin/rails log:clear tmp:clear'
35 |
36 | puts "\n== Restarting application server =="
37 | system! 'bin/rails restart'
38 | end
39 |
--------------------------------------------------------------------------------
/bin/spring:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | # This file loads spring without using Bundler, in order to be fast.
4 | # It gets overwritten when you run the `spring binstub` command.
5 |
6 | unless defined?(Spring)
7 | require 'rubygems'
8 | require 'bundler'
9 |
10 | lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
11 | spring = lockfile.specs.detect { |spec| spec.name == "spring" }
12 | if spring
13 | Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
14 | gem 'spring', spring.version
15 | require 'spring/binstub'
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/bin/update:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'pathname'
3 | require 'fileutils'
4 | include FileUtils
5 |
6 | # path to your application root.
7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8 |
9 | def system!(*args)
10 | system(*args) || abort("\n== Command #{args} failed ==")
11 | end
12 |
13 | chdir APP_ROOT do
14 | # This script is a way to update your development environment automatically.
15 | # Add necessary update steps to this file.
16 |
17 | puts '== Installing dependencies =='
18 | system! 'gem install bundler --conservative'
19 | system('bundle check') || system!('bundle install')
20 |
21 | puts "\n== Updating database =="
22 | system! 'bin/rails db:migrate'
23 |
24 | puts "\n== Removing old logs and tempfiles =="
25 | system! 'bin/rails log:clear tmp:clear'
26 |
27 | puts "\n== Restarting application server =="
28 | system! 'bin/rails restart'
29 | end
30 |
--------------------------------------------------------------------------------
/bin/webpack:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | $stdout.sync = true
3 |
4 | require "shellwords"
5 | require "yaml"
6 |
7 | ENV["RAILS_ENV"] ||= "development"
8 | RAILS_ENV = ENV["RAILS_ENV"]
9 |
10 | ENV["NODE_ENV"] ||= RAILS_ENV
11 | NODE_ENV = ENV["NODE_ENV"]
12 |
13 | APP_PATH = File.expand_path("../", __dir__)
14 | NODE_MODULES_PATH = File.join(APP_PATH, "node_modules")
15 | WEBPACK_CONFIG = File.join(APP_PATH, "config/webpack/#{NODE_ENV}.js")
16 |
17 | unless File.exist?(WEBPACK_CONFIG)
18 | puts "Webpack configuration not found."
19 | puts "Please run bundle exec rails webpacker:install to install webpacker"
20 | exit!
21 | end
22 |
23 | newenv = { "NODE_PATH" => NODE_MODULES_PATH.shellescape }
24 | cmdline = ["yarn", "run", "webpack", "--", "--config", WEBPACK_CONFIG] + ARGV
25 |
26 | Dir.chdir(APP_PATH) do
27 | exec newenv, *cmdline
28 | end
29 |
--------------------------------------------------------------------------------
/bin/webpack-dev-server:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | $stdout.sync = true
3 |
4 | require "shellwords"
5 | require "yaml"
6 |
7 | ENV["RAILS_ENV"] ||= "development"
8 | RAILS_ENV = ENV["RAILS_ENV"]
9 |
10 | ENV["NODE_ENV"] ||= RAILS_ENV
11 | NODE_ENV = ENV["NODE_ENV"]
12 |
13 | APP_PATH = File.expand_path("../", __dir__)
14 | CONFIG_FILE = File.join(APP_PATH, "config/webpacker.yml")
15 | NODE_MODULES_PATH = File.join(APP_PATH, "node_modules")
16 | WEBPACK_CONFIG = File.join(APP_PATH, "config/webpack/development.js")
17 |
18 | def args(key)
19 | index = ARGV.index(key)
20 | index ? ARGV[index + 1] : nil
21 | end
22 |
23 | begin
24 | dev_server = YAML.load_file(CONFIG_FILE)["development"]["dev_server"]
25 |
26 | DEV_SERVER_HOST = "http#{"s" if args('--https') || dev_server["https"]}://#{args('--host') || dev_server["host"]}:#{args('--port') || dev_server["port"]}"
27 |
28 | rescue Errno::ENOENT, NoMethodError
29 | puts "Webpack dev_server configuration not found in #{CONFIG_FILE}."
30 | puts "Please run bundle exec rails webpacker:install to install webpacker"
31 | exit!
32 | end
33 |
34 | newenv = {
35 | "NODE_PATH" => NODE_MODULES_PATH.shellescape,
36 | "ASSET_HOST" => DEV_SERVER_HOST.shellescape
37 | }.freeze
38 |
39 | cmdline = ["yarn", "run", "webpack-dev-server", "--", "--progress", "--color", "--config", WEBPACK_CONFIG] + ARGV
40 |
41 | Dir.chdir(APP_PATH) do
42 | exec newenv, *cmdline
43 | end
44 |
--------------------------------------------------------------------------------
/bin/yarn:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | VENDOR_PATH = File.expand_path('..', __dir__)
3 | Dir.chdir(VENDOR_PATH) do
4 | begin
5 | exec "yarnpkg #{ARGV.join(" ")}"
6 | rescue Errno::ENOENT
7 | $stderr.puts "Yarn executable was not detected in the system."
8 | $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
9 | exit 1
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require_relative 'config/environment'
4 |
5 | run Rails.application
6 |
--------------------------------------------------------------------------------
/config/application.rb:
--------------------------------------------------------------------------------
1 | require_relative 'boot'
2 |
3 | require 'rails/all'
4 |
5 | # Require the gems listed in Gemfile, including any gems
6 | # you've limited to :test, :development, or :production.
7 | Bundler.require(*Rails.groups)
8 |
9 | module ReactDeviseSample
10 | class Application < Rails::Application
11 | # Initialize configuration defaults for originally generated Rails version.
12 | config.load_defaults 5.1
13 |
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 | end
18 | end
19 |
--------------------------------------------------------------------------------
/config/boot.rb:
--------------------------------------------------------------------------------
1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
2 |
3 | require 'bundler/setup' # Set up gems listed in the Gemfile.
4 |
--------------------------------------------------------------------------------
/config/cable.yml:
--------------------------------------------------------------------------------
1 | development:
2 | adapter: async
3 |
4 | test:
5 | adapter: async
6 |
7 | production:
8 | adapter: redis
9 | url: redis://localhost:6379/1
10 | channel_prefix: react-devise-sample_production
11 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | # SQLite version 3.x
2 | # gem install sqlite3
3 | #
4 | # Ensure the SQLite 3 gem is defined in your Gemfile
5 | # gem 'sqlite3'
6 | #
7 | default: &default
8 | adapter: sqlite3
9 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
10 | timeout: 5000
11 |
12 | development:
13 | <<: *default
14 | database: db/development.sqlite3
15 |
16 | # Warning: The database defined as "test" will be erased and
17 | # re-generated from your development database when you run "rake".
18 | # Do not set this db to the same as development or production.
19 | test:
20 | <<: *default
21 | database: db/test.sqlite3
22 |
23 | production:
24 | <<: *default
25 | database: db/production.sqlite3
26 |
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the Rails application.
2 | require_relative 'application'
3 |
4 | # Initialize the Rails application.
5 | Rails.application.initialize!
6 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Rails.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.
13 | config.consider_all_requests_local = true
14 |
15 | # Enable/disable caching. By default caching is disabled.
16 | if Rails.root.join('tmp/caching-dev.txt').exist?
17 | config.action_controller.perform_caching = true
18 |
19 | config.cache_store = :memory_store
20 | config.public_file_server.headers = {
21 | 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
22 | }
23 | else
24 | config.action_controller.perform_caching = false
25 |
26 | config.cache_store = :null_store
27 | end
28 |
29 | # Don't care if the mailer can't send.
30 | config.action_mailer.raise_delivery_errors = false
31 |
32 | config.action_mailer.perform_caching = false
33 |
34 | # Print deprecation notices to the Rails logger.
35 | config.active_support.deprecation = :log
36 |
37 | # Raise an error on page load if there are pending migrations.
38 | config.active_record.migration_error = :page_load
39 |
40 | # Debug mode disables concatenation and preprocessing of assets.
41 | # This option may cause significant delays in view rendering with a large
42 | # number of complex assets.
43 | config.assets.debug = true
44 |
45 | # Suppress logger output for asset requests.
46 | config.assets.quiet = true
47 |
48 | # Raises error for missing translations
49 | # config.action_view.raise_on_missing_translations = true
50 |
51 | # Use an evented file watcher to asynchronously detect changes in source code,
52 | # routes, locales, etc. This feature depends on the listen gem.
53 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker
54 |
55 | config.action_mailer.delivery_method = :smtp
56 | config.action_mailer.raise_delivery_errors = true
57 | config.action_mailer.smtp_settings = {
58 | address: ENV['MAIL_ADDRESS'],
59 | port: ENV['MAIL_PORT'],
60 | user_name: ENV['MAIL_USER'],
61 | password: ENV['MAIL_PASS'],
62 | domain: ENV['MAIL_DOMAIN']
63 | }
64 | config.action_mailer.logger = Logger.new(config.paths['log'].first)
65 | config.action_mailer.logger.level = Logger::INFO
66 | config.action_mailer.default_url_options = { host: 'localhost:3000', protocol: 'http' }
67 |
68 | config.action_controller.asset_host = 'http://localhost:3000'
69 | end
70 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | Rails.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 | # Attempt to read encrypted secrets from `config/secrets.yml.enc`.
18 | # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
19 | # `config/secrets.yml.key`.
20 | config.read_encrypted_secrets = true
21 |
22 | # Disable serving static files from the `/public` folder by default since
23 | # Apache or NGINX already handles this.
24 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
25 |
26 | # Compress JavaScripts and CSS.
27 | config.assets.js_compressor = :uglifier
28 | # config.assets.css_compressor = :sass
29 |
30 | # Do not fallback to assets pipeline if a precompiled asset is missed.
31 | config.assets.compile = false
32 |
33 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
34 |
35 | # Enable serving of images, stylesheets, and JavaScripts from an asset server.
36 | # config.action_controller.asset_host = 'http://assets.example.com'
37 |
38 | # Specifies the header that your server uses for sending files.
39 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
40 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
41 |
42 | # Mount Action Cable outside main process or domain
43 | # config.action_cable.mount_path = nil
44 | # config.action_cable.url = 'wss://example.com/cable'
45 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
46 |
47 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
48 | # config.force_ssl = true
49 |
50 | # Use the lowest log level to ensure availability of diagnostic information
51 | # when problems arise.
52 | config.log_level = :debug
53 |
54 | # Prepend all log lines with the following tags.
55 | config.log_tags = [ :request_id ]
56 |
57 | # Use a different cache store in production.
58 | # config.cache_store = :mem_cache_store
59 |
60 | # Use a real queuing backend for Active Job (and separate queues per environment)
61 | # config.active_job.queue_adapter = :resque
62 | # config.active_job.queue_name_prefix = "react-devise-sample_#{Rails.env}"
63 | config.action_mailer.perform_caching = false
64 |
65 | # Ignore bad email addresses and do not raise email delivery errors.
66 | # Set this to true and configure the email server for immediate delivery to raise delivery errors.
67 | # config.action_mailer.raise_delivery_errors = false
68 |
69 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
70 | # the I18n.default_locale when a translation cannot be found).
71 | config.i18n.fallbacks = true
72 |
73 | # Send deprecation notices to registered listeners.
74 | config.active_support.deprecation = :notify
75 |
76 | # Use default logging formatter so that PID and timestamp are not suppressed.
77 | config.log_formatter = ::Logger::Formatter.new
78 |
79 | # Use a different logger for distributed setups.
80 | # require 'syslog/logger'
81 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
82 |
83 | if ENV["RAILS_LOG_TO_STDOUT"].present?
84 | logger = ActiveSupport::Logger.new(STDOUT)
85 | logger.formatter = config.log_formatter
86 | config.logger = ActiveSupport::TaggedLogging.new(logger)
87 | end
88 |
89 | # Do not dump schema after migrations.
90 | config.active_record.dump_schema_after_migration = false
91 | end
92 |
--------------------------------------------------------------------------------
/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # The test environment is used exclusively to run your application's
5 | # test suite. You never need to work with it otherwise. Remember that
6 | # your test database is "scratch space" for the test suite and is wiped
7 | # and recreated between test runs. Don't rely on the data there!
8 | config.cache_classes = true
9 |
10 | # Do not eager load code on boot. This avoids loading your whole application
11 | # just for the purpose of running a single test. If you are using a tool that
12 | # preloads Rails for running tests, you may have to set it to true.
13 | config.eager_load = false
14 |
15 | # Configure public file server for tests with Cache-Control for performance.
16 | config.public_file_server.enabled = true
17 | config.public_file_server.headers = {
18 | 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}"
19 | }
20 |
21 | # Show full error reports and disable caching.
22 | config.consider_all_requests_local = true
23 | config.action_controller.perform_caching = false
24 |
25 | # Raise exceptions instead of rendering exception templates.
26 | config.action_dispatch.show_exceptions = false
27 |
28 | # Disable request forgery protection in test environment.
29 | config.action_controller.allow_forgery_protection = false
30 | config.action_mailer.perform_caching = false
31 |
32 | # Tell Action Mailer not to deliver emails to the real world.
33 | # The :test delivery method accumulates sent emails in the
34 | # ActionMailer::Base.deliveries array.
35 | config.action_mailer.delivery_method = :test
36 |
37 | # Print deprecation notices to the stderr.
38 | config.active_support.deprecation = :stderr
39 |
40 | # Raises error for missing translations
41 | # config.action_view.raise_on_missing_translations = true
42 | end
43 |
--------------------------------------------------------------------------------
/config/initializers/application_controller_renderer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # ApplicationController.renderer.defaults.merge!(
4 | # http_host: 'example.org',
5 | # https: false
6 | # )
7 |
--------------------------------------------------------------------------------
/config/initializers/assets.rb:
--------------------------------------------------------------------------------
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 | # Add Yarn node_modules folder to the asset load path.
9 | Rails.application.config.assets.paths << Rails.root.join('node_modules')
10 |
11 | # Precompile additional assets.
12 | # application.js, application.css, and all non-JS/CSS in the app/assets
13 | # folder are already added.
14 | # Rails.application.config.assets.precompile += %w( admin.js admin.css )
15 |
--------------------------------------------------------------------------------
/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
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!
8 |
--------------------------------------------------------------------------------
/config/initializers/cookies_serializer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Specify a serializer for the signed and encrypted cookie jars.
4 | # Valid options are :json, :marshal, and :hybrid.
5 | Rails.application.config.action_dispatch.cookies_serializer = :json
6 |
--------------------------------------------------------------------------------
/config/initializers/devise.rb:
--------------------------------------------------------------------------------
1 | # Use this hook to configure devise mailer, warden hooks and so forth.
2 | # Many of these configuration options can be set straight in your model.
3 | Devise.setup do |config|
4 | # The secret key used by Devise. Devise uses this key to generate
5 | # random tokens. Changing this key will render invalid all existing
6 | # confirmation, reset password and unlock tokens in the database.
7 | # Devise will use the `secret_key_base` as its `secret_key`
8 | # by default. You can change it below and use your own secret key.
9 | # config.secret_key = '924f6060fce8be0c38b7080981619d76e2886b5b360e43453ebed827a46e8ab879e30461faff86fec001c5c1d49abee6844fc086b7533fc95ae6ad3ca30e4db7'
10 |
11 | # ==> Mailer Configuration
12 | # Configure the e-mail address which will be shown in Devise::Mailer,
13 | # note that it will be overwritten if you use your own mailer class
14 | # with default "from" parameter.
15 | config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
16 |
17 | # Configure the class responsible to send e-mails.
18 | # config.mailer = 'Devise::Mailer'
19 |
20 | # Configure the parent class responsible to send e-mails.
21 | # config.parent_mailer = 'ActionMailer::Base'
22 |
23 | # ==> ORM configuration
24 | # Load and configure the ORM. Supports :active_record (default) and
25 | # :mongoid (bson_ext recommended) by default. Other ORMs may be
26 | # available as additional gems.
27 | require 'devise/orm/active_record'
28 |
29 | # ==> Configuration for any authentication mechanism
30 | # Configure which keys are used when authenticating a user. The default is
31 | # just :email. You can configure it to use [:username, :subdomain], so for
32 | # authenticating a user, both parameters are required. Remember that those
33 | # parameters are used only when authenticating and not when retrieving from
34 | # session. If you need permissions, you should implement that in a before filter.
35 | # You can also supply a hash where the value is a boolean determining whether
36 | # or not authentication should be aborted when the value is not present.
37 | # config.authentication_keys = [:email]
38 |
39 | # Configure parameters from the request object used for authentication. Each entry
40 | # given should be a request method and it will automatically be passed to the
41 | # find_for_authentication method and considered in your model lookup. For instance,
42 | # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
43 | # The same considerations mentioned for authentication_keys also apply to request_keys.
44 | # config.request_keys = []
45 |
46 | # Configure which authentication keys should be case-insensitive.
47 | # These keys will be downcased upon creating or modifying a user and when used
48 | # to authenticate or find a user. Default is :email.
49 | config.case_insensitive_keys = [:email]
50 |
51 | # Configure which authentication keys should have whitespace stripped.
52 | # These keys will have whitespace before and after removed upon creating or
53 | # modifying a user and when used to authenticate or find a user. Default is :email.
54 | config.strip_whitespace_keys = [:email]
55 |
56 | # Tell if authentication through request.params is enabled. True by default.
57 | # It can be set to an array that will enable params authentication only for the
58 | # given strategies, for example, `config.params_authenticatable = [:database]` will
59 | # enable it only for database (email + password) authentication.
60 | # config.params_authenticatable = true
61 |
62 | # Tell if authentication through HTTP Auth is enabled. False by default.
63 | # It can be set to an array that will enable http authentication only for the
64 | # given strategies, for example, `config.http_authenticatable = [:database]` will
65 | # enable it only for database authentication. The supported strategies are:
66 | # :database = Support basic authentication with authentication key + password
67 | # config.http_authenticatable = false
68 |
69 | # If 401 status code should be returned for AJAX requests. True by default.
70 | # config.http_authenticatable_on_xhr = true
71 |
72 | # The realm used in Http Basic Authentication. 'Application' by default.
73 | # config.http_authentication_realm = 'Application'
74 |
75 | # It will change confirmation, password recovery and other workflows
76 | # to behave the same regardless if the e-mail provided was right or wrong.
77 | # Does not affect registerable.
78 | # config.paranoid = true
79 |
80 | # By default Devise will store the user in session. You can skip storage for
81 | # particular strategies by setting this option.
82 | # Notice that if you are skipping storage for all authentication paths, you
83 | # may want to disable generating routes to Devise's sessions controller by
84 | # passing skip: :sessions to `devise_for` in your config/routes.rb
85 | config.skip_session_storage = [:http_auth]
86 |
87 | # By default, Devise cleans up the CSRF token on authentication to
88 | # avoid CSRF token fixation attacks. This means that, when using AJAX
89 | # requests for sign in and sign up, you need to get a new CSRF token
90 | # from the server. You can disable this option at your own risk.
91 | # config.clean_up_csrf_token_on_authentication = true
92 |
93 | # When false, Devise will not attempt to reload routes on eager load.
94 | # This can reduce the time taken to boot the app but if your application
95 | # requires the Devise mappings to be loaded during boot time the application
96 | # won't boot properly.
97 | # config.reload_routes = true
98 |
99 | # ==> Configuration for :database_authenticatable
100 | # For bcrypt, this is the cost for hashing the password and defaults to 11. If
101 | # using other algorithms, it sets how many times you want the password to be hashed.
102 | #
103 | # Limiting the stretches to just one in testing will increase the performance of
104 | # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
105 | # a value less than 10 in other environments. Note that, for bcrypt (the default
106 | # algorithm), the cost increases exponentially with the number of stretches (e.g.
107 | # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
108 | config.stretches = Rails.env.test? ? 1 : 11
109 |
110 | # Set up a pepper to generate the hashed password.
111 | # config.pepper = 'fbcc3a75fd199e44bf8d10ed0eb8eda101994c45c59197986bcc0bd129933731afb986c76d0420d94ecb1a9086eb280ebe47a2c55d6325e86e85923b917454a0'
112 |
113 | # Send a notification to the original email when the user's email is changed.
114 | # config.send_email_changed_notification = false
115 |
116 | # Send a notification email when the user's password is changed.
117 | # config.send_password_change_notification = false
118 |
119 | # ==> Configuration for :confirmable
120 | # A period that the user is allowed to access the website even without
121 | # confirming their account. For instance, if set to 2.days, the user will be
122 | # able to access the website for two days without confirming their account,
123 | # access will be blocked just in the third day. Default is 0.days, meaning
124 | # the user cannot access the website without confirming their account.
125 | # config.allow_unconfirmed_access_for = 2.days
126 |
127 | # A period that the user is allowed to confirm their account before their
128 | # token becomes invalid. For example, if set to 3.days, the user can confirm
129 | # their account within 3 days after the mail was sent, but on the fourth day
130 | # their account can't be confirmed with the token any more.
131 | # Default is nil, meaning there is no restriction on how long a user can take
132 | # before confirming their account.
133 | # config.confirm_within = 3.days
134 |
135 | # If true, requires any email changes to be confirmed (exactly the same way as
136 | # initial account confirmation) to be applied. Requires additional unconfirmed_email
137 | # db field (see migrations). Until confirmed, new email is stored in
138 | # unconfirmed_email column, and copied to email column on successful confirmation.
139 | config.reconfirmable = true
140 |
141 | # Defines which key will be used when confirming an account
142 | # config.confirmation_keys = [:email]
143 |
144 | # ==> Configuration for :rememberable
145 | # The time the user will be remembered without asking for credentials again.
146 | # config.remember_for = 2.weeks
147 |
148 | # Invalidates all the remember me tokens when the user signs out.
149 | config.expire_all_remember_me_on_sign_out = true
150 |
151 | # If true, extends the user's remember period when remembered via cookie.
152 | # config.extend_remember_period = false
153 |
154 | # Options to be passed to the created cookie. For instance, you can set
155 | # secure: true in order to force SSL only cookies.
156 | # config.rememberable_options = {}
157 |
158 | # ==> Configuration for :validatable
159 | # Range for password length.
160 | config.password_length = 6..128
161 |
162 | # Email regex used to validate email formats. It simply asserts that
163 | # one (and only one) @ exists in the given string. This is mainly
164 | # to give user feedback and not to assert the e-mail validity.
165 | config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
166 |
167 | # ==> Configuration for :timeoutable
168 | # The time you want to timeout the user session without activity. After this
169 | # time the user will be asked for credentials again. Default is 30 minutes.
170 | # config.timeout_in = 30.minutes
171 |
172 | # ==> Configuration for :lockable
173 | # Defines which strategy will be used to lock an account.
174 | # :failed_attempts = Locks an account after a number of failed attempts to sign in.
175 | # :none = No lock strategy. You should handle locking by yourself.
176 | # config.lock_strategy = :failed_attempts
177 |
178 | # Defines which key will be used when locking and unlocking an account
179 | # config.unlock_keys = [:email]
180 |
181 | # Defines which strategy will be used to unlock an account.
182 | # :email = Sends an unlock link to the user email
183 | # :time = Re-enables login after a certain amount of time (see :unlock_in below)
184 | # :both = Enables both strategies
185 | # :none = No unlock strategy. You should handle unlocking by yourself.
186 | # config.unlock_strategy = :both
187 |
188 | # Number of authentication tries before locking an account if lock_strategy
189 | # is failed attempts.
190 | # config.maximum_attempts = 20
191 |
192 | # Time interval to unlock the account if :time is enabled as unlock_strategy.
193 | # config.unlock_in = 1.hour
194 |
195 | # Warn on the last attempt before the account is locked.
196 | # config.last_attempt_warning = true
197 |
198 | # ==> Configuration for :recoverable
199 | #
200 | # Defines which key will be used when recovering the password for an account
201 | # config.reset_password_keys = [:email]
202 |
203 | # Time interval you can reset your password with a reset password key.
204 | # Don't put a too small interval or your users won't have the time to
205 | # change their passwords.
206 | config.reset_password_within = 6.hours
207 |
208 | # When set to false, does not sign a user in automatically after their password is
209 | # reset. Defaults to true, so a user is signed in automatically after a reset.
210 | # config.sign_in_after_reset_password = true
211 |
212 | # ==> Configuration for :encryptable
213 | # Allow you to use another hashing or encryption algorithm besides bcrypt (default).
214 | # You can use :sha1, :sha512 or algorithms from others authentication tools as
215 | # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
216 | # for default behavior) and :restful_authentication_sha1 (then you should set
217 | # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
218 | #
219 | # Require the `devise-encryptable` gem when using anything other than bcrypt
220 | # config.encryptor = :sha512
221 |
222 | # ==> Scopes configuration
223 | # Turn scoped views on. Before rendering "sessions/new", it will first check for
224 | # "users/sessions/new". It's turned off by default because it's slower if you
225 | # are using only default views.
226 | # config.scoped_views = false
227 |
228 | # Configure the default scope given to Warden. By default it's the first
229 | # devise role declared in your routes (usually :user).
230 | # config.default_scope = :user
231 |
232 | # Set this configuration to false if you want /users/sign_out to sign out
233 | # only the current scope. By default, Devise signs out all scopes.
234 | # config.sign_out_all_scopes = true
235 |
236 | # ==> Navigation configuration
237 | # Lists the formats that should be treated as navigational. Formats like
238 | # :html, should redirect to the sign in page when the user does not have
239 | # access, but formats like :xml or :json, should return 401.
240 | #
241 | # If you have any extra navigational formats, like :iphone or :mobile, you
242 | # should add them to the navigational formats lists.
243 | #
244 | # The "*/*" below is required to match Internet Explorer requests.
245 | # config.navigational_formats = ['*/*', :html]
246 | config.navigational_formats = [:json]
247 |
248 | # The default HTTP method used to sign out a resource. Default is :delete.
249 | config.sign_out_via = :delete
250 |
251 | # ==> OmniAuth
252 | # Add a new OmniAuth provider. Check the wiki for more information on setting
253 | # up on your models and hooks.
254 | # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
255 |
256 | # ==> Warden configuration
257 | # If you want to use other strategies, that are not supported by Devise, or
258 | # change the failure app, you can configure them inside the config.warden block.
259 | #
260 | # config.warden do |manager|
261 | # manager.intercept_401 = false
262 | # manager.default_strategies(scope: :user).unshift :some_external_strategy
263 | # end
264 |
265 | # ==> Mountable engine configurations
266 | # When using Devise inside an engine, let's call it `MyEngine`, and this engine
267 | # is mountable, there are some extra configurations to be taken into account.
268 | # The following options are available, assuming the engine is mounted as:
269 | #
270 | # mount MyEngine, at: '/my_engine'
271 | #
272 | # The router that invoked `devise_for`, in the example above, would be:
273 | # config.router_name = :my_engine
274 | #
275 | # When using OmniAuth, Devise cannot automatically set OmniAuth path,
276 | # so you need to do it manually. For the users scope, it would be:
277 | # config.omniauth_path_prefix = '/my_engine/users/auth'
278 | end
279 |
--------------------------------------------------------------------------------
/config/initializers/devise_token_auth.rb:
--------------------------------------------------------------------------------
1 | DeviseTokenAuth.setup do |config|
2 | # By default the authorization headers will change after each request. The
3 | # client is responsible for keeping track of the changing tokens. Change
4 | # this to false to prevent the Authorization header from changing after
5 | # each request.
6 | config.change_headers_on_each_request = false
7 |
8 | # By default, users will need to re-authenticate after 2 weeks. This setting
9 | # determines how long tokens will remain valid after they are issued.
10 | # config.token_lifespan = 2.weeks
11 |
12 | # Sets the max number of concurrent devices per user, which is 10 by default.
13 | # After this limit is reached, the oldest tokens will be removed.
14 | # config.max_number_of_devices = 10
15 |
16 | # Sometimes it's necessary to make several requests to the API at the same
17 | # time. In this case, each request in the batch will need to share the same
18 | # auth token. This setting determines how far apart the requests can be while
19 | # still using the same auth token.
20 | # config.batch_request_buffer_throttle = 5.seconds
21 |
22 | # This route will be the prefix for all oauth2 redirect callbacks. For
23 | # example, using the default '/omniauth', the github oauth2 provider will
24 | # redirect successful authentications to '/omniauth/github/callback'
25 | # config.omniauth_prefix = "/omniauth"
26 |
27 | # By default sending current password is not needed for the password update.
28 | # Uncomment to enforce current_password param to be checked before all
29 | # attribute updates. Set it to :password if you want it to be checked only if
30 | # password is updated.
31 | # config.check_current_password_before_update = :attributes
32 |
33 | # By default we will use callbacks for single omniauth.
34 | # It depends on fields like email, provider and uid.
35 | # config.default_callbacks = true
36 |
37 | # Makes it possible to change the headers names
38 | # config.headers_names = {:'access-token' => 'access-token',
39 | # :'client' => 'client',
40 | # :'expiry' => 'expiry',
41 | # :'uid' => 'uid',
42 | # :'token-type' => 'token-type' }
43 |
44 | # By default, only Bearer Token authentication is implemented out of the box.
45 | # If, however, you wish to integrate with legacy Devise authentication, you can
46 | # do so by enabling this flag. NOTE: This feature is highly experimental!
47 | # config.enable_standard_devise_support = false
48 | end
49 |
--------------------------------------------------------------------------------
/config/initializers/filter_parameter_logging.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Configure sensitive parameters which will be filtered from the log file.
4 | Rails.application.config.filter_parameters += [:password]
5 |
--------------------------------------------------------------------------------
/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format. Inflections
4 | # are locale specific, and you may define rules for as many different
5 | # locales as you wish. All of these examples are active by default:
6 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
7 | # inflect.plural /^(ox)$/i, '\1en'
8 | # inflect.singular /^(ox)en/i, '\1'
9 | # inflect.irregular 'person', 'people'
10 | # inflect.uncountable %w( fish sheep )
11 | # end
12 |
13 | # These inflection rules are supported but not enabled by default:
14 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
15 | # inflect.acronym 'RESTful'
16 | # end
17 |
--------------------------------------------------------------------------------
/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 |
--------------------------------------------------------------------------------
/config/initializers/omniauth.rb:
--------------------------------------------------------------------------------
1 | Rails.application.config.middleware.use OmniAuth::Builder do
2 | provider :facebook, ENV['FACEBOOK_KEY'], ENV['FACEBOOK_SECRET']
3 | end
4 |
--------------------------------------------------------------------------------
/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # This file contains settings for ActionController::ParamsWrapper which
4 | # is enabled by default.
5 |
6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7 | ActiveSupport.on_load(:action_controller) do
8 | wrap_parameters format: [:json]
9 | end
10 |
11 | # To enable root element in JSON for ActiveRecord objects.
12 | # ActiveSupport.on_load(:active_record) do
13 | # self.include_root_in_json = true
14 | # end
15 |
--------------------------------------------------------------------------------
/config/locales/devise.en.yml:
--------------------------------------------------------------------------------
1 | # Additional translations at https://github.com/plataformatec/devise/wiki/I18n
2 |
3 | en:
4 | devise:
5 | confirmations:
6 | confirmed: "Your email address has been successfully confirmed."
7 | send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
8 | send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
9 | failure:
10 | already_authenticated: "You are already signed in."
11 | inactive: "Your account is not activated yet."
12 | invalid: "Invalid %{authentication_keys} or password."
13 | locked: "Your account is locked."
14 | last_attempt: "You have one more attempt before your account is locked."
15 | not_found_in_database: "Invalid %{authentication_keys} or password."
16 | timeout: "Your session expired. Please sign in again to continue."
17 | unauthenticated: "You need to sign in or sign up before continuing."
18 | unconfirmed: "You have to confirm your email address before continuing."
19 | mailer:
20 | confirmation_instructions:
21 | subject: "Confirmation instructions"
22 | reset_password_instructions:
23 | subject: "Reset password instructions"
24 | unlock_instructions:
25 | subject: "Unlock instructions"
26 | email_changed:
27 | subject: "Email Changed"
28 | password_change:
29 | subject: "Password Changed"
30 | omniauth_callbacks:
31 | failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
32 | success: "Successfully authenticated from %{kind} account."
33 | passwords:
34 | no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
35 | send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
36 | send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
37 | updated: "Your password has been changed successfully. You are now signed in."
38 | updated_not_active: "Your password has been changed successfully."
39 | registrations:
40 | destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
41 | signed_up: "Welcome! You have signed up successfully."
42 | signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
43 | signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
44 | signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
45 | update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address."
46 | updated: "Your account has been updated successfully."
47 | sessions:
48 | signed_in: "Signed in successfully."
49 | signed_out: "Signed out successfully."
50 | already_signed_out: "Signed out successfully."
51 | unlocks:
52 | send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
53 | send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
54 | unlocked: "Your account has been unlocked successfully. Please sign in to continue."
55 | errors:
56 | messages:
57 | already_confirmed: "was already confirmed, please try signing in"
58 | confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
59 | expired: "has expired, please request a new one"
60 | not_found: "not found"
61 | not_locked: "was not locked"
62 | not_saved:
63 | one: "1 error prohibited this %{resource} from being saved:"
64 | other: "%{count} errors prohibited this %{resource} from being saved:"
65 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than English, add the necessary files in this directory.
4 | #
5 | # To use the locales, use `I18n.t`:
6 | #
7 | # I18n.t 'hello'
8 | #
9 | # In views, this is aliased to just `t`:
10 | #
11 | # <%= t('hello') %>
12 | #
13 | # To use a different locale, set it with `I18n.locale`:
14 | #
15 | # I18n.locale = :es
16 | #
17 | # This would use the information in config/locales/es.yml.
18 | #
19 | # The following keys must be escaped otherwise they will not be retrieved by
20 | # the default I18n backend:
21 | #
22 | # true, false, on, off, yes, no
23 | #
24 | # Instead, surround them with single quotes.
25 | #
26 | # en:
27 | # 'true': 'foo'
28 | #
29 | # To learn more, please read the Rails Internationalization guide
30 | # available at http://guides.rubyonrails.org/i18n.html.
31 |
32 | en:
33 | hello: "Hello world"
34 |
--------------------------------------------------------------------------------
/config/puma.rb:
--------------------------------------------------------------------------------
1 | # Puma can serve each request in a thread from an internal thread pool.
2 | # The `threads` method setting takes two numbers: a minimum and maximum.
3 | # Any libraries that use thread pools should be configured to match
4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum
5 | # and maximum; this matches the default thread size of Active Record.
6 | #
7 | threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
8 | threads threads_count, threads_count
9 |
10 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
11 | #
12 | port ENV.fetch("PORT") { 3000 }
13 |
14 | # Specifies the `environment` that Puma will run in.
15 | #
16 | environment ENV.fetch("RAILS_ENV") { "development" }
17 |
18 | # Specifies the number of `workers` to boot in clustered mode.
19 | # Workers are forked webserver processes. If using threads and workers together
20 | # the concurrency of the application would be max `threads` * `workers`.
21 | # Workers do not work on JRuby or Windows (both of which do not support
22 | # processes).
23 | #
24 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
25 |
26 | # Use the `preload_app!` method when specifying a `workers` number.
27 | # This directive tells Puma to first boot the application and load code
28 | # before forking the application. This takes advantage of Copy On Write
29 | # process behavior so workers use less memory. If you use this option
30 | # you need to make sure to reconnect any threads in the `on_worker_boot`
31 | # block.
32 | #
33 | # preload_app!
34 |
35 | # If you are preloading your application and using Active Record, it's
36 | # recommended that you close any connections to the database before workers
37 | # are forked to prevent connection leakage.
38 | #
39 | # before_fork do
40 | # ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)
41 | # end
42 |
43 | # The code in the `on_worker_boot` will be called if you are using
44 | # clustered mode by specifying a number of `workers`. After each worker
45 | # process is booted, this block will be run. If you are using the `preload_app!`
46 | # option, you will want to use this block to reconnect to any threads
47 | # or connections that may have been created at application boot, as Ruby
48 | # cannot share connections between processes.
49 | #
50 | # on_worker_boot do
51 | # ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
52 | # end
53 | #
54 |
55 | # Allow puma to be restarted by `rails restart` command.
56 | plugin :tmp_restart
57 |
--------------------------------------------------------------------------------
/config/routes.rb:
--------------------------------------------------------------------------------
1 | Rails.application.routes.draw do
2 | mount_devise_token_auth_for 'User', at: 'auth', defaults: { format: "json" }
3 |
4 | namespace :api, defaults: { format: :json } do
5 | resources :notes, only: [:index, :show, :update, :create, :destroy]
6 | end
7 |
8 | get '/confirm_success' => 'home#confirm_success'
9 | get '/notes' => 'home#index'
10 | get '/notes/new' => 'home#index'
11 | get '/notes/:id/edit' => 'home#index'
12 | get '/notes/:id' => 'home#index'
13 | get '/signup' => 'home#index'
14 | get '/login' => 'home#index'
15 | root 'home#index'
16 |
17 | # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
18 | end
19 |
--------------------------------------------------------------------------------
/config/secrets.yml:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Your secret key is used for verifying the integrity of signed cookies.
4 | # If you change this key, all old signed cookies will become invalid!
5 |
6 | # Make sure the secret is at least 30 characters and all random,
7 | # no regular words or you'll be exposed to dictionary attacks.
8 | # You can use `rails secret` to generate a secure secret key.
9 |
10 | # Make sure the secrets in this file are kept private
11 | # if you're sharing your code publicly.
12 |
13 | # Shared secrets are available across all environments.
14 |
15 | # shared:
16 | # api_key: a1B2c3D4e5F6
17 |
18 | # Environmental secrets are only available for that specific environment.
19 |
20 | development:
21 | secret_key_base: 8eacbf0f702d00310cda145d3a2fc22e06c83335e64f892ea2d783f2e5080e5d4315e117c59aea203ab02906a83bd27c34f26a48716e840502ef69ce543c59db
22 |
23 | test:
24 | secret_key_base: 3de61ada4ea4579d254405ea579a504c2f015a87d5318a78dc2d9fe1aa9bf7ba900931ee74428183249888e057a36287e861f3c08a2b74279f4b3f897df7b8cb
25 |
26 | # Do not keep production secrets in the unencrypted secrets file.
27 | # Instead, either read values from the environment.
28 | # Or, use `bin/rails secrets:setup` to configure encrypted secrets
29 | # and move the `production:` environment over there.
30 |
31 | production:
32 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
33 |
--------------------------------------------------------------------------------
/config/spring.rb:
--------------------------------------------------------------------------------
1 | %w(
2 | .ruby-version
3 | .rbenv-vars
4 | tmp/restart.txt
5 | tmp/caching-dev.txt
6 | ).each { |path| Spring.watch(path) }
7 |
--------------------------------------------------------------------------------
/config/webpack/configuration.js:
--------------------------------------------------------------------------------
1 | // Common configuration for webpacker loaded from config/webpacker.yml
2 |
3 | const { join, resolve } = require('path')
4 | const { env } = require('process')
5 | const { safeLoad } = require('js-yaml')
6 | const { readFileSync } = require('fs')
7 |
8 | const configPath = resolve('config', 'webpacker.yml')
9 | const loadersDir = join(__dirname, 'loaders')
10 | const settings = safeLoad(readFileSync(configPath), 'utf8')[env.NODE_ENV]
11 |
12 | function removeOuterSlashes(string) {
13 | return string.replace(/^\/*/, '').replace(/\/*$/, '')
14 | }
15 |
16 | function formatPublicPath(host = '', path = '') {
17 | let formattedHost = removeOuterSlashes(host)
18 | if (formattedHost && !/^http/i.test(formattedHost)) {
19 | formattedHost = `//${formattedHost}`
20 | }
21 | const formattedPath = removeOuterSlashes(path)
22 | return `${formattedHost}/${formattedPath}/`
23 | }
24 |
25 | const output = {
26 | path: resolve('public', settings.public_output_path),
27 | publicPath: formatPublicPath(env.ASSET_HOST, settings.public_output_path)
28 | }
29 |
30 | module.exports = {
31 | settings,
32 | env,
33 | loadersDir,
34 | output
35 | }
36 |
--------------------------------------------------------------------------------
/config/webpack/development.js:
--------------------------------------------------------------------------------
1 | // Note: You must restart bin/webpack-dev-server for changes to take effect
2 |
3 | const merge = require('webpack-merge')
4 | const sharedConfig = require('./shared.js')
5 | const { settings, output } = require('./configuration.js')
6 |
7 | module.exports = merge(sharedConfig, {
8 | devtool: 'cheap-eval-source-map',
9 |
10 | stats: {
11 | errorDetails: true
12 | },
13 |
14 | output: {
15 | pathinfo: true
16 | },
17 |
18 | devServer: {
19 | clientLogLevel: 'none',
20 | https: settings.dev_server.https,
21 | host: settings.dev_server.host,
22 | port: settings.dev_server.port,
23 | contentBase: output.path,
24 | publicPath: output.publicPath,
25 | compress: true,
26 | headers: { 'Access-Control-Allow-Origin': '*' },
27 | historyApiFallback: true,
28 | watchOptions: {
29 | ignored: /node_modules/
30 | }
31 | }
32 | })
33 |
--------------------------------------------------------------------------------
/config/webpack/loaders/assets.js:
--------------------------------------------------------------------------------
1 | const { env, publicPath } = require('../configuration.js')
2 |
3 | module.exports = {
4 | test: /\.(jpg|jpeg|png|gif|svg|eot|ttf|woff|woff2)$/i,
5 | use: [{
6 | loader: 'file-loader',
7 | options: {
8 | publicPath,
9 | name: env.NODE_ENV === 'production' ? '[name]-[hash].[ext]' : '[name].[ext]'
10 | }
11 | }]
12 | }
13 |
--------------------------------------------------------------------------------
/config/webpack/loaders/babel.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | test: /\.js(\.erb)?$/,
3 | exclude: /node_modules/,
4 | loader: 'babel-loader'
5 | }
6 |
--------------------------------------------------------------------------------
/config/webpack/loaders/coffee.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | test: /\.coffee(\.erb)?$/,
3 | loader: 'coffee-loader'
4 | }
5 |
--------------------------------------------------------------------------------
/config/webpack/loaders/erb.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | test: /\.erb$/,
3 | enforce: 'pre',
4 | exclude: /node_modules/,
5 | loader: 'rails-erb-loader',
6 | options: {
7 | runner: 'bin/rails runner'
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/config/webpack/loaders/react.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | test: /\.(js|jsx)?(\.erb)?$/,
3 | exclude: /node_modules/,
4 | loader: 'babel-loader',
5 | query: {
6 | presets:['react', 'stage-2']
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/config/webpack/loaders/sass.js:
--------------------------------------------------------------------------------
1 | const ExtractTextPlugin = require('extract-text-webpack-plugin')
2 | const { env } = require('../configuration.js')
3 |
4 | module.exports = {
5 | test: /\.(scss|sass|css)$/i,
6 | use: ExtractTextPlugin.extract({
7 | fallback: 'style-loader',
8 | use: [
9 | {
10 | loader: 'css-loader',
11 | // options: { minimize: env.NODE_ENV === 'production' },
12 | options: {
13 | minimize: env.NODE_ENV === 'production',
14 | modules: true,
15 | importLoaders: 1,
16 | localIdentName: "[path]__[name]__[local]__[hash:base64:5]"
17 | }
18 | },
19 | { loader: 'postcss-loader', options: { sourceMap: true } },
20 | 'resolve-url-loader',
21 | { loader: 'sass-loader', options: { sourceMap: true } }
22 | ]
23 | })
24 | }
25 |
--------------------------------------------------------------------------------
/config/webpack/production.js:
--------------------------------------------------------------------------------
1 | // Note: You must restart bin/webpack-dev-server for changes to take effect
2 |
3 | /* eslint global-require: 0 */
4 |
5 | const webpack = require('webpack')
6 | const merge = require('webpack-merge')
7 | const CompressionPlugin = require('compression-webpack-plugin')
8 | const sharedConfig = require('./shared.js')
9 |
10 | module.exports = merge(sharedConfig, {
11 | output: { filename: '[name]-[chunkhash].js' },
12 | devtool: 'source-map',
13 | stats: 'normal',
14 |
15 | plugins: [
16 | new webpack.optimize.UglifyJsPlugin({
17 | minimize: true,
18 | sourceMap: true,
19 |
20 | compress: {
21 | warnings: false
22 | },
23 |
24 | output: {
25 | comments: false
26 | }
27 | }),
28 |
29 | new CompressionPlugin({
30 | asset: '[path].gz[query]',
31 | algorithm: 'gzip',
32 | test: /\.(js|css|html|json|ico|svg|eot|otf|ttf)$/
33 | })
34 | ]
35 | })
36 |
--------------------------------------------------------------------------------
/config/webpack/shared.js:
--------------------------------------------------------------------------------
1 | // Note: You must restart bin/webpack-dev-server for changes to take effect
2 |
3 | /* eslint global-require: 0 */
4 | /* eslint import/no-dynamic-require: 0 */
5 |
6 | const webpack = require('webpack')
7 | const { basename, dirname, join, relative, resolve } = require('path')
8 | const { sync } = require('glob')
9 | const ExtractTextPlugin = require('extract-text-webpack-plugin')
10 | const ManifestPlugin = require('webpack-manifest-plugin')
11 | const extname = require('path-complete-extname')
12 | const { env, settings, output, loadersDir } = require('./configuration.js')
13 |
14 | const extensionGlob = `**/*{${settings.extensions.join(',')}}*`
15 | const entryPath = join(settings.source_path, settings.source_entry_path)
16 | const packPaths = sync(join(entryPath, extensionGlob))
17 |
18 | module.exports = {
19 | entry: packPaths.reduce(
20 | (map, entry) => {
21 | const localMap = map
22 | const namespace = relative(join(entryPath), dirname(entry))
23 | localMap[join(namespace, basename(entry, extname(entry)))] = resolve(entry)
24 | return localMap
25 | }, {}
26 | ),
27 |
28 | output: {
29 | filename: '[name].js',
30 | path: output.path,
31 | publicPath: output.publicPath
32 | },
33 |
34 | module: {
35 | rules: sync(join(loadersDir, '*.js')).map(loader => require(loader))
36 | },
37 |
38 | plugins: [
39 | new webpack.EnvironmentPlugin(JSON.parse(JSON.stringify(env))),
40 | new ExtractTextPlugin(env.NODE_ENV === 'production' ? '[name]-[hash].css' : '[name].css'),
41 | new ManifestPlugin({
42 | publicPath: output.publicPath,
43 | writeToFileEmit: true
44 | })
45 | ],
46 |
47 | resolve: {
48 | extensions: settings.extensions,
49 | modules: [
50 | resolve(settings.source_path),
51 | 'node_modules'
52 | ]
53 | },
54 |
55 | resolveLoader: {
56 | modules: ['node_modules']
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/config/webpack/test.js:
--------------------------------------------------------------------------------
1 | // Note: You must restart bin/webpack-dev-server for changes to take effect
2 |
3 | const merge = require('webpack-merge')
4 | const sharedConfig = require('./shared.js')
5 |
6 | module.exports = merge(sharedConfig, {})
7 |
--------------------------------------------------------------------------------
/config/webpacker.yml:
--------------------------------------------------------------------------------
1 | # Note: You must restart bin/webpack-dev-server for changes to take effect
2 |
3 | default: &default
4 | source_path: app/javascript
5 | source_entry_path: packs
6 | public_output_path: packs
7 |
8 | extensions:
9 | - .coffee
10 | - .erb
11 | - .js
12 | - .jsx
13 | - .ts
14 | - .vue
15 | - .sass
16 | - .scss
17 | - .css
18 | - .png
19 | - .svg
20 | - .gif
21 | - .jpeg
22 | - .jpg
23 |
24 | development:
25 | <<: *default
26 |
27 | dev_server:
28 | host: 0.0.0.0
29 | port: 8080
30 | https: false
31 |
32 | test:
33 | <<: *default
34 |
35 | public_output_path: packs-test
36 |
37 | production:
38 | <<: *default
39 |
--------------------------------------------------------------------------------
/db/migrate/20170604061340_devise_token_auth_create_users.rb:
--------------------------------------------------------------------------------
1 | class DeviseTokenAuthCreateUsers < ActiveRecord::Migration[5.1]
2 | def change
3 | create_table(:users) do |t|
4 | ## Required
5 | t.string :provider, :null => false, :default => "email"
6 | t.string :uid, :null => false, :default => ""
7 |
8 | ## Database authenticatable
9 | t.string :encrypted_password, :null => false, :default => ""
10 |
11 | ## Recoverable
12 | t.string :reset_password_token
13 | t.datetime :reset_password_sent_at
14 |
15 | ## Rememberable
16 | t.datetime :remember_created_at
17 |
18 | ## Trackable
19 | t.integer :sign_in_count, :default => 0, :null => false
20 | t.datetime :current_sign_in_at
21 | t.datetime :last_sign_in_at
22 | t.string :current_sign_in_ip
23 | t.string :last_sign_in_ip
24 |
25 | ## Confirmable
26 | t.string :confirmation_token
27 | t.datetime :confirmed_at
28 | t.datetime :confirmation_sent_at
29 | t.string :unconfirmed_email # Only if using reconfirmable
30 |
31 | ## Lockable
32 | # t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
33 | # t.string :unlock_token # Only if unlock strategy is :email or :both
34 | # t.datetime :locked_at
35 |
36 | ## User Info
37 | t.string :name
38 | t.string :nickname
39 | t.string :image
40 | t.string :email
41 |
42 | ## Tokens
43 | t.text :tokens
44 |
45 | t.timestamps
46 | end
47 |
48 | add_index :users, :email, unique: true
49 | add_index :users, [:uid, :provider], unique: true
50 | add_index :users, :reset_password_token, unique: true
51 | add_index :users, :confirmation_token, unique: true
52 | # add_index :users, :unlock_token, unique: true
53 | end
54 | end
55 |
--------------------------------------------------------------------------------
/db/migrate/20170605031939_create_notes.rb:
--------------------------------------------------------------------------------
1 | class CreateNotes < ActiveRecord::Migration[5.1]
2 | def change
3 | create_table :notes do |t|
4 | t.string :title
5 | t.text :content
6 | t.references :user, foreign_key: true
7 |
8 | t.timestamps
9 | end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/db/schema.rb:
--------------------------------------------------------------------------------
1 | # This file is auto-generated from the current state of the database. Instead
2 | # of editing this file, please use the migrations feature of Active Record to
3 | # incrementally modify your database, and then regenerate this schema definition.
4 | #
5 | # Note that this schema.rb definition is the authoritative source for your
6 | # database schema. If you need to create the application database on another
7 | # system, you should be using db:schema:load, not running all the migrations
8 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9 | # you'll amass, the slower it'll run and the greater likelihood for issues).
10 | #
11 | # It's strongly recommended that you check this file into your version control system.
12 |
13 | ActiveRecord::Schema.define(version: 20170605031939) do
14 |
15 | create_table "notes", force: :cascade do |t|
16 | t.string "title"
17 | t.text "content"
18 | t.integer "user_id"
19 | t.datetime "created_at", null: false
20 | t.datetime "updated_at", null: false
21 | t.index ["user_id"], name: "index_notes_on_user_id"
22 | end
23 |
24 | create_table "users", force: :cascade do |t|
25 | t.string "provider", default: "email", null: false
26 | t.string "uid", default: "", null: false
27 | t.string "encrypted_password", default: "", null: false
28 | t.string "reset_password_token"
29 | t.datetime "reset_password_sent_at"
30 | t.datetime "remember_created_at"
31 | t.integer "sign_in_count", default: 0, null: false
32 | t.datetime "current_sign_in_at"
33 | t.datetime "last_sign_in_at"
34 | t.string "current_sign_in_ip"
35 | t.string "last_sign_in_ip"
36 | t.string "confirmation_token"
37 | t.datetime "confirmed_at"
38 | t.datetime "confirmation_sent_at"
39 | t.string "unconfirmed_email"
40 | t.string "name"
41 | t.string "nickname"
42 | t.string "image"
43 | t.string "email"
44 | t.text "tokens"
45 | t.datetime "created_at", null: false
46 | t.datetime "updated_at", null: false
47 | t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
48 | t.index ["email"], name: "index_users_on_email", unique: true
49 | t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
50 | t.index ["uid", "provider"], name: "index_users_on_uid_and_provider", unique: true
51 | end
52 |
53 | end
54 |
--------------------------------------------------------------------------------
/db/seeds.rb:
--------------------------------------------------------------------------------
1 | # This file should contain all the record creation needed to seed the database with its default values.
2 | # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
3 | #
4 | # Examples:
5 | #
6 | # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
7 | # Character.create(name: 'Luke', movie: movies.first)
8 |
9 | User.delete_all
10 | Note.delete_all
11 |
--------------------------------------------------------------------------------
/lib/assets/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saitoxu/react-devise-token-auth-sample/68024040bae95024f2bba6f15d6f076dd45ce315/lib/assets/.keep
--------------------------------------------------------------------------------
/lib/tasks/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saitoxu/react-devise-token-auth-sample/68024040bae95024f2bba6f15d6f076dd45ce315/lib/tasks/.keep
--------------------------------------------------------------------------------
/log/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saitoxu/react-devise-token-auth-sample/68024040bae95024f2bba6f15d6f076dd45ce315/log/.keep
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-devise-sample",
3 | "private": true,
4 | "scripts": {
5 | "dev": "bin/webpack-dev-server"
6 | },
7 | "dependencies": {
8 | "autoprefixer": "^7.1.1",
9 | "axios": "^0.16.2",
10 | "babel-core": "^6.24.1",
11 | "babel-loader": "7.x",
12 | "babel-plugin-syntax-dynamic-import": "^6.18.0",
13 | "babel-plugin-transform-class-properties": "^6.24.1",
14 | "babel-polyfill": "^6.23.0",
15 | "babel-preset-env": "^1.5.1",
16 | "babel-preset-react": "^6.24.1",
17 | "babel-preset-stage-2": "^6.24.1",
18 | "coffee-loader": "^0.7.3",
19 | "coffee-script": "^1.12.6",
20 | "compression-webpack-plugin": "^0.4.0",
21 | "css-loader": "^0.28.4",
22 | "extract-text-webpack-plugin": "^2.1.0",
23 | "file-loader": "^0.11.1",
24 | "glob": "^7.1.2",
25 | "history": "^4.6.1",
26 | "js-yaml": "^3.8.4",
27 | "node-sass": "^4.5.3",
28 | "path-complete-extname": "^0.1.0",
29 | "postcss-loader": "^2.0.5",
30 | "postcss-smart-import": "^0.7.4",
31 | "precss": "^1.4.0",
32 | "prop-types": "^15.5.10",
33 | "rails-erb-loader": "^5.0.1",
34 | "react": "^15.5.4",
35 | "react-dom": "^15.5.4",
36 | "react-facebook-login": "^3.6.1",
37 | "react-redux": "^5.0.5",
38 | "react-router": "^4.1.1",
39 | "react-router-dom": "^4.1.1",
40 | "react-router-redux": "next",
41 | "react-toolbox": "^2.0.0-beta.12",
42 | "redux": "^3.6.0",
43 | "redux-localstorage": "^0.4.1",
44 | "redux-logger": "^3.0.6",
45 | "redux-thunk": "^2.2.0",
46 | "resolve-url-loader": "^2.0.2",
47 | "sass-loader": "^6.0.5",
48 | "style-loader": "^0.18.1",
49 | "webpack": "^2.6.1",
50 | "webpack-manifest-plugin": "^1.1.0",
51 | "webpack-merge": "^4.1.0"
52 | },
53 | "devDependencies": {
54 | "webpack-dev-server": "^2.4.5"
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The page you were looking for doesn't exist.
62 |
You may have mistyped the address or the page may have moved.
63 |
64 |
If you are the application owner check the logs for more information.