devise_masquerade 0.6.5 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +5 -5
  2. data/.github/FUNDING.yml +1 -0
  3. data/.github/workflows/brakeman-analysis.yml +44 -0
  4. data/.github/workflows/rubocop-analysis.yml +39 -0
  5. data/.gitignore +1 -2
  6. data/.ruby-version +1 -1
  7. data/.travis.yml +2 -7
  8. data/Gemfile +16 -10
  9. data/Gemfile.lock +310 -0
  10. data/Makefile +6 -1
  11. data/README.md +57 -12
  12. data/app/controllers/devise/masquerades_controller.rb +119 -70
  13. data/devise_masquerade.gemspec +5 -4
  14. data/features/back.feature +15 -1
  15. data/features/expires_masquerade.feature +36 -0
  16. data/features/multiple_masquerading_models.feature +17 -0
  17. data/features/step_definitions/auth_steps.rb +8 -0
  18. data/features/step_definitions/back_steps.rb +22 -3
  19. data/features/step_definitions/expires_steps.rb +9 -0
  20. data/features/step_definitions/url_helpers_steps.rb +11 -0
  21. data/features/support/env.rb +23 -4
  22. data/features/url_helpers.feature +14 -0
  23. data/lib/devise_masquerade/controllers/helpers.rb +90 -9
  24. data/lib/devise_masquerade/controllers/url_helpers.rb +16 -2
  25. data/lib/devise_masquerade/models/masqueradable.rb +13 -0
  26. data/lib/devise_masquerade/models.rb +9 -0
  27. data/lib/devise_masquerade/rails.rb +14 -4
  28. data/lib/devise_masquerade/routes.rb +11 -8
  29. data/lib/devise_masquerade/version.rb +1 -1
  30. data/lib/devise_masquerade.rb +23 -9
  31. data/spec/controllers/admin/dashboard_controller_spec.rb +3 -4
  32. data/spec/controllers/dashboard_controller_spec.rb +3 -5
  33. data/spec/controllers/devise/masquerades_controller_spec.rb +80 -38
  34. data/spec/controllers/masquerades_tests_controller_spec.rb +57 -0
  35. data/spec/dummy/app/controllers/admin/dashboard_controller.rb +1 -2
  36. data/spec/dummy/app/controllers/application_controller.rb +2 -0
  37. data/spec/dummy/app/controllers/dashboard_controller.rb +5 -2
  38. data/spec/dummy/app/controllers/masquerades_tests_controller.rb +7 -0
  39. data/spec/dummy/app/controllers/students_controller.rb +8 -0
  40. data/spec/dummy/app/models/admin/user.rb +0 -7
  41. data/spec/dummy/app/models/student.rb +3 -0
  42. data/spec/dummy/app/models/user.rb +1 -10
  43. data/spec/dummy/app/views/admin/dashboard/index.html.erb +0 -2
  44. data/spec/dummy/app/views/dashboard/extra_params.html.erb +7 -0
  45. data/spec/dummy/app/views/dashboard/index.html.erb +0 -2
  46. data/spec/dummy/app/views/layouts/application.html.erb +10 -2
  47. data/spec/dummy/app/views/students/_student.html.erb +6 -0
  48. data/spec/dummy/app/views/students/index.html.erb +1 -0
  49. data/spec/dummy/app/views/users/_user.html.erb +1 -1
  50. data/spec/dummy/config/application.rb +2 -0
  51. data/spec/dummy/config/environment.rb +1 -0
  52. data/spec/dummy/config/routes.rb +9 -5
  53. data/spec/dummy/db/.gitignore +1 -0
  54. data/spec/dummy/db/migrate/20121119085620_devise_create_users.rb +1 -1
  55. data/spec/dummy/db/migrate/20140418160449_create_admin_users.rb +1 -1
  56. data/spec/dummy/db/migrate/20191022100000_create_students.rb +14 -0
  57. data/spec/dummy/db/schema.rb +37 -31
  58. data/spec/models/user_spec.rb +3 -30
  59. data/spec/orm/active_record.rb +5 -2
  60. data/spec/spec_helper.rb +3 -3
  61. data/spec/support/factories.rb +13 -9
  62. metadata +61 -19
  63. data/lib/devise_masquerade/model.rb +0 -42
  64. data/spec/controllers/masquerades_controller_spec.rb +0 -42
  65. data/spec/dummy/app/controllers/masquerades_controller.rb +0 -5
@@ -0,0 +1,13 @@
1
+ module DeviseMasquerade
2
+ module Models
3
+ module Masqueradable
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ def masquerade_key
8
+ to_sgid(expires_in: Devise.masquerade_expires_in, for: 'masquerade')
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ require 'devise_masquerade/models/masqueradable'
2
+
3
+ module DeviseMasquerade
4
+ module Models
5
+
6
+ end
7
+ end
8
+
9
+ Devise::Models.send :include, DeviseMasquerade::Models
@@ -1,7 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module DeviseMasquerade
2
- class Engine < ::Rails::Engine
3
- ActiveSupport.on_load(:action_controller) { include DeviseMasquerade::Controllers::UrlHelpers }
4
- ActiveSupport.on_load(:action_view) { include DeviseMasquerade::Controllers::UrlHelpers }
4
+ module Rails
5
+
6
+ class Engine < ::Rails::Engine
7
+ initializer "devise.url_helpers" do
8
+ Devise.include_helpers(DeviseMasquerade::Controllers)
9
+ end
10
+
11
+ ActiveSupport.on_load(:action_controller) do
12
+ include DeviseMasquerade::Controllers::Helpers
13
+ end
14
+ end
15
+
5
16
  end
6
17
  end
7
-
@@ -1,17 +1,20 @@
1
- module ActionDispatch::Routing
2
- class Mapper
3
-
4
- protected
1
+ module DeviseMasquerade
2
+ module Routes
5
3
 
6
4
  def devise_masquerade(mapping, controllers)
7
5
  resources :masquerade,
8
- :only => :show,
9
- :path => mapping.path_names[:masquerade],
10
- :controller => controllers[:masquerades] do
6
+ path: mapping.path_names[:masquerade],
7
+ controller: controllers[:masquerades],
8
+ only: [] do
11
9
 
12
- get :back, :on => :collection
10
+ collection do
11
+ get :show
12
+ get :back
13
+ end
13
14
  end
14
15
  end
16
+
15
17
  end
16
18
  end
17
19
 
20
+ ActionDispatch::Routing::Mapper.send :include, DeviseMasquerade::Routes
@@ -1,3 +1,3 @@
1
1
  module DeviseMasquerade
2
- VERSION = '0.6.5'.freeze
2
+ VERSION = '2.1.0'.freeze
3
3
  end
@@ -1,22 +1,16 @@
1
1
  require 'devise'
2
-
3
- require 'action_controller'
4
- require 'action_controller/base'
5
2
  require 'devise_masquerade/version'
6
3
  require 'devise_masquerade/routes'
7
4
  require 'devise_masquerade/controllers/helpers'
8
5
  require 'devise_masquerade/controllers/url_helpers'
9
6
  require 'devise_masquerade/rails'
10
7
 
11
- module DeviseMasquerade
12
- end
13
-
14
8
  module Devise
15
9
  mattr_accessor :masquerade_param
16
10
  @@masquerade_param = 'masquerade'
17
11
 
18
12
  mattr_accessor :masquerade_expires_in
19
- @@masquerade_expires_in = 10.seconds
13
+ @@masquerade_expires_in = 1.minute
20
14
 
21
15
  mattr_accessor :masquerade_key_size
22
16
  @@masquerade_key_size = 16
@@ -30,17 +24,37 @@ module Devise
30
24
  # Example: Devise.masqueraded_resource_class = User
31
25
  mattr_accessor :masqueraded_resource_class
32
26
 
27
+ # Example: Devise.masqueraded_resource_class_name = 'User'
28
+ mattr_accessor :masqueraded_resource_class_name
29
+
33
30
  # Example: Devise.masqueraded_resource_name = :user
34
31
  mattr_accessor :masqueraded_resource_name
35
32
 
36
33
  # Example: Devise.masquerading_resource_class = AdminUser
37
34
  mattr_accessor :masquerading_resource_class
38
35
 
36
+ # Example: Devise.masquerading_resource_class_name = 'AdminUser'
37
+ mattr_accessor :masquerading_resource_class_name
38
+
39
39
  # Example: Devise.masquerading_resource_name = :admin_user
40
40
  mattr_accessor :masquerading_resource_name
41
41
 
42
+ # Example: Devise.masquerade_storage_method = :session
43
+ # - session
44
+ # - cache
45
+ mattr_accessor :masquerade_storage_method
46
+ @@masquerade_storage_method = :session
47
+
48
+ def self.masquerade_storage_method_session?
49
+ Devise.masquerade_storage_method == :session
50
+ end
51
+
52
+ def self.masquerade_storage_method_cache?
53
+ Devise.masquerade_storage_method == :cache
54
+ end
55
+
42
56
  @@helpers << DeviseMasquerade::Controllers::Helpers
43
57
  end
44
58
 
45
- Devise.add_module :masqueradable, :controller => :masquerades,
46
- :model => 'devise_masquerade/model', :route => :masquerade
59
+ Devise.add_module :masqueradable, controller: :masquerades,
60
+ model: 'devise_masquerade/models', route: :masquerade
@@ -5,14 +5,13 @@ describe Admin::DashboardController, type: :controller do
5
5
  before { admin_logged_in }
6
6
 
7
7
  context 'and admin masquerade by user' do
8
- let!(:user) { create(:admin_user) }
8
+ let!(:mask) { create(:admin_user) }
9
9
 
10
10
  before do
11
- user.masquerade!
12
- get :index, :masquerade => user.masquerade_key
11
+ get :index, params: { masquerade: mask.masquerade_key, masqueraded_resource_class: 'Admin::User' }
13
12
  end
14
13
 
15
- it { expect(current_admin_user.reload).to eq(user) }
14
+ it { expect(current_admin_user.reload).to eq(mask) }
16
15
  end
17
16
  end
18
17
  end
@@ -5,15 +5,13 @@ describe DashboardController, type: :controller do
5
5
  before { logged_in }
6
6
 
7
7
  context 'and admin masquerade by user' do
8
- let!(:user) { create(:user) }
8
+ let!(:mask) { create(:user) }
9
9
 
10
10
  before do
11
- user.masquerade!
12
-
13
- get :index, :masquerade => user.masquerade_key
11
+ get :index, params: { masquerade: mask.masquerade_key }
14
12
  end
15
13
 
16
- it { expect(current_user.reload).to eq(user) }
14
+ it { expect(current_user.reload).to eq(mask) }
17
15
  end
18
16
  end
19
17
  end
@@ -1,9 +1,31 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Devise::MasqueradesController, type: :controller do
4
+ before { Devise.masquerade_storage_method = :cache }
5
+ after { Devise.masquerade_storage_method = :session }
6
+
4
7
  context 'with configured devise app' do
5
8
  before { @request.env['devise.mapping'] = Devise.mappings[:user] }
6
9
 
10
+ context 'when logged in' do
11
+ before { logged_in }
12
+
13
+ context 'with masqueradable_class param' do
14
+ let(:mask) { create(:student) }
15
+
16
+ before do
17
+ get :show, params: { id: mask.id, masqueraded_resource_class: mask.class.name, masquerade: mask.masquerade_key }
18
+ end
19
+
20
+ it { expect(cache_read(mask)).to be }
21
+
22
+ it 'should have warden keys defined' do
23
+ expect(session["warden.user.student.key"].first.first).to eq(mask.id)
24
+ end
25
+
26
+ it { should redirect_to('/') }
27
+ end
28
+ end
7
29
  context 'when logged in' do
8
30
  before { logged_in }
9
31
 
@@ -11,69 +33,77 @@ describe Devise::MasqueradesController, type: :controller do
11
33
  let(:mask) { create(:user) }
12
34
 
13
35
  before do
14
- expect(SecureRandom).to receive(:urlsafe_base64) { "secure_key" }
15
- get :show, :id => mask.to_param
36
+ get :show, params: { id: mask.id, masquerade: mask.masquerade_key }
16
37
  end
17
38
 
18
- it { expect(session.keys).to include('devise_masquerade_user') }
39
+ it { expect(cache_read(mask)).to be }
19
40
  it { expect(session["warden.user.user.key"].first.first).to eq(mask.id) }
20
- it { should redirect_to("/?masquerade=secure_key") }
41
+ it { should redirect_to('/') }
21
42
 
22
43
  context 'and back' do
23
44
  before { get :back }
24
45
 
25
46
  it { should redirect_to(masquerade_page) }
26
47
  it { expect(current_user.reload).to eq(@user) }
27
- it { expect(session.keys).not_to include('devise_masquerade_user') }
48
+ it { expect(cache_read(mask)).not_to be }
28
49
  end
50
+ end
29
51
 
30
- # Configure masquerade_routes_back setting
31
- describe 'config#masquerade_routes_back' do
32
- before { Devise.setup {|c| c.masquerade_routes_back = true } }
52
+ # Configure masquerade_routes_back setting
53
+ describe 'config#masquerade_routes_back' do
54
+ let(:mask) { create(:user) }
33
55
 
34
- context 'show' do
35
- before { expect(SecureRandom).to receive(:urlsafe_base64) { "secure_key" } }
56
+ before { Devise.setup { |c| c.masquerade_routes_back = true } }
36
57
 
37
- context '< Rails 5 version' do
38
- before do
39
- @request.env['HTTP_REFERER'] = 'previous_location'
40
- get :show, id: mask.to_param
41
- end # before
58
+ after { Devise.masquerade_routes_back = false }
42
59
 
43
- it { should redirect_to('previous_location') }
44
- end # context
60
+ context 'show' do
61
+ context 'with http referrer' do
62
+ before do
63
+ @request.env['HTTP_REFERER'] = 'previous_location'
64
+ get :show, params: { id: mask.id, masquerade: mask.masquerade_key }
65
+ end # before
45
66
 
46
- context '< Rails 5, fallback if http_referer not present' do
47
- before do
48
- allow_any_instance_of(described_class).to receive(:after_masquerade_path_for).and_return("/dashboard?color=red")
49
- end
67
+ it { should redirect_to('previous_location') }
68
+ end # context
50
69
 
51
- before { get :show, id: mask.to_param }
70
+ context 'no http referrer' do
71
+ before do
72
+ allow_any_instance_of(described_class).to(
73
+ receive(:after_masquerade_path_for).and_return("/dashboard?color=red"))
74
+ end
75
+
76
+ before { get :show, params: { id: mask.id, masquerade: mask.masquerade_key } }
52
77
 
53
- it { should redirect_to("/dashboard?color=red&masquerade=secure_key") }
54
- end # context
78
+ it { should redirect_to("/dashboard?color=red") }
55
79
  end # context
80
+ end # context
56
81
 
57
- context '< Rails 5, and back' do
58
- before { get :back }
82
+ context 'and back' do
83
+ before do
84
+ get :show, params: { id: mask.id, masquerade: mask.masquerade_key }
59
85
 
60
- it { should redirect_to(masquerade_page) }
61
- end # context
86
+ get :back
87
+ end
62
88
 
63
- context '< Rails 5, and back fallback if http_referer not present' do
64
- before do
65
- @request.env['HTTP_REFERER'] = 'previous_location'
66
- get :back
67
- end
89
+ it { should redirect_to(masquerade_page) }
90
+ end # context
68
91
 
69
- it { should redirect_to('previous_location') }
70
- end # context
71
- end # describe
72
- end
92
+ context 'and back fallback if http_referer not present' do
93
+ before do
94
+ get :show, params: { id: mask.id, masquerade: mask.masquerade_key }
95
+
96
+ @request.env['HTTP_REFERER'] = 'previous_location'
97
+ get :back
98
+ end
99
+
100
+ it { should redirect_to('previous_location') }
101
+ end # context
102
+ end # describe
73
103
  end
74
104
 
75
105
  context 'when not logged in' do
76
- before { get :show, :id => 'any_id' }
106
+ before { get :show, params: { id: 'any_id' } }
77
107
 
78
108
  it { should redirect_to(new_user_session_path) }
79
109
  end
@@ -83,4 +113,16 @@ describe Devise::MasqueradesController, type: :controller do
83
113
  def masquerade_page
84
114
  "/"
85
115
  end
116
+
117
+ def guid
118
+ session[:devise_masquerade_masquerading_resource_guid]
119
+ end
120
+
121
+ def cache_read(user)
122
+ Rails.cache.read(cache_key(user))
123
+ end
124
+
125
+ def cache_key(user)
126
+ "devise_masquerade_#{mask.class.name.downcase}_#{mask.id}_#{guid}"
127
+ end
86
128
  end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe MasqueradesTestsController, type: :controller do
4
+ before { Devise.masquerade_storage_method = :cache }
5
+ after { Devise.masquerade_storage_method = :session }
6
+
7
+ before { @request.env['devise.mapping'] = Devise.mappings[:user] }
8
+
9
+ context 'no access for masquerade' do
10
+ before do
11
+ session.clear
12
+ allow_any_instance_of(MasqueradesTestsController).to receive(:masquerade_authorized?) { false }
13
+ end
14
+
15
+ before { logged_in }
16
+
17
+ let(:mask) { create(:user) }
18
+
19
+ before { get :show, params: { id: mask.id, masquerade: mask.masquerade_key } }
20
+
21
+ it { expect(response.status).to eq(403) }
22
+ it { expect(cache_read(mask)).not_to be }
23
+ it { expect(session['warden.user.user.key'].first.first).not_to eq(mask.id) }
24
+ end
25
+
26
+ context 'access for masquerade' do
27
+ before do
28
+ session.clear
29
+ allow_any_instance_of(MasqueradesTestsController).to receive(:masquerade_authorized?) { true }
30
+ end
31
+
32
+ before { logged_in }
33
+
34
+ let(:mask) { create(:user) }
35
+
36
+ before do
37
+ get :show, params: { id: mask.id, masquerade: mask.masquerade_key }
38
+ end
39
+
40
+ it { expect(response.status).to eq(302) }
41
+ it { expect(cache_read(mask)).to be }
42
+ it { expect(session['warden.user.user.key'].first.first).to eq(mask.id) }
43
+ end
44
+
45
+
46
+ def guid
47
+ session[:devise_masquerade_masquerading_resource_guid]
48
+ end
49
+
50
+ def cache_read(user)
51
+ Rails.cache.read(cache_key(user))
52
+ end
53
+
54
+ def cache_key(user)
55
+ "devise_masquerade_#{mask.class.name.downcase}_#{mask.id}_#{guid}"
56
+ end
57
+ end
@@ -1,6 +1,5 @@
1
1
  class Admin::DashboardController < ApplicationController
2
- before_filter :authenticate_admin_user!
3
- before_filter :masquerade_admin_user!
2
+ before_action :authenticate_admin_user!
4
3
 
5
4
  def index
6
5
  @users = Admin::User.where("admin_users.id != ?", current_admin_user.id).all
@@ -1,4 +1,6 @@
1
1
  class ApplicationController < ActionController::Base
2
+ before_action :masquerade!
3
+
2
4
  protect_from_forgery
3
5
  end
4
6
 
@@ -1,9 +1,12 @@
1
1
  class DashboardController < ApplicationController
2
- before_filter :authenticate_user!
3
- before_filter :masquerade_user!
2
+ before_action :authenticate_user!
4
3
 
5
4
  def index
6
5
  @users = User.where("users.id != ?", current_user.id).all
7
6
  end
7
+
8
+ def extra_params
9
+ @users = User.where("users.id != ?", current_user.id).all
10
+ end
8
11
  end
9
12
 
@@ -0,0 +1,7 @@
1
+ class MasqueradesTestsController < Devise::MasqueradesController
2
+ before_action :authenticate_user!
3
+
4
+ def show
5
+ super
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ class StudentsController < ApplicationController
2
+ before_action :authenticate_user!
3
+
4
+ def index
5
+ @students = Student.all
6
+ end
7
+ end
8
+
@@ -1,13 +1,6 @@
1
1
  class Admin::User < ActiveRecord::Base
2
- # Include default devise modules. Others available are:
3
- # :token_authenticatable, :confirmable,
4
- # :lockable, :timeoutable and :omniauthable
5
2
  devise :database_authenticatable, :registerable,
6
3
  :recoverable, :rememberable, :trackable, :validatable,
7
4
  :masqueradable
8
-
9
- # Setup accessible (or protected) attributes for your model
10
- attr_accessible :email, :password, :password_confirmation, :remember_me
11
- # attr_accessible :title, :body
12
5
  end
13
6
 
@@ -0,0 +1,3 @@
1
+ class Student < ActiveRecord::Base
2
+ devise :database_authenticatable, :validatable, :masqueradable
3
+ end
@@ -1,12 +1,3 @@
1
1
  class User < ActiveRecord::Base
2
- # Include default devise modules. Others available are:
3
- # :token_authenticatable, :confirmable,
4
- # :lockable, :timeoutable and :omniauthable
5
- devise :database_authenticatable, :registerable,
6
- :recoverable, :rememberable, :trackable, :validatable,
7
- :masqueradable
8
-
9
- # Setup accessible (or protected) attributes for your model
10
- attr_accessible :email, :password, :password_confirmation, :remember_me
11
- # attr_accessible :title, :body
2
+ devise :database_authenticatable, :validatable, :masqueradable
12
3
  end
@@ -1,3 +1 @@
1
- <h1>Users</h1>
2
-
3
1
  <%= render @users %>
@@ -0,0 +1,7 @@
1
+ <% @users.each do |user| %>
2
+ <p>
3
+ <%= user.email %>
4
+
5
+ <%= link_to "Login as", masquerade_path(user, key1: 'value1'), class: 'login_as' %>
6
+ </p>
7
+ <% end %>
@@ -1,3 +1 @@
1
- <h1>Users</h1>
2
-
3
1
  <%= render @users %>
@@ -8,10 +8,18 @@
8
8
  </head>
9
9
  <body>
10
10
  <% if signed_in? %>
11
- <h1 class='current_user'><%= current_user.email %></h1>
11
+ <% if user_signed_in? %>
12
+ <h1 class='current_user'><%= current_user.email %></h1>
13
+ <% end %>
14
+
15
+ <% if student_signed_in? %>
16
+ <h1 class='current_student'><%= current_student.email %></h1>
17
+ <% end %>
12
18
 
13
19
  <% if user_masquerade? %>
14
- <%= link_to "Back masquerade", back_masquerade_path(current_user) %>
20
+ <h1 class='owner_user'><%= user_masquerade_owner.email %></h1>
21
+
22
+ <%= link_to "Back masquerade", back_masquerade_path(User.new) %>
15
23
  <% end %>
16
24
  <% end %>
17
25
 
@@ -0,0 +1,6 @@
1
+ <p>
2
+ <%= student.email %>
3
+
4
+ <%= link_to "Login as", masquerade_path(student), class: 'login_as' %>
5
+ </p>
6
+
@@ -0,0 +1 @@
1
+ <%= render @students %>
@@ -1,6 +1,6 @@
1
1
  <p>
2
2
  <%= user.email %>
3
3
 
4
- <%= link_to "Login as", masquerade_path(user) %>
4
+ <%= link_to "Login as", masquerade_path(user), class: 'login_as' %>
5
5
  </p>
6
6
 
@@ -16,6 +16,8 @@ module Dummy
16
16
  config.encoding = "utf-8"
17
17
 
18
18
  config.filter_parameters += [:password]
19
+
20
+ config.eager_load = false
19
21
  end
20
22
  end
21
23
 
@@ -2,4 +2,5 @@
2
2
  require File.expand_path('../application', __FILE__)
3
3
 
4
4
  # Initialize the rails application
5
+ #
5
6
  Dummy::Application.initialize!
@@ -1,12 +1,16 @@
1
1
  Dummy::Application.routes.draw do
2
- devise_for :users, controllers: { masquerades: "users/masquerades" }
3
- devise_for :admin_users, :class_name => 'Admin::User'
2
+ devise_for :users, controllers: { masquerades: 'users/masquerades' }
3
+ devise_for :admin_users, class_name: Admin::User.name
4
+ devise_for :students, class_name: Student.name
4
5
 
5
- root :to => 'dashboard#index'
6
+ root to: 'dashboard#index'
6
7
 
7
- resources :masquerades
8
+ get '/extra_params', to: 'dashboard#extra_params'
9
+
10
+ resources :masquerades_tests
11
+ resources :students, only: :index
8
12
 
9
13
  namespace :admin do
10
- root :to => 'dashboard#index'
14
+ root to: 'dashboard#index'
11
15
  end
12
16
  end
@@ -0,0 +1 @@
1
+ test.sqlite3*
@@ -1,4 +1,4 @@
1
- class DeviseCreateUsers < ActiveRecord::Migration
1
+ class DeviseCreateUsers < ActiveRecord::Migration[5.2]
2
2
  def change
3
3
  create_table(:users) do |t|
4
4
  ## Database authenticatable
@@ -1,4 +1,4 @@
1
- class CreateAdminUsers < ActiveRecord::Migration
1
+ class CreateAdminUsers < ActiveRecord::Migration[5.2]
2
2
  def change
3
3
  create_table(:admin_users) do |t|
4
4
  ## Database authenticatable
@@ -0,0 +1,14 @@
1
+ class CreateStudents < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table(:students) do |t|
4
+ t.string :email, null: false, default: ''
5
+ t.string :encrypted_password, null: false, default: ''
6
+
7
+ t.timestamps
8
+ end
9
+
10
+ add_index :students, :email, unique: true
11
+ add_index :students, :reset_password_token, unique: true
12
+ end
13
+ end
14
+