devise_token_auth_skycocker_fork 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +13 -0
- data/README.md +97 -0
- data/Rakefile +42 -0
- data/app/controllers/devise_token_auth/application_controller.rb +79 -0
- data/app/controllers/devise_token_auth/concerns/resource_finder.rb +44 -0
- data/app/controllers/devise_token_auth/concerns/set_user_by_token.rb +178 -0
- data/app/controllers/devise_token_auth/confirmations_controller.rb +39 -0
- data/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +239 -0
- data/app/controllers/devise_token_auth/passwords_controller.rb +185 -0
- data/app/controllers/devise_token_auth/registrations_controller.rb +198 -0
- data/app/controllers/devise_token_auth/sessions_controller.rb +131 -0
- data/app/controllers/devise_token_auth/token_validations_controller.rb +31 -0
- data/app/controllers/devise_token_auth/unlocks_controller.rb +89 -0
- data/app/models/devise_token_auth/concerns/active_record_support.rb +34 -0
- data/app/models/devise_token_auth/concerns/mongoid_support.rb +19 -0
- data/app/models/devise_token_auth/concerns/user.rb +262 -0
- data/app/models/devise_token_auth/concerns/user_omniauth_callbacks.rb +28 -0
- data/app/validators/devise_token_auth/email_validator.rb +23 -0
- data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/devise_token_auth/omniauth_external_window.html.erb +38 -0
- data/config/locales/da-DK.yml +50 -0
- data/config/locales/de.yml +49 -0
- data/config/locales/en.yml +50 -0
- data/config/locales/es.yml +49 -0
- data/config/locales/fr.yml +49 -0
- data/config/locales/it.yml +46 -0
- data/config/locales/ja.yml +46 -0
- data/config/locales/nl.yml +30 -0
- data/config/locales/pl.yml +48 -0
- data/config/locales/pt-BR.yml +46 -0
- data/config/locales/pt.yml +48 -0
- data/config/locales/ro.yml +46 -0
- data/config/locales/ru.yml +50 -0
- data/config/locales/sq.yml +46 -0
- data/config/locales/sv.yml +50 -0
- data/config/locales/uk.yml +59 -0
- data/config/locales/vi.yml +50 -0
- data/config/locales/zh-CN.yml +46 -0
- data/config/locales/zh-HK.yml +48 -0
- data/config/locales/zh-TW.yml +48 -0
- data/lib/devise_token_auth.rb +13 -0
- data/lib/devise_token_auth/blacklist.rb +2 -0
- data/lib/devise_token_auth/controllers/helpers.rb +161 -0
- data/lib/devise_token_auth/controllers/url_helpers.rb +10 -0
- data/lib/devise_token_auth/engine.rb +90 -0
- data/lib/devise_token_auth/errors.rb +8 -0
- data/lib/devise_token_auth/rails/routes.rb +116 -0
- data/lib/devise_token_auth/url.rb +41 -0
- data/lib/devise_token_auth/version.rb +5 -0
- data/lib/generators/devise_token_auth/USAGE +31 -0
- data/lib/generators/devise_token_auth/install_generator.rb +91 -0
- data/lib/generators/devise_token_auth/install_generator_helpers.rb +98 -0
- data/lib/generators/devise_token_auth/install_mongoid_generator.rb +46 -0
- data/lib/generators/devise_token_auth/install_views_generator.rb +18 -0
- data/lib/generators/devise_token_auth/templates/devise_token_auth.rb +50 -0
- data/lib/generators/devise_token_auth/templates/devise_token_auth_create_users.rb.erb +56 -0
- data/lib/generators/devise_token_auth/templates/user.rb.erb +9 -0
- data/lib/generators/devise_token_auth/templates/user_mongoid.rb.erb +63 -0
- data/lib/tasks/devise_token_auth_tasks.rake +6 -0
- data/test/controllers/custom/custom_confirmations_controller_test.rb +25 -0
- data/test/controllers/custom/custom_omniauth_callbacks_controller_test.rb +33 -0
- data/test/controllers/custom/custom_passwords_controller_test.rb +79 -0
- data/test/controllers/custom/custom_registrations_controller_test.rb +63 -0
- data/test/controllers/custom/custom_sessions_controller_test.rb +39 -0
- data/test/controllers/custom/custom_token_validations_controller_test.rb +42 -0
- data/test/controllers/demo_group_controller_test.rb +151 -0
- data/test/controllers/demo_mang_controller_test.rb +284 -0
- data/test/controllers/demo_user_controller_test.rb +629 -0
- data/test/controllers/devise_token_auth/confirmations_controller_test.rb +127 -0
- data/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb +376 -0
- data/test/controllers/devise_token_auth/passwords_controller_test.rb +639 -0
- data/test/controllers/devise_token_auth/registrations_controller_test.rb +880 -0
- data/test/controllers/devise_token_auth/sessions_controller_test.rb +541 -0
- data/test/controllers/devise_token_auth/token_validations_controller_test.rb +102 -0
- data/test/controllers/devise_token_auth/unlocks_controller_test.rb +196 -0
- data/test/controllers/overrides/confirmations_controller_test.rb +47 -0
- data/test/controllers/overrides/omniauth_callbacks_controller_test.rb +53 -0
- data/test/controllers/overrides/passwords_controller_test.rb +64 -0
- data/test/controllers/overrides/registrations_controller_test.rb +46 -0
- data/test/controllers/overrides/sessions_controller_test.rb +35 -0
- data/test/controllers/overrides/token_validations_controller_test.rb +43 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/app/active_record/lockable_user.rb +7 -0
- data/test/dummy/app/active_record/mang.rb +5 -0
- data/test/dummy/app/active_record/only_email_user.rb +7 -0
- data/test/dummy/app/active_record/scoped_user.rb +9 -0
- data/test/dummy/app/active_record/unconfirmable_user.rb +9 -0
- data/test/dummy/app/active_record/unregisterable_user.rb +9 -0
- data/test/dummy/app/active_record/user.rb +6 -0
- data/test/dummy/app/controllers/application_controller.rb +18 -0
- data/test/dummy/app/controllers/auth_origin_controller.rb +7 -0
- data/test/dummy/app/controllers/custom/confirmations_controller.rb +13 -0
- data/test/dummy/app/controllers/custom/omniauth_callbacks_controller.rb +13 -0
- data/test/dummy/app/controllers/custom/passwords_controller.rb +39 -0
- data/test/dummy/app/controllers/custom/registrations_controller.rb +39 -0
- data/test/dummy/app/controllers/custom/sessions_controller.rb +29 -0
- data/test/dummy/app/controllers/custom/token_validations_controller.rb +19 -0
- data/test/dummy/app/controllers/demo_group_controller.rb +15 -0
- data/test/dummy/app/controllers/demo_mang_controller.rb +14 -0
- data/test/dummy/app/controllers/demo_user_controller.rb +27 -0
- data/test/dummy/app/controllers/overrides/confirmations_controller.rb +28 -0
- data/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb +16 -0
- data/test/dummy/app/controllers/overrides/passwords_controller.rb +35 -0
- data/test/dummy/app/controllers/overrides/registrations_controller.rb +29 -0
- data/test/dummy/app/controllers/overrides/sessions_controller.rb +36 -0
- data/test/dummy/app/controllers/overrides/token_validations_controller.rb +23 -0
- data/test/dummy/app/helpers/application_helper.rb +1058 -0
- data/test/dummy/app/models/concerns/favorite_color.rb +19 -0
- data/test/dummy/app/mongoid/lockable_user.rb +38 -0
- data/test/dummy/app/mongoid/mang.rb +53 -0
- data/test/dummy/app/mongoid/only_email_user.rb +33 -0
- data/test/dummy/app/mongoid/scoped_user.rb +57 -0
- data/test/dummy/app/mongoid/unconfirmable_user.rb +51 -0
- data/test/dummy/app/mongoid/unregisterable_user.rb +54 -0
- data/test/dummy/app/mongoid/user.rb +56 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +18 -0
- data/test/dummy/config/application.rb +48 -0
- data/test/dummy/config/application.yml.bk +0 -0
- data/test/dummy/config/boot.rb +11 -0
- data/test/dummy/config/environment.rb +7 -0
- data/test/dummy/config/environments/development.rb +46 -0
- data/test/dummy/config/environments/production.rb +84 -0
- data/test/dummy/config/environments/test.rb +50 -0
- data/test/dummy/config/initializers/assets.rb +10 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +9 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/devise.rb +17 -0
- data/test/dummy/config/initializers/devise_token_auth.rb +24 -0
- data/test/dummy/config/initializers/figaro.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +6 -0
- data/test/dummy/config/initializers/inflections.rb +18 -0
- data/test/dummy/config/initializers/mime_types.rb +6 -0
- data/test/dummy/config/initializers/omniauth.rb +10 -0
- data/test/dummy/config/initializers/session_store.rb +5 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +16 -0
- data/test/dummy/config/routes.rb +55 -0
- data/test/dummy/config/spring.rb +3 -0
- data/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb +65 -0
- data/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb +64 -0
- data/test/dummy/db/migrate/20140829044006_add_operating_thetan_to_user.rb +8 -0
- data/test/dummy/db/migrate/20140916224624_add_favorite_color_to_mangs.rb +7 -0
- data/test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb +62 -0
- data/test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb +63 -0
- data/test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb +63 -0
- data/test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb +63 -0
- data/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb +63 -0
- data/test/dummy/db/schema.rb +200 -0
- data/test/dummy/lib/migration_database_helper.rb +43 -0
- data/test/dummy/tmp/generators/app/models/user.rb +9 -0
- data/test/dummy/tmp/generators/config/initializers/devise_token_auth.rb +50 -0
- data/test/dummy/tmp/generators/db/migrate/20181030122248_devise_token_auth_create_users.rb +56 -0
- data/test/factories/users.rb +40 -0
- data/test/lib/devise_token_auth/blacklist_test.rb +11 -0
- data/test/lib/devise_token_auth/url_test.rb +26 -0
- data/test/lib/generators/devise_token_auth/install_generator_test.rb +217 -0
- data/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb +222 -0
- data/test/lib/generators/devise_token_auth/install_views_generator_test.rb +25 -0
- data/test/models/concerns/mongoid_support_test.rb +31 -0
- data/test/models/only_email_user_test.rb +37 -0
- data/test/models/user_test.rb +140 -0
- data/test/support/controllers/routes.rb +43 -0
- data/test/test_helper.rb +103 -0
- metadata +443 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
# was the web request successful?
|
6
|
+
# was the user redirected to the right page?
|
7
|
+
# was the user successfully authenticated?
|
8
|
+
# was the correct object stored in the response?
|
9
|
+
# was the appropriate message delivered in the json payload?
|
10
|
+
|
11
|
+
class Overrides::RegistrationsControllerTest < ActionDispatch::IntegrationTest
|
12
|
+
include OverridesControllersRoutes
|
13
|
+
|
14
|
+
describe Overrides::RegistrationsController do
|
15
|
+
describe 'Succesful Registration update' do
|
16
|
+
before do
|
17
|
+
@existing_user = create(:user, :confirmed)
|
18
|
+
@auth_headers = @existing_user.create_new_auth_token
|
19
|
+
@client_id = @auth_headers['client']
|
20
|
+
@favorite_color = 'pink'
|
21
|
+
|
22
|
+
# ensure request is not treated as batch request
|
23
|
+
age_token(@existing_user, @client_id)
|
24
|
+
|
25
|
+
# test valid update param
|
26
|
+
@new_operating_thetan = 1_000_000
|
27
|
+
|
28
|
+
put '/evil_user_auth',
|
29
|
+
params: { favorite_color: @favorite_color },
|
30
|
+
headers: @auth_headers
|
31
|
+
|
32
|
+
@data = JSON.parse(response.body)
|
33
|
+
@existing_user.reload
|
34
|
+
end
|
35
|
+
|
36
|
+
test 'user was updated' do
|
37
|
+
assert_equal @favorite_color, @existing_user.favorite_color
|
38
|
+
end
|
39
|
+
|
40
|
+
test 'controller was overridden' do
|
41
|
+
assert_equal Overrides::RegistrationsController::OVERRIDE_PROOF,
|
42
|
+
@data['override_proof']
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
# was the web request successful?
|
6
|
+
# was the user redirected to the right page?
|
7
|
+
# was the user successfully authenticated?
|
8
|
+
# was the correct object stored in the response?
|
9
|
+
# was the appropriate message delivered in the json payload?
|
10
|
+
|
11
|
+
class Overrides::RegistrationsControllerTest < ActionDispatch::IntegrationTest
|
12
|
+
include OverridesControllersRoutes
|
13
|
+
|
14
|
+
describe Overrides::RegistrationsController do
|
15
|
+
before do
|
16
|
+
@existing_user = create(:user, :confirmed)
|
17
|
+
|
18
|
+
post '/evil_user_auth/sign_in',
|
19
|
+
params: { email: @existing_user.email,
|
20
|
+
password: @existing_user.password }
|
21
|
+
|
22
|
+
@resource = assigns(:resource)
|
23
|
+
@data = JSON.parse(response.body)
|
24
|
+
end
|
25
|
+
|
26
|
+
test 'request should succeed' do
|
27
|
+
assert_equal 200, response.status
|
28
|
+
end
|
29
|
+
|
30
|
+
test 'controller was overridden' do
|
31
|
+
assert_equal Overrides::RegistrationsController::OVERRIDE_PROOF,
|
32
|
+
@data['override_proof']
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
# was the web request successful?
|
6
|
+
# was the user redirected to the right page?
|
7
|
+
# was the user successfully authenticated?
|
8
|
+
# was the correct object stored in the response?
|
9
|
+
# was the appropriate message delivered in the json payload?
|
10
|
+
|
11
|
+
class Overrides::TokenValidationsControllerTest < ActionDispatch::IntegrationTest
|
12
|
+
include OverridesControllersRoutes
|
13
|
+
|
14
|
+
describe Overrides::TokenValidationsController do
|
15
|
+
before do
|
16
|
+
@resource = create(:user, :confirmed)
|
17
|
+
|
18
|
+
@auth_headers = @resource.create_new_auth_token
|
19
|
+
|
20
|
+
@token = @auth_headers['access-token']
|
21
|
+
@client_id = @auth_headers['client']
|
22
|
+
@expiry = @auth_headers['expiry']
|
23
|
+
|
24
|
+
# ensure that request is not treated as batch request
|
25
|
+
age_token(@resource, @client_id)
|
26
|
+
|
27
|
+
get '/evil_user_auth/validate_token',
|
28
|
+
params: {},
|
29
|
+
headers: @auth_headers
|
30
|
+
|
31
|
+
@resp = JSON.parse(response.body)
|
32
|
+
end
|
33
|
+
|
34
|
+
test 'token valid' do
|
35
|
+
assert_equal 200, response.status
|
36
|
+
end
|
37
|
+
|
38
|
+
test 'controller was overridden' do
|
39
|
+
assert_equal Overrides::TokenValidationsController::OVERRIDE_PROOF,
|
40
|
+
@resp['override_proof']
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ScopedUser < ActiveRecord::Base
|
4
|
+
# Include default devise modules.
|
5
|
+
devise :database_authenticatable, :registerable,
|
6
|
+
:recoverable, :rememberable, :trackable,
|
7
|
+
:validatable, :confirmable, :omniauthable
|
8
|
+
include DeviseTokenAuth::Concerns::User
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UnconfirmableUser < ActiveRecord::Base
|
4
|
+
# Include default devise modules.
|
5
|
+
devise :database_authenticatable, :registerable,
|
6
|
+
:recoverable, :rememberable, :trackable,
|
7
|
+
:validatable, :omniauthable
|
8
|
+
include DeviseTokenAuth::Concerns::User
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UnregisterableUser < ActiveRecord::Base
|
4
|
+
# Include default devise modules.
|
5
|
+
devise :database_authenticatable, :recoverable,
|
6
|
+
:trackable, :validatable, :confirmable,
|
7
|
+
:omniauthable
|
8
|
+
include DeviseTokenAuth::Concerns::User
|
9
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ApplicationController < ActionController::Base
|
4
|
+
include DeviseTokenAuth::Concerns::SetUserByToken
|
5
|
+
|
6
|
+
before_action :configure_permitted_parameters, if: :devise_controller?
|
7
|
+
|
8
|
+
protected
|
9
|
+
|
10
|
+
def configure_permitted_parameters
|
11
|
+
permitted_parameters = devise_parameter_sanitizer.instance_values['permitted']
|
12
|
+
permitted_parameters[:sign_up] << :operating_thetan
|
13
|
+
permitted_parameters[:sign_up] << :favorite_color
|
14
|
+
permitted_parameters[:account_update] << :operating_thetan
|
15
|
+
permitted_parameters[:account_update] << :favorite_color
|
16
|
+
permitted_parameters[:account_update] << :current_password
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Custom::ConfirmationsController < DeviseTokenAuth::ConfirmationsController
|
4
|
+
def show
|
5
|
+
super do |resource|
|
6
|
+
@show_block_called = true unless resource.nil?
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def show_block_called?
|
11
|
+
@show_block_called == true
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Custom::OmniauthCallbacksController < DeviseTokenAuth::OmniauthCallbacksController
|
4
|
+
def omniauth_success
|
5
|
+
super do |resource|
|
6
|
+
@omniauth_success_block_called = true unless resource.nil?
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def omniauth_success_block_called?
|
11
|
+
@omniauth_success_block_called == true
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Custom::PasswordsController < DeviseTokenAuth::PasswordsController
|
4
|
+
def create
|
5
|
+
super do |resource|
|
6
|
+
@create_block_called = true unless resource.nil?
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def edit
|
11
|
+
super do |resource|
|
12
|
+
@edit_block_called = true unless resource.nil?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def update
|
17
|
+
super do |resource|
|
18
|
+
@update_block_called = true unless resource.nil?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_block_called?
|
23
|
+
@create_block_called == true
|
24
|
+
end
|
25
|
+
|
26
|
+
def edit_block_called?
|
27
|
+
@edit_block_called == true
|
28
|
+
end
|
29
|
+
|
30
|
+
def update_block_called?
|
31
|
+
@update_block_called == true
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
|
36
|
+
def render_update_success
|
37
|
+
render json: { custom: 'foo' }
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Custom::RegistrationsController < DeviseTokenAuth::RegistrationsController
|
4
|
+
def create
|
5
|
+
super do |resource|
|
6
|
+
@create_block_called = true
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def update
|
11
|
+
super do |resource|
|
12
|
+
@update_block_called = true unless resource.nil?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def destroy
|
17
|
+
super do |resource|
|
18
|
+
@destroy_block_called = true unless resource.nil?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_block_called?
|
23
|
+
@create_block_called == true
|
24
|
+
end
|
25
|
+
|
26
|
+
def update_block_called?
|
27
|
+
@update_block_called == true
|
28
|
+
end
|
29
|
+
|
30
|
+
def destroy_block_called?
|
31
|
+
@destroy_block_called == true
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
|
36
|
+
def render_create_success
|
37
|
+
render json: { custom: 'foo' }
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Custom::SessionsController < DeviseTokenAuth::SessionsController
|
4
|
+
def create
|
5
|
+
super do |resource|
|
6
|
+
@create_block_called = true unless resource.nil?
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def destroy
|
11
|
+
super do |resource|
|
12
|
+
@destroy_block_called = true unless resource.nil?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_block_called?
|
17
|
+
@create_block_called == true
|
18
|
+
end
|
19
|
+
|
20
|
+
def destroy_block_called?
|
21
|
+
@destroy_block_called == true
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def render_create_success
|
27
|
+
render json: { custom: 'foo' }
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Custom::TokenValidationsController < DeviseTokenAuth::TokenValidationsController
|
4
|
+
def validate_token
|
5
|
+
super do |resource|
|
6
|
+
@validate_token_block_called = true unless resource.nil?
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def validate_token_block_called?
|
11
|
+
@validate_token_block_called == true
|
12
|
+
end
|
13
|
+
|
14
|
+
protected
|
15
|
+
|
16
|
+
def render_validate_token_success
|
17
|
+
render json: { custom: 'foo' }
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class DemoGroupController < ApplicationController
|
4
|
+
devise_token_auth_group :member, contains: [:user, :mang]
|
5
|
+
before_action :authenticate_member!
|
6
|
+
|
7
|
+
def members_only
|
8
|
+
render json: {
|
9
|
+
data: {
|
10
|
+
message: "Welcome #{current_member.name}",
|
11
|
+
user: current_member
|
12
|
+
}
|
13
|
+
}, status: 200
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class DemoMangController < ApplicationController
|
4
|
+
before_action :authenticate_mang!
|
5
|
+
|
6
|
+
def members_only
|
7
|
+
render json: {
|
8
|
+
data: {
|
9
|
+
message: "Welcome #{current_mang.name}",
|
10
|
+
user: current_mang
|
11
|
+
}
|
12
|
+
}, status: 200
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class DemoUserController < ApplicationController
|
4
|
+
before_action :authenticate_user!
|
5
|
+
|
6
|
+
def members_only
|
7
|
+
render json: {
|
8
|
+
data: {
|
9
|
+
message: "Welcome #{current_user.name}",
|
10
|
+
user: current_user
|
11
|
+
}
|
12
|
+
}, status: 200
|
13
|
+
end
|
14
|
+
|
15
|
+
def members_only_remove_token
|
16
|
+
u = User.find(current_user.id)
|
17
|
+
u.tokens = {}
|
18
|
+
u.save!
|
19
|
+
|
20
|
+
render json: {
|
21
|
+
data: {
|
22
|
+
message: "Welcome #{current_user.name}",
|
23
|
+
user: current_user
|
24
|
+
}
|
25
|
+
}, status: 200
|
26
|
+
end
|
27
|
+
end
|