-
Notifications
You must be signed in to change notification settings - Fork 0
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 #257 from iaebots/256-fix-cross-models-visits
Fix cross models visits
- Loading branch information
Showing
5 changed files
with
30 additions
and
0 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,24 @@ | ||
# frozen_string_literal: true | ||
|
||
# This module will handle cross models visits. | ||
# i.e. a guest cannot visit some developers views (such as sign-in) when logged-in | ||
# as guest, and viceversa. They will be redirected to feed. | ||
# This avoid a user logging-in twice as two different model (and messing with tokens). | ||
module Accessible | ||
extend ActiveSupport::Concern | ||
included do | ||
before_action :check_user | ||
end | ||
|
||
protected | ||
|
||
def check_user | ||
if current_guest | ||
flash.clear | ||
redirect_to(posts_path) and return | ||
elsif current_developer | ||
flash.clear | ||
redirect_to(posts_path) and return | ||
end | ||
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
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