Remove grape.
This commit is contained in:
parent
c20d01c4e8
commit
6f74eb9bdd
82 changed files with 0 additions and 1884 deletions
11
Gemfile
11
Gemfile
|
@ -65,20 +65,9 @@ gem 'devise', '~> 4.4'
|
|||
gem 'config', '> 1.5'
|
||||
gem 'dry-validation', '~> 0.13.3' # used only for config validation
|
||||
gem 'foreman', '~> 0.85.0'
|
||||
gem 'grape_devise', path: 'gems/grape_devise'
|
||||
gem 'grape_logging', '~> 1.8', '>= 1.8.1'
|
||||
gem 'grape_url_validator', '~> 1.0'
|
||||
gem 'grape-entity', '~> 0.7.1'
|
||||
gem 'grape-swagger-entity', '~> 0.3.3'
|
||||
gem 'grape-swagger', '~> 0.33.0'
|
||||
gem 'grape', '~> 1.2', '>= 1.2.4'
|
||||
gem 'wisper', '~> 2.0'
|
||||
gem 'wisper-activejob', '~> 1.0.0'
|
||||
|
||||
group :development do
|
||||
gem 'grape_on_rails_routes', '~> 0.3.2'
|
||||
end
|
||||
|
||||
group :development, :ci do
|
||||
gem 'debase', '~> 0.2.3'
|
||||
gem 'ruby-debug-ide', '~> 0.7.0'
|
||||
|
|
58
Gemfile.lock
58
Gemfile.lock
|
@ -8,14 +8,6 @@ GIT
|
|||
multi_json (~> 1.0)
|
||||
stripe (>= 1.31.0, <= 1.58.0)
|
||||
|
||||
PATH
|
||||
remote: gems/grape_devise
|
||||
specs:
|
||||
grape_devise (0.1.1)
|
||||
devise (>= 2.2.8, < 5)
|
||||
grape (> 0.7)
|
||||
rails (> 3.2, < 6)
|
||||
|
||||
PATH
|
||||
remote: gems/ruby-param-validation
|
||||
specs:
|
||||
|
@ -106,10 +98,6 @@ GEM
|
|||
xml-simple
|
||||
aws-sigv4 (1.1.0)
|
||||
aws-eventstream (~> 1.0, >= 1.0.2)
|
||||
axiom-types (0.1.1)
|
||||
descendants_tracker (~> 0.0.4)
|
||||
ice_nine (~> 0.11.0)
|
||||
thread_safe (~> 0.3, >= 0.3.1)
|
||||
backport (1.1.2)
|
||||
bcrypt (3.1.13)
|
||||
binding_of_caller (0.8.0)
|
||||
|
@ -129,8 +117,6 @@ GEM
|
|||
carrierwave (>= 0.7, < 2.0)
|
||||
chronic (0.10.2)
|
||||
coderay (1.1.2)
|
||||
coercible (1.0.0)
|
||||
descendants_tracker (~> 0.0.1)
|
||||
colorize (0.8.1)
|
||||
concurrent-ruby (1.1.5)
|
||||
config (1.7.2)
|
||||
|
@ -153,8 +139,6 @@ GEM
|
|||
debase-ruby_core_source (0.10.5)
|
||||
debug_inspector (0.0.3)
|
||||
deep_merge (1.2.1)
|
||||
descendants_tracker (0.0.4)
|
||||
thread_safe (~> 0.3, >= 0.3.1)
|
||||
devise (4.6.2)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
|
@ -200,7 +184,6 @@ GEM
|
|||
dry-equalizer (~> 0.2)
|
||||
dry-logic (~> 0.5, >= 0.5.0)
|
||||
dry-types (~> 0.14.0)
|
||||
equalizer (0.0.11)
|
||||
erubi (1.8.0)
|
||||
execjs (2.7.0)
|
||||
factory_bot (5.0.2)
|
||||
|
@ -226,28 +209,6 @@ GEM
|
|||
ffi (~> 1.0)
|
||||
globalid (0.4.2)
|
||||
activesupport (>= 4.2.0)
|
||||
grape (1.2.4)
|
||||
activesupport
|
||||
builder
|
||||
mustermann-grape (~> 1.0.0)
|
||||
rack (>= 1.3.0)
|
||||
rack-accept
|
||||
virtus (>= 1.0.0)
|
||||
grape-entity (0.7.1)
|
||||
activesupport (>= 4.0)
|
||||
multi_json (>= 1.3.2)
|
||||
grape-swagger (0.33.0)
|
||||
grape (>= 0.16.2)
|
||||
grape-swagger-entity (0.3.3)
|
||||
grape-entity (>= 0.5.0)
|
||||
grape-swagger (>= 0.31.0)
|
||||
grape_logging (1.8.1)
|
||||
grape
|
||||
rack
|
||||
grape_on_rails_routes (0.3.2)
|
||||
rails (>= 3.1.1)
|
||||
grape_url_validator (1.0.0)
|
||||
grape (>= 0.12.0)
|
||||
hamster (3.0.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
hashdiff (1.0.0)
|
||||
|
@ -265,7 +226,6 @@ GEM
|
|||
i18n-js (3.3.0)
|
||||
i18n (>= 0.6.6)
|
||||
i18n_data (0.8.0)
|
||||
ice_nine (0.11.2)
|
||||
jaro_winkler (1.5.3)
|
||||
jbuilder (2.10.0)
|
||||
activesupport (>= 5.0.0)
|
||||
|
@ -300,9 +260,6 @@ GEM
|
|||
multi_json (1.13.1)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.1.1)
|
||||
mustermann (1.0.3)
|
||||
mustermann-grape (1.0.0)
|
||||
mustermann (~> 1.0.0)
|
||||
nearest_time_zone (0.0.4)
|
||||
andand
|
||||
kdtree
|
||||
|
@ -334,8 +291,6 @@ GEM
|
|||
rabl (0.14.1)
|
||||
activesupport (>= 2.3.14)
|
||||
rack (2.0.9)
|
||||
rack-accept (0.4.5)
|
||||
rack (>= 0.4)
|
||||
rack-attack (5.4.2)
|
||||
rack (>= 1.0, < 3)
|
||||
rack-ssl (1.4.1)
|
||||
|
@ -482,11 +437,6 @@ GEM
|
|||
unf_ext (0.0.7.6)
|
||||
unicode-display_width (1.6.0)
|
||||
unicode_utils (1.4.0)
|
||||
virtus (1.0.5)
|
||||
axiom-types (~> 0.1)
|
||||
coercible (~> 1.0)
|
||||
descendants_tracker (~> 0.0, >= 0.0.3)
|
||||
equalizer (~> 0.0, >= 0.0.9)
|
||||
warden (1.2.8)
|
||||
rack (>= 2.0.6)
|
||||
webmock (3.6.2)
|
||||
|
@ -534,14 +484,6 @@ DEPENDENCIES
|
|||
foreman (~> 0.85.0)
|
||||
fullcontact (~> 0.18.0)
|
||||
geocoder (~> 1.5)
|
||||
grape (~> 1.2, >= 1.2.4)
|
||||
grape-entity (~> 0.7.1)
|
||||
grape-swagger (~> 0.33.0)
|
||||
grape-swagger-entity (~> 0.3.3)
|
||||
grape_devise!
|
||||
grape_logging (~> 1.8, >= 1.8.1)
|
||||
grape_on_rails_routes (~> 0.3.2)
|
||||
grape_url_validator (~> 1.0)
|
||||
hamster (~> 3.0)
|
||||
heroku-deflater (~> 0.6.3)
|
||||
httparty (~> 0.17.0)
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
class Houdini::API < Grape::API
|
||||
format :json
|
||||
mount Houdini::V1::API => '/v1'
|
||||
end
|
|
@ -1,24 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
require 'houdini/v1/validations'
|
||||
class Houdini::V1::API < Grape::API
|
||||
logger.formatter = GrapeLogging::Formatters::Rails.new
|
||||
use GrapeLogging::Middleware::RequestLogger, logger: logger
|
||||
content_type :json, 'application/json'
|
||||
default_format :json
|
||||
rescue_from Grape::Exceptions::ValidationErrors do |e|
|
||||
output = { errors: e }
|
||||
error! output, 400
|
||||
end
|
||||
|
||||
# include Houdini::V1::Helpers::ApplicationHelper
|
||||
mount Houdini::V1::Nonprofit => '/nonprofit'
|
||||
# Additional mounts are added via generators above this line
|
||||
# DON'T REMOVE THIS OR THE PREVIOUS LINES!!!
|
||||
uri_for_host = URI.parse(Settings.api_domain&.url || Settings.cdn.url)
|
||||
add_swagger_documentation \
|
||||
host: "#{uri_for_host.host}#{uri_for_host.port ? ":#{uri_for_host.port}" : ''}",
|
||||
schemes: [uri_for_host.scheme],
|
||||
base_path: '/api/v1'
|
||||
end
|
|
@ -1,5 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
class Houdini::V1::BaseAPI < Grape::API
|
||||
end
|
|
@ -1,6 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
class Houdini::V1::Entities::Nonprofit < Grape::Entity
|
||||
expose :id
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
class Houdini::V1::Entities::ValidationError < Grape::Entity
|
||||
expose :params, documentation: { type: 'String', desc: 'Params where the following had an error.', is_array: true }
|
||||
expose :messages, documentation: { type: 'String', desc: 'The validation messages for the params', is_array: true }
|
||||
end
|
|
@ -1,6 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
class Houdini::V1::Entities::ValidationErrors < Grape::Entity
|
||||
expose :errors, documentation: { type: ValidationError, desc: 'errors', is_array: true }
|
||||
end
|
|
@ -1,6 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
module Houdini::V1::Helpers::ApplicationHelper
|
||||
extend Grape::API::Helpers
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Houdini::V1::Helpers::RescueHelper
|
||||
require 'active_support/concern'
|
||||
|
||||
extend ActiveSupport::Concern
|
||||
include Grape::DSL::Configuration
|
||||
module ClassMethods
|
||||
def rescue_ar_invalid(*class_to_hash)
|
||||
rescue_with ActiveRecord::RecordInvalid do |error|
|
||||
output = []
|
||||
error.record.errors do |attr, message|
|
||||
output.push(params: "#{class_to_hash[error.record.class]}['#{attr}']",
|
||||
message: message)
|
||||
end
|
||||
raise Grape::Exceptions::ValidationErrors, output
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,107 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
class Houdini::V1::Nonprofit < Houdini::V1::BaseAPI
|
||||
helpers Houdini::V1::Helpers::ApplicationHelper, Houdini::V1::Helpers::RescueHelper
|
||||
|
||||
desc 'Return a nonprofit.' do
|
||||
success Houdini::V1::Entities::Nonprofit
|
||||
end
|
||||
params do
|
||||
requires :id, type: Integer, desc: 'Status id.'
|
||||
end
|
||||
route_param :id do
|
||||
get do
|
||||
np = ::Nonprofit.find(params[:id])
|
||||
present np, as: Houdini::V1::Entities::Nonprofit
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Register a nonprofit' do
|
||||
success Houdini::V1::Entities::Nonprofit
|
||||
|
||||
# this needs to be a validation an array
|
||||
failure [{ code: 400, message: 'Validation Errors', model: Houdini::V1::Entities::ValidationErrors }]
|
||||
end
|
||||
|
||||
params do
|
||||
requires :nonprofit, type: Hash do
|
||||
requires :name, type: String, desc: 'Organization Name', allow_blank: false, documentation: { param_type: 'body' }
|
||||
optional :website, type: String, desc: 'Organization website URL', allow_blank: true, regexp: URI::DEFAULT_PARSER.make_regexp, documentation: { param_type: 'body' }, coerce_with: lambda { |url|
|
||||
coerced_url = url
|
||||
unless url =~ %r{\Ahttp://.*}i || url =~ %r{\Ahttps://.*}i
|
||||
coerced_url = 'http://' + coerced_url
|
||||
end
|
||||
coerced_url
|
||||
}
|
||||
requires :zip_code, type: String, allow_blank: false, desc: 'Organization Address ZIP Code', documentation: { param_type: 'body' }
|
||||
requires :state_code, type: String, allow_blank: false, desc: 'Organization Address State Code', documentation: { param_type: 'body' }
|
||||
requires :city, type: String, allow_blank: false, desc: 'Organization Address City', documentation: { param_type: 'body' }
|
||||
optional :email, type: String, desc: 'Organization email (public)', regexp: Email::Regex, documentation: { param_type: 'body' }
|
||||
optional :phone, type: String, desc: 'Organization phone (public)', documentation: { param_type: 'body' }
|
||||
end
|
||||
|
||||
requires :user, type: Hash do
|
||||
requires :name, type: String, desc: 'Full name', allow_blank: false, documentation: { param_type: 'body' }
|
||||
requires :email, type: String, desc: 'Username', allow_blank: false, documentation: { param_type: 'body' }
|
||||
requires :password, type: String, desc: 'Password', allow_blank: false, is_equal_to: :password_confirmation, documentation: { param_type: 'body' }
|
||||
requires :password_confirmation, type: String, desc: 'Password confirmation', allow_blank: false, documentation: { param_type: 'body' }
|
||||
end
|
||||
end
|
||||
post do
|
||||
declared_params = declared(params)
|
||||
np = nil
|
||||
u = nil
|
||||
Qx.transaction do
|
||||
np = ::Nonprofit.new(OnboardAccounts.set_nonprofit_defaults(declared_params[:nonprofit]))
|
||||
|
||||
begin
|
||||
np.save!
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
if e.record.errors[:slug]
|
||||
begin
|
||||
slug = SlugNonprofitNamingAlgorithm.new(np.state_code_slug, np.city_slug).create_copy_name(np.slug)
|
||||
np.slug = slug
|
||||
np.save!
|
||||
rescue UnableToCreateNameCopyError
|
||||
raise Grape::Exceptions::ValidationErrors.new(errors: [Grape::Exceptions::Validation.new(
|
||||
params: ['nonprofit[name]'],
|
||||
message: 'has an invalid slug. Contact support for help.'
|
||||
)])
|
||||
end
|
||||
else
|
||||
raise e
|
||||
end
|
||||
end
|
||||
|
||||
u = User.new(declared_params[:user])
|
||||
u.save!
|
||||
|
||||
role = u.roles.build(host: np, name: 'nonprofit_admin')
|
||||
role.save!
|
||||
|
||||
billing_plan = BillingPlan.find(Settings.default_bp.id)
|
||||
b_sub = np.build_billing_subscription(billing_plan: billing_plan, status: 'active')
|
||||
b_sub.save!
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
class_to_name = { Nonprofit => 'nonprofit', User => 'user' }
|
||||
if class_to_name[e.record.class]
|
||||
errors = e.record.errors.keys.map do |k|
|
||||
errors = e.record.errors[k].uniq
|
||||
errors.map do |error|
|
||||
Grape::Exceptions::Validation.new(
|
||||
params: ["#{class_to_name[e.record.class]}[#{k}]"],
|
||||
message: error
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
raise Grape::Exceptions::ValidationErrors.new(errors: errors.flatten)
|
||||
else
|
||||
raise e
|
||||
end
|
||||
end
|
||||
# onboard callback
|
||||
present np, with: Houdini::V1::Entities::Nonprofit
|
||||
end
|
||||
end
|
|
@ -1,4 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
require 'houdini/v1/validators/is_equal_to'
|
|
@ -1,10 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
class Houdini::V1::Validators::IsEqualTo < Grape::Validations::Base
|
||||
def validate_param!(attr_name, params)
|
||||
if params[attr_name] != params[@option]
|
||||
raise Grape::Exceptions::Validation, params: [@scope.full_name(attr_name), @scope.full_name(@option)], message: message(:is_equal_to)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
# License: CC0-1.0
|
||||
# grape validation errors require a very specific format for their translation messages. Why? *shrug*
|
||||
en:
|
||||
grape:
|
||||
errors:
|
||||
messages:
|
||||
is_equal_to: "must be the same"
|
10
gems/grape_devise/.gitignore
vendored
10
gems/grape_devise/.gitignore
vendored
|
@ -1,10 +0,0 @@
|
|||
.bundle/
|
||||
log/*.log
|
||||
pkg/
|
||||
spec/dummy/db/*.sqlite3
|
||||
spec/dummy/db/*.sqlite3-journal
|
||||
spec/dummy/log/*.log
|
||||
spec/dummy/tmp/
|
||||
spec/dummy/.sass-cache
|
||||
.idea
|
||||
*.iml
|
|
@ -1,4 +0,0 @@
|
|||
language: ruby
|
||||
rvm:
|
||||
- 2.1.0
|
||||
sudo: false
|
|
@ -1,16 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
source 'https://rubygems.org'
|
||||
|
||||
# Declare your gem's dependencies in grape_devise.gemspec.
|
||||
# Bundler will treat runtime dependencies like base dependencies, and
|
||||
# development dependencies will be added by default to the :development group.
|
||||
gemspec
|
||||
|
||||
# Declare any dependencies that are still in development here instead of in
|
||||
# your gemspec. These might include edge Rails or gems from your path or
|
||||
# Git. Remember to move these dependencies to your gemspec before releasing
|
||||
# your gem to rubygems.org.
|
||||
|
||||
# To use debugger
|
||||
# gem 'debugger'
|
|
@ -1,176 +0,0 @@
|
|||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
grape_devise (0.1.1)
|
||||
devise (>= 2.2.8, < 4)
|
||||
grape (~> 0.7)
|
||||
rails (> 3.2, < 5)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actionmailer (4.1.6)
|
||||
actionpack (= 4.1.6)
|
||||
actionview (= 4.1.6)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
actionpack (4.1.6)
|
||||
actionview (= 4.1.6)
|
||||
activesupport (= 4.1.6)
|
||||
rack (~> 1.5.2)
|
||||
rack-test (~> 0.6.2)
|
||||
actionview (4.1.6)
|
||||
activesupport (= 4.1.6)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
activemodel (4.1.6)
|
||||
activesupport (= 4.1.6)
|
||||
builder (~> 3.1)
|
||||
activerecord (4.1.6)
|
||||
activemodel (= 4.1.6)
|
||||
activesupport (= 4.1.6)
|
||||
arel (~> 5.0.0)
|
||||
activerecord-nulldb-adapter (0.3.1)
|
||||
activerecord (>= 2.0.0)
|
||||
activesupport (4.1.6)
|
||||
i18n (~> 0.6, >= 0.6.9)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.1)
|
||||
tzinfo (~> 1.1)
|
||||
arel (5.0.1.20140414130214)
|
||||
axiom-types (0.1.1)
|
||||
descendants_tracker (~> 0.0.4)
|
||||
ice_nine (~> 0.11.0)
|
||||
thread_safe (~> 0.3, >= 0.3.1)
|
||||
bcrypt (3.1.11)
|
||||
builder (3.2.2)
|
||||
capybara (2.4.1)
|
||||
mime-types (>= 1.16)
|
||||
nokogiri (>= 1.3.3)
|
||||
rack (>= 1.0.0)
|
||||
rack-test (>= 0.5.4)
|
||||
xpath (~> 2.0)
|
||||
coercible (1.0.0)
|
||||
descendants_tracker (~> 0.0.1)
|
||||
concurrent-ruby (1.0.5)
|
||||
descendants_tracker (0.0.4)
|
||||
thread_safe (~> 0.3, >= 0.3.1)
|
||||
devise (3.5.10)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 3.2.6, < 5)
|
||||
responders
|
||||
thread_safe (~> 0.1)
|
||||
warden (~> 1.2.3)
|
||||
diff-lcs (1.2.5)
|
||||
equalizer (0.0.11)
|
||||
erubis (2.7.0)
|
||||
factory_girl (4.4.0)
|
||||
activesupport (>= 3.0.0)
|
||||
grape (0.19.1)
|
||||
activesupport
|
||||
builder
|
||||
hashie (>= 2.1.0)
|
||||
multi_json (>= 1.3.2)
|
||||
multi_xml (>= 0.5.2)
|
||||
mustermann-grape (~> 0.4.0)
|
||||
rack (>= 1.3.0)
|
||||
rack-accept
|
||||
virtus (>= 1.0.0)
|
||||
hashie (3.5.5)
|
||||
i18n (0.6.11)
|
||||
ice_nine (0.11.2)
|
||||
json (1.8.1)
|
||||
mail (2.6.4)
|
||||
mime-types (>= 1.16, < 4)
|
||||
mime-types (2.3)
|
||||
mini_portile (0.6.0)
|
||||
minitest (5.4.1)
|
||||
multi_json (1.12.1)
|
||||
multi_xml (0.6.0)
|
||||
mustermann (0.4.0)
|
||||
tool (~> 0.2)
|
||||
mustermann-grape (0.4.0)
|
||||
mustermann (= 0.4.0)
|
||||
nokogiri (1.6.3.1)
|
||||
mini_portile (= 0.6.0)
|
||||
orm_adapter (0.5.0)
|
||||
rack (1.5.2)
|
||||
rack-accept (0.4.5)
|
||||
rack (>= 0.4)
|
||||
rack-test (0.6.2)
|
||||
rack (>= 1.0)
|
||||
rails (4.1.6)
|
||||
actionmailer (= 4.1.6)
|
||||
actionpack (= 4.1.6)
|
||||
actionview (= 4.1.6)
|
||||
activemodel (= 4.1.6)
|
||||
activerecord (= 4.1.6)
|
||||
activesupport (= 4.1.6)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.1.6)
|
||||
sprockets-rails (~> 2.0)
|
||||
railties (4.1.6)
|
||||
actionpack (= 4.1.6)
|
||||
activesupport (= 4.1.6)
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (10.3.2)
|
||||
responders (1.1.2)
|
||||
railties (>= 3.2, < 4.2)
|
||||
rspec (2.99.0)
|
||||
rspec-core (~> 2.99.0)
|
||||
rspec-expectations (~> 2.99.0)
|
||||
rspec-mocks (~> 2.99.0)
|
||||
rspec-collection_matchers (1.0.0)
|
||||
rspec-expectations (>= 2.99.0.beta1)
|
||||
rspec-core (2.99.2)
|
||||
rspec-expectations (2.99.2)
|
||||
diff-lcs (>= 1.1.3, < 2.0)
|
||||
rspec-mocks (2.99.2)
|
||||
rspec-rails (2.99.0)
|
||||
actionpack (>= 3.0)
|
||||
activemodel (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
rspec-collection_matchers
|
||||
rspec-core (~> 2.99.0)
|
||||
rspec-expectations (~> 2.99.0)
|
||||
rspec-mocks (~> 2.99.0)
|
||||
sprockets (3.7.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (2.3.3)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
sqlite3 (1.3.9)
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.4)
|
||||
tool (0.2.3)
|
||||
tzinfo (1.2.2)
|
||||
thread_safe (~> 0.1)
|
||||
virtus (1.0.5)
|
||||
axiom-types (~> 0.1)
|
||||
coercible (~> 1.0)
|
||||
descendants_tracker (~> 0.0, >= 0.0.3)
|
||||
equalizer (~> 0.0, >= 0.0.9)
|
||||
warden (1.2.7)
|
||||
rack (>= 1.0)
|
||||
xpath (2.0.0)
|
||||
nokogiri (~> 1.3)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
activerecord-nulldb-adapter (~> 0.3.1)
|
||||
capybara (~> 2.4.1)
|
||||
factory_girl (~> 4.4.0)
|
||||
grape_devise!
|
||||
rspec (~> 2.99.0)
|
||||
rspec-rails (~> 2.99.0)
|
||||
sqlite3
|
||||
|
||||
BUNDLED WITH
|
||||
1.14.5
|
|
@ -1,21 +0,0 @@
|
|||
Copyright 2014 justinm
|
||||
Copyright 2018 CommitChange
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,39 +0,0 @@
|
|||
# Grape::Devise
|
||||
|
||||
Grape::Devise adds support for devise helpers from inside Grape::APIs.
|
||||
|
||||
NOTE: this project was originally at https://github.com/justinm/grape_devise
|
||||
but is not longer supported so we moved it into our repo.
|
||||
|
||||
## Installing
|
||||
|
||||
Installing is simple. Just add the grape_devise gem to your Gemfile, run
|
||||
```bundle install``` and it's ready to go.
|
||||
|
||||
```
|
||||
gem 'grape_devise'
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
The devise API can now be accessed from inside of Grape request blocks.
|
||||
|
||||
```
|
||||
class MyAPI < Grape::API
|
||||
get "/requires-authentication" do
|
||||
authenticate_user!
|
||||
end
|
||||
|
||||
get "/who-am-i" do
|
||||
current_user
|
||||
end
|
||||
end
|
||||
|
||||
```
|
||||
|
||||
## FAQ
|
||||
|
||||
####Can I use this with rails
|
||||
Yes you can! Grape::Devise works with your existing rails sessions to provide
|
||||
seamless authentication between your rails app and grape APIs.
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
begin
|
||||
require 'bundler/setup'
|
||||
rescue LoadError
|
||||
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
||||
end
|
||||
|
||||
require 'rdoc/task'
|
||||
|
||||
RDoc::Task.new(:rdoc) do |rdoc|
|
||||
rdoc.rdoc_dir = 'rdoc'
|
||||
rdoc.title = 'GrapeDevise'
|
||||
rdoc.options << '--line-numbers'
|
||||
rdoc.rdoc_files.include('README.rdoc')
|
||||
rdoc.rdoc_files.include('lib/**/*.rb')
|
||||
end
|
||||
|
||||
require 'rspec/core/rake_task'
|
||||
|
||||
RSpec::Core::RakeTask.new(:spec)
|
||||
|
||||
Bundler::GemHelper.install_tasks
|
||||
|
||||
task default: :spec
|
|
@ -1,34 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
||||
|
||||
# Maintain your gem's version:
|
||||
require 'grape_devise/version'
|
||||
|
||||
# Describe your gem and declare its dependencies:
|
||||
Gem::Specification.new do |s|
|
||||
s.name = 'grape_devise'
|
||||
s.version = GrapeDevise::VERSION
|
||||
s.authors = ['Justin McCormick']
|
||||
s.email = ['me@justinmccormick.com']
|
||||
s.homepage = 'http://github.com/justinm/grape_devise'
|
||||
s.summary = 'Adds support for devise in grape applications'
|
||||
s.description = 'This gem provides access to devise helpers inside of '
|
||||
'Grape applications.'
|
||||
|
||||
s.licenses = ['MIT']
|
||||
|
||||
s.files = Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE ', 'Rakefile', 'README.rdoc']
|
||||
s.test_files = Dir['test/**/*']
|
||||
|
||||
s.add_development_dependency 'activerecord-nulldb-adapter', '~> 0.3.1'
|
||||
s.add_development_dependency 'capybara', '~> 2.4.1'
|
||||
s.add_development_dependency 'factory_girl', '~> 4.4.0'
|
||||
s.add_development_dependency 'rspec', '~> 2.99.0'
|
||||
s.add_development_dependency 'rspec-rails', '~> 2.99.0'
|
||||
s.add_development_dependency 'sqlite3'
|
||||
|
||||
s.add_dependency 'devise', '>= 2.2.8', '< 5'
|
||||
s.add_dependency 'grape', '> 0.7'
|
||||
s.add_dependency 'rails', '> 3.2', '< 6'
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module GrapeDevise
|
||||
end
|
||||
|
||||
require 'devise'
|
||||
require 'grape'
|
||||
require 'grape_devise/api'
|
||||
|
||||
Devise.helpers << GrapeDevise::API
|
||||
Grape::Endpoint.send :include, GrapeDevise::API
|
|
@ -1,38 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'devise'
|
||||
|
||||
module GrapeDevise::API
|
||||
extend ActiveSupport::Concern
|
||||
include Devise::Controllers::SignInOut
|
||||
|
||||
def self.define_helpers(mapping)
|
||||
mapping = mapping.name.to_s
|
||||
|
||||
class_eval <<-METHODS, __FILE__, __LINE__ + 1
|
||||
def warden
|
||||
env["warden"]
|
||||
end
|
||||
|
||||
def authenticate_#{mapping}!(opts={})
|
||||
opts[:scope] = :#{mapping}
|
||||
env["devise.allow_params_authentication"] = true
|
||||
if opts.delete(:force) || current_#{mapping}.nil?
|
||||
error!("401 Forbidden", 401) unless warden.authenticate(opts)
|
||||
end
|
||||
end
|
||||
|
||||
def #{mapping}_signed_in?
|
||||
!!current_#{mapping}
|
||||
end
|
||||
|
||||
def current_#{mapping}
|
||||
@current_#{mapping} ||= warden.authenticate(scope: :#{mapping})
|
||||
end
|
||||
|
||||
def #{mapping}_session
|
||||
current_#{mapping} && warden.session(:#{mapping})
|
||||
end
|
||||
METHODS
|
||||
end
|
||||
end
|
|
@ -1,5 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module GrapeDevise
|
||||
VERSION = '0.1.1'
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
== README
|
||||
|
||||
This README would normally document whatever steps are necessary to get the
|
||||
application up and running.
|
||||
|
||||
Things you may want to cover:
|
||||
|
||||
* Ruby version
|
||||
|
||||
* System dependencies
|
||||
|
||||
* Configuration
|
||||
|
||||
* Database creation
|
||||
|
||||
* Database initialization
|
||||
|
||||
* How to run the test suite
|
||||
|
||||
* Services (job queues, cache servers, search engines, etc.)
|
||||
|
||||
* Deployment instructions
|
||||
|
||||
* ...
|
||||
|
||||
|
||||
Please feel free to use a different markup language if you do not plan to run
|
||||
<tt>rake doc:app</tt>.
|
|
@ -1,11 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
||||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
||||
|
||||
require File.expand_path('config/application', __dir__)
|
||||
|
||||
require 'rspec/core/rake_task'
|
||||
RSpec::Core::RakeTask.new(:spec)
|
||||
|
||||
Dummy::Application.load_tasks
|
|
@ -1,20 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'grape_devise'
|
||||
|
||||
class API < Grape::API
|
||||
format :json
|
||||
|
||||
get 'me' do
|
||||
authenticate_user!
|
||||
current_user
|
||||
end
|
||||
|
||||
get 'authorized' do
|
||||
user_signed_in?
|
||||
end
|
||||
|
||||
post 'signin' do
|
||||
authenticate_user!
|
||||
end
|
||||
end
|
|
@ -1,13 +0,0 @@
|
|||
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
||||
// listed below.
|
||||
//
|
||||
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
||||
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
||||
//
|
||||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||
// compiled file.
|
||||
//
|
||||
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
||||
// about supported directives.
|
||||
//
|
||||
//= require_tree .
|
|
@ -1,13 +0,0 @@
|
|||
/*
|
||||
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
||||
* listed below.
|
||||
*
|
||||
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
||||
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
||||
*
|
||||
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
||||
* compiled file, but it's generally better to create a new file per style scope.
|
||||
*
|
||||
*= require_self
|
||||
*= require_tree .
|
||||
*/
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ApplicationController < ActionController::Base
|
||||
# Prevent CSRF attacks by raising an exception.
|
||||
# For APIs, you may want to use :null_session instead.
|
||||
protect_from_forgery with: :exception
|
||||
end
|
|
@ -1,4 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module ApplicationHelper
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class User < ActiveRecord::Base
|
||||
# Include default devise modules. Others available are:
|
||||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||
devise :database_authenticatable
|
||||
end
|
|
@ -1,14 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Dummy</title>
|
||||
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
|
||||
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
|
||||
<%= csrf_meta_tags %>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<%= yield %>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,5 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
||||
load Gem.bin_path('bundler', 'bundle')
|
|
@ -1,6 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
APP_PATH = File.expand_path('../config/application', __dir__)
|
||||
require_relative '../config/boot'
|
||||
require 'rails/commands'
|
|
@ -1,6 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative '../config/boot'
|
||||
require 'rake'
|
||||
Rake.application.run
|
|
@ -1,6 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# This file is used by Rack-based servers to start the application.
|
||||
|
||||
require ::File.expand_path('../config/environment', __FILE__)
|
||||
run Rails.application
|
|
@ -1,15 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require File.expand_path('boot', __dir__)
|
||||
|
||||
require 'rails/all'
|
||||
# require '../..app/models/user'
|
||||
|
||||
Bundler.require(*Rails.groups)
|
||||
|
||||
module Dummy
|
||||
class Application < Rails::Application
|
||||
config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
|
||||
config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
|
||||
end
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Set up gems listed in the Gemfile.
|
||||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
|
||||
|
||||
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
||||
$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
|
|
@ -1,25 +0,0 @@
|
|||
# SQLite version 3.x
|
||||
# gem install sqlite3
|
||||
#
|
||||
# Ensure the SQLite 3 gem is defined in your Gemfile
|
||||
# gem 'sqlite3'
|
||||
development:
|
||||
adapter: sqlite3
|
||||
database: db/development.sqlite3
|
||||
pool: 5
|
||||
timeout: 5000
|
||||
|
||||
# Warning: The database defined as "test" will be erased and
|
||||
# re-generated from your development database when you run "rake".
|
||||
# Do not set this db to the same as development or production.
|
||||
test:
|
||||
adapter: nulldb
|
||||
database: db/test.sqlite3
|
||||
pool: 5
|
||||
timeout: 5000
|
||||
|
||||
production:
|
||||
adapter: sqlite3
|
||||
database: db/production.sqlite3
|
||||
pool: 5
|
||||
timeout: 5000
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Load the Rails application.
|
||||
require File.expand_path('application', __dir__)
|
||||
|
||||
# Initialize the Rails application.
|
||||
Dummy::Application.initialize!
|
|
@ -1,31 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Dummy::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# In the development environment your application's code is reloaded on
|
||||
# every request. This slows down response time but is perfect for development
|
||||
# since you don't have to restart the web server when you make code changes.
|
||||
config.cache_classes = false
|
||||
|
||||
# Do not eager load code on boot.
|
||||
config.eager_load = false
|
||||
|
||||
# Show full error reports and disable caching.
|
||||
config.consider_all_requests_local = true
|
||||
config.action_controller.perform_caching = false
|
||||
|
||||
# Don't care if the mailer can't send.
|
||||
config.action_mailer.raise_delivery_errors = false
|
||||
|
||||
# Print deprecation notices to the Rails logger.
|
||||
config.active_support.deprecation = :log
|
||||
|
||||
# Raise an error on page load if there are pending migrations
|
||||
config.active_record.migration_error = :page_load
|
||||
|
||||
# Debug mode disables concatenation and preprocessing of assets.
|
||||
# This option may cause significant delays in view rendering with a large
|
||||
# number of complex assets.
|
||||
config.assets.debug = true
|
||||
end
|
|
@ -1,82 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Dummy::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# Code is not reloaded between requests.
|
||||
config.cache_classes = true
|
||||
|
||||
# Eager load code on boot. This eager loads most of Rails and
|
||||
# your application in memory, allowing both thread web servers
|
||||
# and those relying on copy on write to perform better.
|
||||
# Rake tasks automatically ignore this option for performance.
|
||||
config.eager_load = true
|
||||
|
||||
# Full error reports are disabled and caching is turned on.
|
||||
config.consider_all_requests_local = false
|
||||
config.action_controller.perform_caching = true
|
||||
|
||||
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
||||
# Add `rack-cache` to your Gemfile before enabling this.
|
||||
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
|
||||
# config.action_dispatch.rack_cache = true
|
||||
|
||||
# Disable Rails's static asset server (Apache or nginx will already do this).
|
||||
config.serve_static_assets = false
|
||||
|
||||
# Compress JavaScripts and CSS.
|
||||
config.assets.js_compressor = :uglifier
|
||||
# config.assets.css_compressor = :sass
|
||||
|
||||
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
||||
config.assets.compile = false
|
||||
|
||||
# Generate digests for assets URLs.
|
||||
config.assets.digest = true
|
||||
|
||||
# Version of your assets, change this if you want to expire all your assets.
|
||||
config.assets.version = '1.0'
|
||||
|
||||
# Specifies the header that your server uses for sending files.
|
||||
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
||||
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
||||
|
||||
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
||||
# config.force_ssl = true
|
||||
|
||||
# Set to :debug to see everything in the log.
|
||||
config.log_level = :info
|
||||
|
||||
# Prepend all log lines with the following tags.
|
||||
# config.log_tags = [ :subdomain, :uuid ]
|
||||
|
||||
# Use a different logger for distributed setups.
|
||||
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
||||
|
||||
# Use a different cache store in production.
|
||||
# config.cache_store = :mem_cache_store
|
||||
|
||||
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
||||
# config.action_controller.asset_host = "http://assets.example.com"
|
||||
|
||||
# Precompile additional assets.
|
||||
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
||||
# config.assets.precompile += %w( search.js )
|
||||
|
||||
# Ignore bad email addresses and do not raise email delivery errors.
|
||||
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
||||
# config.action_mailer.raise_delivery_errors = false
|
||||
|
||||
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
||||
# the I18n.default_locale when a translation can not be found).
|
||||
config.i18n.fallbacks = true
|
||||
|
||||
# Send deprecation notices to registered listeners.
|
||||
config.active_support.deprecation = :notify
|
||||
|
||||
# Disable automatic flushing of the log to improve performance.
|
||||
# config.autoflush_log = false
|
||||
|
||||
# Use default logging formatter so that PID and timestamp are not suppressed.
|
||||
config.log_formatter = ::Logger::Formatter.new
|
||||
end
|
|
@ -1,38 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Dummy::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# The test environment is used exclusively to run your application's
|
||||
# test suite. You never need to work with it otherwise. Remember that
|
||||
# your test database is "scratch space" for the test suite and is wiped
|
||||
# and recreated between test runs. Don't rely on the data there!
|
||||
config.cache_classes = true
|
||||
|
||||
# Do not eager load code on boot. This avoids loading your whole application
|
||||
# just for the purpose of running a single test. If you are using a tool that
|
||||
# preloads Rails for running tests, you may have to set it to true.
|
||||
config.eager_load = false
|
||||
|
||||
# Configure static asset server for tests with Cache-Control for performance.
|
||||
config.serve_static_assets = true
|
||||
config.static_cache_control = 'public, max-age=3600'
|
||||
|
||||
# Show full error reports and disable caching.
|
||||
config.consider_all_requests_local = true
|
||||
config.action_controller.perform_caching = false
|
||||
|
||||
# Raise exceptions instead of rendering exception templates.
|
||||
config.action_dispatch.show_exceptions = false
|
||||
|
||||
# Disable request forgery protection in test environment.
|
||||
config.action_controller.allow_forgery_protection = false
|
||||
|
||||
# Tell Action Mailer not to deliver emails to the real world.
|
||||
# The :test delivery method accumulates sent emails in the
|
||||
# ActionMailer::Base.deliveries array.
|
||||
config.action_mailer.delivery_method = :spec
|
||||
|
||||
# Print deprecation notices to the stderr.
|
||||
config.active_support.deprecation = :stderr
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
||||
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
||||
|
||||
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
||||
# Rails.backtrace_cleaner.remove_silencers!
|
|
@ -1,262 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'devise'
|
||||
# Use this hook to configure devise mailer, warden hooks and so forth.
|
||||
# Many of these configuration options can be set straight in your model.
|
||||
Devise.setup do |config|
|
||||
# The secret key used by Devise. Devise uses this key to generate
|
||||
# random tokens. Changing this key will render invalid all existing
|
||||
# confirmation, reset password and unlock tokens in the database.
|
||||
config.secret_key = 'd5ee28e76818649f112d6f0fc8b20f9aa72e2bd83273f28b14b48ef8804f8e9cafa8ca4c9e4811a563bf4782b7908461189b6b45e9d85a97092453221a25ac3a'
|
||||
|
||||
# ==> Mailer Configuration
|
||||
# Configure the e-mail address which will be shown in Devise::Mailer,
|
||||
# note that it will be overwritten if you use your own mailer class
|
||||
# with default "from" parameter.
|
||||
config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
|
||||
|
||||
# Configure the class responsible to send e-mails.
|
||||
# config.mailer = 'Devise::Mailer'
|
||||
|
||||
# ==> ORM configuration
|
||||
# Load and configure the ORM. Supports :active_record (default) and
|
||||
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
||||
# available as additional gems.
|
||||
require 'devise/orm/active_record'
|
||||
|
||||
# ==> Configuration for any authentication mechanism
|
||||
# Configure which keys are used when authenticating a user. The default is
|
||||
# just :email. You can configure it to use [:username, :subdomain], so for
|
||||
# authenticating a user, both parameters are required. Remember that those
|
||||
# parameters are used only when authenticating and not when retrieving from
|
||||
# session. If you need permissions, you should implement that in a before filter.
|
||||
# You can also supply a hash where the value is a boolean determining whether
|
||||
# or not authentication should be aborted when the value is not present.
|
||||
# config.authentication_keys = [ :email ]
|
||||
|
||||
# Configure parameters from the request object used for authentication. Each entry
|
||||
# given should be a request method and it will automatically be passed to the
|
||||
# find_for_authentication method and considered in your model lookup. For instance,
|
||||
# if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
|
||||
# The same considerations mentioned for authentication_keys also apply to request_keys.
|
||||
# config.request_keys = []
|
||||
|
||||
# Configure which authentication keys should be case-insensitive.
|
||||
# These keys will be downcased upon creating or modifying a user and when used
|
||||
# to authenticate or find a user. Default is :email.
|
||||
config.case_insensitive_keys = [:email]
|
||||
|
||||
# Configure which authentication keys should have whitespace stripped.
|
||||
# These keys will have whitespace before and after removed upon creating or
|
||||
# modifying a user and when used to authenticate or find a user. Default is :email.
|
||||
config.strip_whitespace_keys = [:email]
|
||||
|
||||
# Tell if authentication through request.params is enabled. True by default.
|
||||
# It can be set to an array that will enable params authentication only for the
|
||||
# given strategies, for example, `config.params_authenticatable = [:database]` will
|
||||
# enable it only for database (email + password) authentication.
|
||||
# config.params_authenticatable = true
|
||||
|
||||
# Tell if authentication through HTTP Auth is enabled. False by default.
|
||||
# It can be set to an array that will enable http authentication only for the
|
||||
# given strategies, for example, `config.http_authenticatable = [:database]` will
|
||||
# enable it only for database authentication. The supported strategies are:
|
||||
# :database = Support basic authentication with authentication key + password
|
||||
# config.http_authenticatable = false
|
||||
|
||||
# If http headers should be returned for AJAX requests. True by default.
|
||||
# config.http_authenticatable_on_xhr = true
|
||||
|
||||
# The realm used in Http Basic Authentication. 'Application' by default.
|
||||
# config.http_authentication_realm = 'Application'
|
||||
|
||||
# It will change confirmation, password recovery and other workflows
|
||||
# to behave the same regardless if the e-mail provided was right or wrong.
|
||||
# Does not affect registerable.
|
||||
# config.paranoid = true
|
||||
|
||||
# By default Devise will store the user in session. You can skip storage for
|
||||
# particular strategies by setting this option.
|
||||
# Notice that if you are skipping storage for all authentication paths, you
|
||||
# may want to disable generating routes to Devise's sessions controller by
|
||||
# passing skip: :sessions to `devise_for` in your config/routes.rb
|
||||
config.skip_session_storage = [:http_auth]
|
||||
|
||||
# By default, Devise cleans up the CSRF token on authentication to
|
||||
# avoid CSRF token fixation attacks. This means that, when using AJAX
|
||||
# requests for sign in and sign up, you need to get a new CSRF token
|
||||
# from the server. You can disable this option at your own risk.
|
||||
# config.clean_up_csrf_token_on_authentication = true
|
||||
|
||||
# ==> Configuration for :database_authenticatable
|
||||
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
|
||||
# using other encryptors, it sets how many times you want the password re-encrypted.
|
||||
#
|
||||
# Limiting the stretches to just one in testing will increase the performance of
|
||||
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
|
||||
# a value less than 10 in other environments. Note that, for bcrypt (the default
|
||||
# encryptor), the cost increases exponentially with the number of stretches (e.g.
|
||||
# a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
|
||||
config.stretches = Rails.env.test? ? 1 : 10
|
||||
|
||||
# Setup a pepper to generate the encrypted password.
|
||||
# config.pepper = '5a21421a82d405edec88445a0b72552d60fca3c2b8c2e8f98356f84638a729c94081c43abb9f5b4a1391ce7a15f4cc4b3d919f19a0fc478e766245372a14df00'
|
||||
|
||||
# ==> Configuration for :confirmable
|
||||
# A period that the user is allowed to access the website even without
|
||||
# confirming their account. For instance, if set to 2.days, the user will be
|
||||
# able to access the website for two days without confirming their account,
|
||||
# access will be blocked just in the third day. Default is 0.days, meaning
|
||||
# the user cannot access the website without confirming their account.
|
||||
# config.allow_unconfirmed_access_for = 2.days
|
||||
|
||||
# A period that the user is allowed to confirm their account before their
|
||||
# token becomes invalid. For example, if set to 3.days, the user can confirm
|
||||
# their account within 3 days after the mail was sent, but on the fourth day
|
||||
# their account can't be confirmed with the token any more.
|
||||
# Default is nil, meaning there is no restriction on how long a user can take
|
||||
# before confirming their account.
|
||||
# config.confirm_within = 3.days
|
||||
|
||||
# If true, requires any email changes to be confirmed (exactly the same way as
|
||||
# initial account confirmation) to be applied. Requires additional unconfirmed_email
|
||||
# db field (see migrations). Until confirmed, new email is stored in
|
||||
# unconfirmed_email column, and copied to email column on successful confirmation.
|
||||
config.reconfirmable = true
|
||||
|
||||
# Defines which key will be used when confirming an account
|
||||
# config.confirmation_keys = [ :email ]
|
||||
|
||||
# ==> Configuration for :rememberable
|
||||
# The time the user will be remembered without asking for credentials again.
|
||||
# config.remember_for = 2.weeks
|
||||
|
||||
# Invalidates all the remember me tokens when the user signs out.
|
||||
config.expire_all_remember_me_on_sign_out = true
|
||||
|
||||
# If true, extends the user's remember period when remembered via cookie.
|
||||
# config.extend_remember_period = false
|
||||
|
||||
# Options to be passed to the created cookie. For instance, you can set
|
||||
# secure: true in order to force SSL only cookies.
|
||||
# config.rememberable_options = {}
|
||||
|
||||
# ==> Configuration for :validatable
|
||||
# Range for password length.
|
||||
config.password_length = 8..128
|
||||
|
||||
# Email regex used to validate email formats. It simply asserts that
|
||||
# one (and only one) @ exists in the given string. This is mainly
|
||||
# to give user feedback and not to assert the e-mail validity.
|
||||
# config.email_regexp = /\A[^@]+@[^@]+\z/
|
||||
|
||||
# ==> Configuration for :timeoutable
|
||||
# The time you want to timeout the user session without activity. After this
|
||||
# time the user will be asked for credentials again. Default is 30 minutes.
|
||||
# config.timeout_in = 30.minutes
|
||||
|
||||
# If true, expires auth token on session timeout.
|
||||
# config.expire_auth_token_on_timeout = false
|
||||
|
||||
# ==> Configuration for :lockable
|
||||
# Defines which strategy will be used to lock an account.
|
||||
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
|
||||
# :none = No lock strategy. You should handle locking by yourself.
|
||||
# config.lock_strategy = :failed_attempts
|
||||
|
||||
# Defines which key will be used when locking and unlocking an account
|
||||
# config.unlock_keys = [ :email ]
|
||||
|
||||
# Defines which strategy will be used to unlock an account.
|
||||
# :email = Sends an unlock link to the user email
|
||||
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
||||
# :both = Enables both strategies
|
||||
# :none = No unlock strategy. You should handle unlocking by yourself.
|
||||
# config.unlock_strategy = :both
|
||||
|
||||
# Number of authentication tries before locking an account if lock_strategy
|
||||
# is failed attempts.
|
||||
# config.maximum_attempts = 20
|
||||
|
||||
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
||||
# config.unlock_in = 1.hour
|
||||
|
||||
# Warn on the last attempt before the account is locked.
|
||||
# config.last_attempt_warning = false
|
||||
|
||||
# ==> Configuration for :recoverable
|
||||
#
|
||||
# Defines which key will be used when recovering the password for an account
|
||||
# config.reset_password_keys = [ :email ]
|
||||
|
||||
# Time interval you can reset your password with a reset password key.
|
||||
# Don't put a too small interval or your users won't have the time to
|
||||
# change their passwords.
|
||||
config.reset_password_within = 6.hours
|
||||
|
||||
# ==> Configuration for :encryptable
|
||||
# Allow you to use another encryption algorithm besides bcrypt (default). You can use
|
||||
# :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
|
||||
# :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
|
||||
# and :restful_authentication_sha1 (then you should set stretches to 10, and copy
|
||||
# REST_AUTH_SITE_KEY to pepper).
|
||||
#
|
||||
# Require the `devise-encryptable` gem when using anything other than bcrypt
|
||||
# config.encryptor = :sha512
|
||||
|
||||
# ==> Scopes configuration
|
||||
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
||||
# "users/sessions/new". It's turned off by default because it's slower if you
|
||||
# are using only default views.
|
||||
# config.scoped_views = false
|
||||
|
||||
# Configure the default scope given to Warden. By default it's the first
|
||||
# devise role declared in your routes (usually :user).
|
||||
# config.default_scope = :user
|
||||
|
||||
# Set this configuration to false if you want /users/sign_out to sign out
|
||||
# only the current scope. By default, Devise signs out all scopes.
|
||||
# config.sign_out_all_scopes = true
|
||||
|
||||
# ==> Navigation configuration
|
||||
# Lists the formats that should be treated as navigational. Formats like
|
||||
# :html, should redirect to the sign in page when the user does not have
|
||||
# access, but formats like :xml or :json, should return 401.
|
||||
#
|
||||
# If you have any extra navigational formats, like :iphone or :mobile, you
|
||||
# should add them to the navigational formats lists.
|
||||
#
|
||||
# The "*/*" below is required to match Internet Explorer requests.
|
||||
# config.navigational_formats = ['*/*', :html]
|
||||
|
||||
# The default HTTP method used to sign out a resource. Default is :delete.
|
||||
config.sign_out_via = :delete
|
||||
|
||||
# ==> OmniAuth
|
||||
# Add a new OmniAuth provider. Check the wiki for more information on setting
|
||||
# up on your models and hooks.
|
||||
# config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
|
||||
|
||||
# ==> Warden configuration
|
||||
# If you want to use other strategies, that are not supported by Devise, or
|
||||
# change the failure app, you can configure them inside the config.warden block.
|
||||
#
|
||||
# config.warden do |manager|
|
||||
# manager.intercept_401 = false
|
||||
# manager.default_strategies(scope: :user).unshift :some_external_strategy
|
||||
# end
|
||||
|
||||
# ==> Mountable engine configurations
|
||||
# When using Devise inside an engine, let's call it `MyEngine`, and this engine
|
||||
# is mountable, there are some extra configurations to be taken into account.
|
||||
# The following options are available, assuming the engine is mounted as:
|
||||
#
|
||||
# mount MyEngine, at: '/my_engine'
|
||||
#
|
||||
# The router that invoked `devise_for`, in the example above, would be:
|
||||
# config.router_name = :my_engine
|
||||
#
|
||||
# When using omniauth, Devise cannot automatically set Omniauth path,
|
||||
# so you need to do it manually. For the users scope, it would be:
|
||||
# config.omniauth_path_prefix = '/my_engine/users/auth'
|
||||
end
|
|
@ -1,6 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Configure sensitive parameters which will be filtered from the log file.
|
||||
Rails.application.config.filter_parameters += [:password]
|
|
@ -1,18 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Add new inflection rules using the following format. Inflections
|
||||
# are locale specific, and you may define rules for as many different
|
||||
# locales as you wish. All of these examples are active by default:
|
||||
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
||||
# inflect.plural /^(ox)$/i, '\1en'
|
||||
# inflect.singular /^(ox)en/i, '\1'
|
||||
# inflect.irregular 'person', 'people'
|
||||
# inflect.uncountable %w( fish sheep )
|
||||
# end
|
||||
|
||||
# These inflection rules are supported but not enabled by default:
|
||||
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
||||
# inflect.acronym 'RESTful'
|
||||
# end
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Add new mime types for use in respond_to blocks:
|
||||
# Mime::Type.register "text/richtext", :rtf
|
||||
# Mime::Type.register_alias "text/html", :iphone
|
|
@ -1,15 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Your secret key is used for verifying the integrity of signed cookies.
|
||||
# If you change this key, all old signed cookies will become invalid!
|
||||
|
||||
# Make sure the secret is at least 30 characters and all random,
|
||||
# no regular words or you'll be exposed to dictionary attacks.
|
||||
# You can use `rake secret` to generate a secure secret key.
|
||||
|
||||
# Make sure your secret_key_base is kept private
|
||||
# if you're sharing your code publicly.
|
||||
Dummy::Application.config.secret_key_base = 'ec3f72391ec6c746cd3ab309163423262b262963beedd29a521f7651da3fafcc13ce7635758c118402d5cdcf006fc7142a46484c6384ba6b45cecd86f318eddc'
|
||||
Dummy::Application.config.secret_key = '792518f023a032d868890eba6d50deb422e5afbe4affd3e9ee32943c5948b13ee54b9292875694cd7e8232663ffb0d0731278e9ae189a21acbb99d8263e4a819'
|
|
@ -1,5 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
|
|
@ -1,16 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# This file contains settings for ActionController::ParamsWrapper which
|
||||
# is enabled by default.
|
||||
|
||||
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
||||
ActiveSupport.on_load(:action_controller) do
|
||||
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
|
||||
end
|
||||
|
||||
# To enable root element in JSON for ActiveRecord objects.
|
||||
# ActiveSupport.on_load(:active_record) do
|
||||
# self.include_root_in_json = true
|
||||
# end
|
|
@ -1,60 +0,0 @@
|
|||
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
|
||||
|
||||
en:
|
||||
devise:
|
||||
confirmations:
|
||||
confirmed: "Your email address has been successfully confirmed."
|
||||
send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
|
||||
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."
|
||||
failure:
|
||||
already_authenticated: "You are already signed in."
|
||||
inactive: "Your account is not activated yet."
|
||||
invalid: "Invalid email or password."
|
||||
locked: "Your account is locked."
|
||||
last_attempt: "You have one more attempt before your account is locked."
|
||||
not_found_in_database: "Invalid email address or password."
|
||||
timeout: "Your session expired. Please sign in again to continue."
|
||||
unauthenticated: "You need to sign in or sign up before continuing."
|
||||
unconfirmed: "You have to confirm your email address before continuing."
|
||||
mailer:
|
||||
confirmation_instructions:
|
||||
subject: "Confirmation instructions"
|
||||
reset_password_instructions:
|
||||
subject: "Reset password instructions"
|
||||
unlock_instructions:
|
||||
subject: "Unlock instructions"
|
||||
omniauth_callbacks:
|
||||
failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
|
||||
success: "Successfully authenticated from %{kind} account."
|
||||
passwords:
|
||||
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."
|
||||
send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
|
||||
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."
|
||||
updated: "Your password has been changed successfully. You are now signed in."
|
||||
updated_not_active: "Your password has been changed successfully."
|
||||
registrations:
|
||||
destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
|
||||
signed_up: "Welcome! You have signed up successfully."
|
||||
signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
|
||||
signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
|
||||
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."
|
||||
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."
|
||||
updated: "Your account has been updated successfully."
|
||||
sessions:
|
||||
signed_in: "Signed in successfully."
|
||||
signed_out: "Signed out successfully."
|
||||
already_signed_out: "Signed out successfully."
|
||||
unlocks:
|
||||
send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
|
||||
send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
|
||||
unlocked: "Your account has been unlocked successfully. Please sign in to continue."
|
||||
errors:
|
||||
messages:
|
||||
already_confirmed: "was already confirmed, please try signing in"
|
||||
confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
|
||||
expired: "has expired, please request a new one"
|
||||
not_found: "not found"
|
||||
not_locked: "was not locked"
|
||||
not_saved:
|
||||
one: "1 error prohibited this %{resource} from being saved:"
|
||||
other: "%{count} errors prohibited this %{resource} from being saved:"
|
|
@ -1,23 +0,0 @@
|
|||
# Files in the config/locales directory are used for internationalization
|
||||
# and are automatically loaded by Rails. If you want to use locales other
|
||||
# than English, add the necessary files in this directory.
|
||||
#
|
||||
# To use the locales, use `I18n.t`:
|
||||
#
|
||||
# I18n.t 'hello'
|
||||
#
|
||||
# In views, this is aliased to just `t`:
|
||||
#
|
||||
# <%= t('hello') %>
|
||||
#
|
||||
# To use a different locale, set it with `I18n.locale`:
|
||||
#
|
||||
# I18n.locale = :es
|
||||
#
|
||||
# This would use the information in config/locales/es.yml.
|
||||
#
|
||||
# To learn more, please read the Rails Internationalization guide
|
||||
# available at http://guides.rubyonrails.org/i18n.html.
|
||||
|
||||
en:
|
||||
hello: "Hello world"
|
|
@ -1,8 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'devise'
|
||||
|
||||
Dummy::Application.routes.draw do
|
||||
devise_for :users
|
||||
mount API => '/'
|
||||
end
|
|
@ -1,43 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DeviseCreateUsers < ActiveRecord::Migration
|
||||
def change
|
||||
create_table(:users) do |t|
|
||||
## Database authenticatable
|
||||
t.string :email, null: false, default: ''
|
||||
t.string :encrypted_password, null: false, default: ''
|
||||
|
||||
## Recoverable
|
||||
t.string :reset_password_token
|
||||
t.datetime :reset_password_sent_at
|
||||
|
||||
## Rememberable
|
||||
t.datetime :remember_created_at
|
||||
|
||||
## Trackable
|
||||
t.integer :sign_in_count, default: 0, null: false
|
||||
t.datetime :current_sign_in_at
|
||||
t.datetime :last_sign_in_at
|
||||
t.string :current_sign_in_ip
|
||||
t.string :last_sign_in_ip
|
||||
|
||||
## Confirmable
|
||||
# t.string :confirmation_token
|
||||
# t.datetime :confirmed_at
|
||||
# t.datetime :confirmation_sent_at
|
||||
# t.string :unconfirmed_email # Only if using reconfirmable
|
||||
|
||||
## Lockable
|
||||
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
|
||||
# t.string :unlock_token # Only if unlock strategy is :email or :both
|
||||
# t.datetime :locked_at
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :users, :email, unique: true
|
||||
add_index :users, :reset_password_token, unique: true
|
||||
# add_index :users, :confirmation_token, unique: true
|
||||
# add_index :users, :unlock_token, unique: true
|
||||
end
|
||||
end
|
|
@ -1,33 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# This file is auto-generated from the current state of the database. Instead
|
||||
# of editing this file, please use the migrations feature of Active Record to
|
||||
# incrementally modify your database, and then regenerate this schema definition.
|
||||
#
|
||||
# Note that this schema.rb definition is the authoritative source for your
|
||||
# database schema. If you need to create the application database on another
|
||||
# system, you should be using db:schema:load, not running all the migrations
|
||||
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
||||
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20_140_913_043_018) do
|
||||
create_table 'users', force: true do |t|
|
||||
t.string 'email', default: '', null: false
|
||||
t.string 'encrypted_password', default: '', null: false
|
||||
t.string 'reset_password_token'
|
||||
t.datetime 'reset_password_sent_at'
|
||||
t.datetime 'remember_created_at'
|
||||
t.integer 'sign_in_count', default: 0, null: false
|
||||
t.datetime 'current_sign_in_at'
|
||||
t.datetime 'last_sign_in_at'
|
||||
t.string 'current_sign_in_ip'
|
||||
t.string 'last_sign_in_ip'
|
||||
t.datetime 'created_at'
|
||||
t.datetime 'updated_at'
|
||||
end
|
||||
|
||||
add_index 'users', ['email'], name: 'index_users_on_email', unique: true
|
||||
add_index 'users', ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true
|
||||
end
|
|
@ -1,58 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>The page you were looking for doesn't exist (404)</title>
|
||||
<style>
|
||||
body {
|
||||
background-color: #EFEFEF;
|
||||
color: #2E2F30;
|
||||
text-align: center;
|
||||
font-family: arial, sans-serif;
|
||||
}
|
||||
|
||||
div.dialog {
|
||||
width: 25em;
|
||||
margin: 4em auto 0 auto;
|
||||
border: 1px solid #CCC;
|
||||
border-right-color: #999;
|
||||
border-left-color: #999;
|
||||
border-bottom-color: #BBB;
|
||||
border-top: #B00100 solid 4px;
|
||||
border-top-left-radius: 9px;
|
||||
border-top-right-radius: 9px;
|
||||
background-color: white;
|
||||
padding: 7px 4em 0 4em;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 100%;
|
||||
color: #730E15;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
|
||||
body > p {
|
||||
width: 33em;
|
||||
margin: 0 auto 1em;
|
||||
padding: 1em 0;
|
||||
background-color: #F7F7F7;
|
||||
border: 1px solid #CCC;
|
||||
border-right-color: #999;
|
||||
border-bottom-color: #999;
|
||||
border-bottom-left-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
border-top-color: #DADADA;
|
||||
color: #666;
|
||||
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- This file lives in public/404.html -->
|
||||
<div class="dialog">
|
||||
<h1>The page you were looking for doesn't exist.</h1>
|
||||
<p>You may have mistyped the address or the page may have moved.</p>
|
||||
</div>
|
||||
<p>If you are the application owner check the logs for more information.</p>
|
||||
</body>
|
||||
</html>
|
|
@ -1,58 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>The change you wanted was rejected (422)</title>
|
||||
<style>
|
||||
body {
|
||||
background-color: #EFEFEF;
|
||||
color: #2E2F30;
|
||||
text-align: center;
|
||||
font-family: arial, sans-serif;
|
||||
}
|
||||
|
||||
div.dialog {
|
||||
width: 25em;
|
||||
margin: 4em auto 0 auto;
|
||||
border: 1px solid #CCC;
|
||||
border-right-color: #999;
|
||||
border-left-color: #999;
|
||||
border-bottom-color: #BBB;
|
||||
border-top: #B00100 solid 4px;
|
||||
border-top-left-radius: 9px;
|
||||
border-top-right-radius: 9px;
|
||||
background-color: white;
|
||||
padding: 7px 4em 0 4em;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 100%;
|
||||
color: #730E15;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
|
||||
body > p {
|
||||
width: 33em;
|
||||
margin: 0 auto 1em;
|
||||
padding: 1em 0;
|
||||
background-color: #F7F7F7;
|
||||
border: 1px solid #CCC;
|
||||
border-right-color: #999;
|
||||
border-bottom-color: #999;
|
||||
border-bottom-left-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
border-top-color: #DADADA;
|
||||
color: #666;
|
||||
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- This file lives in public/422.html -->
|
||||
<div class="dialog">
|
||||
<h1>The change you wanted was rejected.</h1>
|
||||
<p>Maybe you tried to change something you didn't have access to.</p>
|
||||
</div>
|
||||
<p>If you are the application owner check the logs for more information.</p>
|
||||
</body>
|
||||
</html>
|
|
@ -1,57 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>We're sorry, but something went wrong (500)</title>
|
||||
<style>
|
||||
body {
|
||||
background-color: #EFEFEF;
|
||||
color: #2E2F30;
|
||||
text-align: center;
|
||||
font-family: arial, sans-serif;
|
||||
}
|
||||
|
||||
div.dialog {
|
||||
width: 25em;
|
||||
margin: 4em auto 0 auto;
|
||||
border: 1px solid #CCC;
|
||||
border-right-color: #999;
|
||||
border-left-color: #999;
|
||||
border-bottom-color: #BBB;
|
||||
border-top: #B00100 solid 4px;
|
||||
border-top-left-radius: 9px;
|
||||
border-top-right-radius: 9px;
|
||||
background-color: white;
|
||||
padding: 7px 4em 0 4em;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 100%;
|
||||
color: #730E15;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
|
||||
body > p {
|
||||
width: 33em;
|
||||
margin: 0 auto 1em;
|
||||
padding: 1em 0;
|
||||
background-color: #F7F7F7;
|
||||
border: 1px solid #CCC;
|
||||
border-right-color: #999;
|
||||
border-bottom-color: #999;
|
||||
border-bottom-left-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
border-top-color: #DADADA;
|
||||
color: #666;
|
||||
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- This file lives in public/500.html -->
|
||||
<div class="dialog">
|
||||
<h1>We're sorry, but something went wrong.</h1>
|
||||
</div>
|
||||
<p>If you are the application owner check the logs for more information.</p>
|
||||
</body>
|
||||
</html>
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :user do
|
||||
email 'john.doe@example.com'
|
||||
password '12345'
|
||||
password_confirmation '12345'
|
||||
end
|
||||
end
|
|
@ -1,53 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
require 'warden/test/helpers'
|
||||
|
||||
RSpec.describe API, type: :request do
|
||||
include Warden::Test::Helpers
|
||||
|
||||
let(:user) { build(:user) }
|
||||
|
||||
after { Warden.test_reset! }
|
||||
|
||||
it 'should return the current user' do
|
||||
login_as user, scope: :user
|
||||
|
||||
get '/me'
|
||||
|
||||
response.body.should eq(user.to_json)
|
||||
end
|
||||
|
||||
it 'should return an error if not logged in' do
|
||||
login_as nil, scope: :user
|
||||
|
||||
get '/me'
|
||||
|
||||
response.code.should eq('401')
|
||||
end
|
||||
|
||||
it 'should return true if logged in' do
|
||||
login_as user, scope: :user
|
||||
|
||||
get '/authorized'
|
||||
|
||||
response.body.should eq('true')
|
||||
end
|
||||
|
||||
it 'should return false if logged out' do
|
||||
login_as nil, scope: :user
|
||||
|
||||
get '/authorized'
|
||||
|
||||
response.body.should eq('false')
|
||||
end
|
||||
|
||||
it 'should log in the user' do
|
||||
User.stub :find_for_database_authentication do
|
||||
user
|
||||
end
|
||||
post '/signin', user: { email: user.email, password: user.password }
|
||||
|
||||
response.code.should eq('201')
|
||||
end
|
||||
end
|
|
@ -1,38 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Configure Rails Environment
|
||||
ENV['RAILS_ENV'] = 'test'
|
||||
|
||||
require File.expand_path('dummy/config/environment.rb', __dir__)
|
||||
require 'rspec'
|
||||
require 'rspec/rails'
|
||||
require 'factory_girl'
|
||||
require 'warden'
|
||||
require 'devise'
|
||||
require 'capybara/dsl'
|
||||
require 'factories'
|
||||
require 'nulldb/rails'
|
||||
Warden.test_mode!
|
||||
|
||||
Rails.backtrace_cleaner.remove_silencers!
|
||||
|
||||
# Requires supporting ruby files with custom matchers and macros, etc,
|
||||
# in spec/support/ and its subdirectories.
|
||||
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
||||
|
||||
RSpec.configure do |config|
|
||||
# == Mock Framework
|
||||
#
|
||||
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
||||
#
|
||||
# config.mock_with :mocha
|
||||
# config.mock_with :flexmock
|
||||
# config.mock_with :rr
|
||||
config.mock_with :rspec
|
||||
config.use_transactional_fixtures = true
|
||||
config.infer_spec_type_from_file_location!
|
||||
|
||||
config.include Capybara::DSL, type: :request
|
||||
config.include FactoryGirl::Syntax::Methods
|
||||
config.include Devise::Test::ControllerHelpers, type: :controller
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
Description:
|
||||
Generates a new entity to be returned by the API
|
||||
|
||||
Example:
|
||||
rails generate api:entity EntityName
|
||||
|
||||
This will create:
|
||||
A new subclass of Grape::Entity called Houdini::V1::Entities::EntityName
|
||||
in app/api/houdini/v1/entities/entity_name.rb
|
|
@ -1,10 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
require 'rails/generators'
|
||||
class Api::EntityGenerator < Rails::Generators::NamedBase
|
||||
source_root File.expand_path('templates', __dir__)
|
||||
def copy_to_entity
|
||||
template 'entity.rb.erb', File.join('app/api/houdini/v1/entities', "#{name.underscore}.rb")
|
||||
end
|
||||
end
|
|
@ -1,4 +0,0 @@
|
|||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
class Houdini::V1::Entities::<%= name.camelcase %> < Grape::Entity
|
||||
|
||||
end
|
|
@ -1,10 +0,0 @@
|
|||
Description:
|
||||
Creates a new resource for API usage
|
||||
|
||||
Example:
|
||||
rails generate api:resource ResourceName
|
||||
|
||||
This will create:
|
||||
* A new subclass of Grape::API called Houdini::V1::ResourceName
|
||||
at app/api/houdini/v1/resource_name.rb
|
||||
* Houdini::V1::ResourceName mounted to the api in app/api/houdini/v1/api.rb
|
|
@ -1,18 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
require 'rails/generators'
|
||||
class Api::ResourceGenerator < Rails::Generators::NamedBase
|
||||
source_root File.expand_path('templates', __dir__)
|
||||
def copy_to_resource
|
||||
template 'resource.rb.erb', File.join('app/api/houdini/v1', "#{name.underscore}.rb")
|
||||
end
|
||||
|
||||
def copy_to_spec
|
||||
template 'spec.rb.erb', File.join('spec/api/houdini/', "#{name.underscore}_spec.rb")
|
||||
end
|
||||
|
||||
def add_to_root_api
|
||||
inject_into_file 'app/api/houdini/v1/api.rb', "mount Houdini::V1::#{name.camelcase} => \"/#{name.underscore}\"\n ", before: '# Additional mounts are added via generators above this line'
|
||||
end
|
||||
end
|
|
@ -1,3 +0,0 @@
|
|||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
class Houdini::V1::<%= name.camelcase %> < Grape::API
|
||||
end
|
|
@ -1,8 +0,0 @@
|
|||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
require 'rails_helper'
|
||||
|
||||
describe Houdini::V1::<%= name.camelcase %>, :type => :request do
|
||||
describe 'get', :get do
|
||||
|
||||
end
|
||||
end
|
|
@ -1,8 +0,0 @@
|
|||
Description:
|
||||
Explain the generator
|
||||
|
||||
Example:
|
||||
rails generate validator Thing
|
||||
|
||||
This will create:
|
||||
what/will/it/create
|
|
@ -1,6 +0,0 @@
|
|||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
class Houdini::V1::Validators::<%= name.camelcase %> < Grape::Validations::Base
|
||||
def validate_param!(attr_name, params)
|
||||
fail Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message: 'MESSAGE'
|
||||
end
|
||||
end
|
|
@ -1,18 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
require 'rails/generators'
|
||||
class Api::ValidatorGenerator < Rails::Generators::NamedBase
|
||||
source_root File.expand_path('templates', __dir__)
|
||||
|
||||
def copy_to_validators
|
||||
post_api_part = File.join('houdini/v1/validators', "#{name.underscore}.rb")
|
||||
output_file = File.join('app/api', post_api_part)
|
||||
template 'validator.rb.erb', output_file
|
||||
end
|
||||
|
||||
def add_to_root_validations
|
||||
post_api_part = File.join('houdini/v1/validators', name.underscore.to_s)
|
||||
append_to_file 'app/api/houdini/v1/validations.rb', "\nrequire '#{post_api_part}'"
|
||||
end
|
||||
end
|
|
@ -1,10 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'grape-swagger/rake/oapi_tasks'
|
||||
namespace :oapi do
|
||||
task gen: [:environment] do
|
||||
ENV['store'] = 'tmp/openapi.json'
|
||||
GrapeSwagger::Rake::OapiTasks.new(Houdini::API)
|
||||
Rake::Task['oapi:fetch'].invoke
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue