Add auth and ruby update
This commit is contained in:
parent
5d50194f39
commit
fbf6923835
43 changed files with 614 additions and 64 deletions
|
|
@ -4,6 +4,7 @@ class ApplicationController < ActionController::Base
|
|||
include Pagy::Backend
|
||||
|
||||
# allow_browser versions: :modern
|
||||
helper_method :sidebar?
|
||||
|
||||
before_action :initialize_navbar
|
||||
|
||||
|
|
@ -12,15 +13,26 @@ class ApplicationController < ActionController::Base
|
|||
def initialize_navbar
|
||||
return unless request.get?
|
||||
|
||||
@navbar_items = [
|
||||
{ label: "Dashboard", icon: :speedometer2, path: :root },
|
||||
{ label: Report.model_name.human(count: 2), icon: :'journal-text', path: :reports },
|
||||
{ label: Checklist.model_name.human(count: 2), icon: :'list-check', path: :checklists },
|
||||
{ label: Check.model_name.human(count: 2), icon: :check2, path: :checks },
|
||||
{ label: Link.model_name.human(count: 2), icon: :link, path: :links },
|
||||
{ label: LinkCategory.model_name.human(count: 2), icon: :folder, path: :link_categories }
|
||||
]
|
||||
@navbar_items = if rodauth.logged_in?
|
||||
[
|
||||
{ label: "Dashboard", icon: :speedometer2, path: :root },
|
||||
{ label: Report.model_name.human(count: 2), icon: :'journal-text', path: :reports },
|
||||
{ label: I18n.t("backoffice"), icon: :gear, path: :backoffice, active: %w[backoffice checklists checks links link_categories].include?(controller_name) },
|
||||
{ label: Account.model_name.human, icon: :person, path: profile_path }
|
||||
]
|
||||
else
|
||||
[ { label: "Login", icon: :'door-closed', path: rodauth.login_path, label_class: "text-info" } ]
|
||||
end
|
||||
@nav_path = controller_name
|
||||
@search_url = nil
|
||||
@sidebar_items = initialize_sidebar_items
|
||||
end
|
||||
|
||||
def sidebar?
|
||||
@sidebar_items && @sidebar_items.any?
|
||||
end
|
||||
|
||||
def initialize_sidebar_items
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
|
|
|||
6
app/controllers/backoffice_controller.rb
Normal file
6
app/controllers/backoffice_controller.rb
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
class BackofficeController < ApplicationController
|
||||
include BackofficeMenu
|
||||
|
||||
def show
|
||||
end
|
||||
end
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ChecklistsController < ApplicationController
|
||||
include BackofficeMenu
|
||||
|
||||
before_action :set_checklist, only: %i[show edit update destroy]
|
||||
|
||||
# GET /checklists
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ChecksController < ApplicationController
|
||||
include BackofficeMenu
|
||||
|
||||
before_action :set_check, only: %i[show edit update destroy]
|
||||
|
||||
# GET /checks or /checks.json
|
||||
|
|
|
|||
12
app/controllers/concerns/backoffice_menu.rb
Normal file
12
app/controllers/concerns/backoffice_menu.rb
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
module BackofficeMenu
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def initialize_sidebar_items
|
||||
[
|
||||
{ label: "Einstellungen", icon: :sliders, path: :backoffice },
|
||||
{ label: Checklist.model_name.human(count: 2), icon: :'list-check', path: :checklists },
|
||||
{ label: Check.model_name.human(count: 2), icon: :check2, path: :checks },
|
||||
{ label: Link.model_name.human(count: 2), icon: :link, path: :links },
|
||||
{ label: LinkCategory.model_name.human(count: 2), icon: :folder, path: :link_categories } ]
|
||||
end
|
||||
end
|
||||
|
|
@ -2,5 +2,9 @@
|
|||
|
||||
class HomeController < ApplicationController
|
||||
def show
|
||||
if rodauth.logged_in?
|
||||
else
|
||||
render :root
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class LinkCategoriesController < ApplicationController
|
||||
include BackofficeMenu
|
||||
|
||||
before_action :set_link_category, only: %i[show edit update destroy]
|
||||
|
||||
# GET /link_categories
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class LinksController < ApplicationController
|
||||
include BackofficeMenu
|
||||
|
||||
before_action :set_link, only: %i[show edit update destroy]
|
||||
|
||||
# GET /links
|
||||
|
|
|
|||
37
app/controllers/rodauth_controller.rb
Normal file
37
app/controllers/rodauth_controller.rb
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
class RodauthController < ApplicationController
|
||||
# Used by Rodauth for rendering views, CSRF protection, running any
|
||||
# registered action callbacks and rescue handlers, instrumentation etc.
|
||||
|
||||
# Controller callbacks and rescue handlers will run around Rodauth endpoints.
|
||||
# before_action :verify_captcha, only: :login, if: -> { request.post? }
|
||||
# rescue_from("SomeError") { |exception| ... }
|
||||
|
||||
# Layout can be changed for all Rodauth pages or only certain pages.
|
||||
# layout "authentication"
|
||||
# layout -> do
|
||||
# case rodauth.current_route
|
||||
# when :login, :create_account, :verify_account, :verify_account_resend,
|
||||
# :reset_password, :reset_password_request
|
||||
# "authentication"
|
||||
# else
|
||||
# "application"
|
||||
# end
|
||||
# end
|
||||
#
|
||||
before_action do
|
||||
# Fix encoding in rodauth views.
|
||||
response.headers["Content-Type"] = "text/html; charset=utf-8" if request.format.html?
|
||||
end
|
||||
|
||||
def profile
|
||||
end
|
||||
|
||||
private
|
||||
def initialize_sidebar_items
|
||||
[
|
||||
{ label: "Profile", icon: :'person', path: profile_path, active: action_name == "profile" },
|
||||
{ label: "Passwort ändern", icon: :'lock', path: rodauth.change_password_path, active: action_name == "change_password" },
|
||||
{ label: "Logout", icon: :'box-arrow-right', path: rodauth.logout_path, active: action_name == "logout" }
|
||||
]
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue