-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add routing constraints for admins and authenticated users
- Loading branch information
Showing
7 changed files
with
41 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,18 @@ | ||
class MainController < ApplicationController | ||
allow_unauthenticated_access only: [:about] | ||
Check failure on line 2 in app/controllers/main_controller.rb GitHub Actions / lint
|
||
|
||
def index | ||
end | ||
|
||
def admin | ||
render plain: "Admin area" | ||
end | ||
|
||
def dashboard | ||
render plain: "Dashboard" | ||
end | ||
|
||
def about | ||
render plain: "About" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,7 @@ | ||
class Current < ActiveSupport::CurrentAttributes | ||
attribute :session | ||
# delegate :user, to: :session, allow_nil: true | ||
|
||
attribute :impersonated_user | ||
|
||
def user | ||
impersonated_user || true_user | ||
end | ||
|
||
def true_user | ||
session&.user | ||
end | ||
def user = impersonated_user || true_user | ||
def true_user = session&.user | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddAdminToUsers < ActiveRecord::Migration[8.0] | ||
def change | ||
add_column :users, :admin, :boolean | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.