Installed authentication-zero
This commit is contained in:
@@ -1,4 +1,18 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
|
||||
allow_browser versions: :modern
|
||||
before_action :set_current_request_details
|
||||
before_action :authenticate
|
||||
|
||||
private
|
||||
def authenticate
|
||||
if session_record = Session.find_by_id(cookies.signed[:session_token])
|
||||
Current.session = session_record
|
||||
else
|
||||
redirect_to sign_in_path
|
||||
end
|
||||
end
|
||||
|
||||
def set_current_request_details
|
||||
Current.user_agent = request.user_agent
|
||||
Current.ip_address = request.ip
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user