-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from realstorypro/access-control
added access control to the homepage
- Loading branch information
Showing
6 changed files
with
29 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module RestrictedAccess | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
before_action :authenticate_user! | ||
before_action :check_access | ||
end | ||
|
||
private | ||
|
||
def check_access | ||
redirect_to unauthorized_index_path unless current_user.has_access? | ||
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,6 +1,6 @@ | ||
class PageController < ApplicationController | ||
before_action :authenticate_user! | ||
|
||
include RestrictedAccess | ||
def index | ||
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class UnauthorizedController < ApplicationController | ||
def index | ||
redirect_to root_path if current_user.has_access? | ||
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
=r ux.container | ||
=r ux.row | ||
=r ux.column size: 16, class: 'pt-20' | ||
=r ux.h1 text: 'Unauthorized', class: 'center aligned' | ||
=r ux.text text: 'You are not authorized to access this page.', class: 'text-center' |
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