Browse Source

Admi Users must sign in to access panel

pull/104/head
baarkerlounger 4 years ago
parent
commit
95bd321edd
  1. 5
      app/models/admin_user.rb
  2. 4
      config/initializers/active_admin.rb
  3. 1
      config/routes.rb
  4. 18
      db/migrate/20211119120910_add_admin_users.rb
  5. 14
      db/schema.rb
  6. 1
      db/seeds.rb

5
app/models/admin_user.rb

@ -0,0 +1,5 @@
class AdminUser < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :recoverable, :rememberable, :validatable
end

4
config/initializers/active_admin.rb

@ -54,7 +54,7 @@ ActiveAdmin.setup do |config|
#
# This setting changes the method which Active Admin calls
# within the application controller.
# config.authentication_method = :authenticate_admin_user!
config.authentication_method = :authenticate_admin_user!
# == User Authorization
#
@ -91,7 +91,7 @@ ActiveAdmin.setup do |config|
#
# This setting changes the method which Active Admin calls
# (within the application controller) to return the currently logged in user.
# config.current_user_method = :current_admin_user
config.current_user_method = :current_admin_user
# == Logging Out
#

1
config/routes.rb

@ -1,4 +1,5 @@
Rails.application.routes.draw do
devise_for :admin_users, ActiveAdmin::Devise.config
devise_for :users, controllers: { passwords: "users/passwords" }
devise_scope :user do
get "confirmations/reset", to: "users/passwords#reset_confirmation"

18
db/migrate/20211119120910_add_admin_users.rb

@ -0,0 +1,18 @@
class AddAdminUsers < ActiveRecord::Migration[6.1]
def change
create_table :admin_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
t.timestamps null: false
end
end
end

14
db/schema.rb

@ -10,11 +10,21 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_11_18_090831) do
ActiveRecord::Schema.define(version: 2021_11_19_120910) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "admin_users", force: :cascade 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.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
create_table "case_logs", force: :cascade do |t|
t.integer "status", default: 0
t.datetime "created_at", precision: 6, null: false
@ -88,7 +98,6 @@ ActiveRecord::Schema.define(version: 2021_11_18_090831) do
t.integer "tcharge"
t.integer "layear"
t.integer "lawaitlist"
t.string "property_postcode"
t.integer "reasonpref"
t.string "reasonable_preference_reason"
t.integer "cbl"
@ -153,6 +162,7 @@ ActiveRecord::Schema.define(version: 2021_11_18_090831) do
t.datetime "sale_completion_date"
t.datetime "startdate"
t.integer "armedforces"
t.string "property_postcode"
t.index ["discarded_at"], name: "index_case_logs_on_discarded_at"
end

1
db/seeds.rb

@ -7,3 +7,4 @@
# Character.create(name: 'Luke', movie: movies.first)
User.create!(email: "test@example.com", password: "password")
AdminUser.create!(email: "admin@example.com", password: "password")

Loading…
Cancel
Save