module Phcscriptcdnpro class ApplicationController < ActionController::Base # Security Filters protect_from_forgery with: :exception # Load Helpers for PHCPress Widgets before_action :phcpress_recent_posts # Load Helpers helper Phctitleseo::Engine.helpers helper Phcnotifi::Engine.helpers helper Phcaccountspro::Engine.helpers # AuthRocket Definitions def require_user unless current_user params.permit! session[:last_url] = request.get? ? url_for(params) : url_for redirect_to new_login_url end end def current_user @_current_user ||= AuthRocket::Session.from_token(session[:ar_token]).try(:user) end helper_method :current_user def new_login_url ENV['AUTHROCKET_LOGIN_URL'] end helper_method :new_login_url def authrocket_membership_info AuthRocket::Membership.all(user_id: current_user.id).first end # Papertrail Whodunnit Username def user_for_paper_trail # Default is: current_user rescue nil current_user ? current_user.username : 'Public user' end private # PHCPress Widget Helpers def phcpress_recent_posts @recent_posts = Phcpresspro::Articles::Post.all end end end