-
-
Notifications
You must be signed in to change notification settings - Fork 934
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract verified session logic into a concern
It was being duplicated a lot
- Loading branch information
Showing
7 changed files
with
73 additions
and
47 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
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,29 @@ | ||
module SessionVerifiable | ||
extend ActiveSupport::Concern | ||
|
||
class_methods do | ||
def verify_session_before(**opts) | ||
before_action :redirect_to_signin, **opts, unless: :signed_in? | ||
before_action :redirect_to_new_mfa, **opts, if: :mfa_required_not_yet_enabled? | ||
before_action :redirect_to_settings_strong_mfa_required, **opts, if: :mfa_required_weak_level_enabled? | ||
before_action :redirect_to_verify, **opts, unless: :password_session_active? | ||
end | ||
end | ||
|
||
private | ||
|
||
def verify_session_redirect_path | ||
redirect_uri = request.path_info | ||
redirect_uri += "?#{request.query_string}" if request.query_string.present? | ||
redirect_uri | ||
end | ||
|
||
included do | ||
private | ||
|
||
def redirect_to_verify | ||
session[:redirect_uri] = verify_session_redirect_path | ||
redirect_to verify_session_path | ||
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