Sha256: b62a0718811bd54e47c2d5a87145c7ffbe04d6b9f9bf9bf6199e27be9b5b7f1a
Contents?: true
Size: 1 KB
Versions: 2
Compression:
Stored size: 1 KB
Contents
# frozen_string_literal: true module NulogySSO # A mix-in that is intended to enhance a controller with NulogySSO authentication code. # It is recommended to `include NulogySSO::ControllerHelper` in your ApplicationController. module ControllerHelper extend ActiveSupport::Concern included do # Makes the commonly used @current_user variable available to controllers and views. # This emulates a code pattern popular in Rails apps using Devise. attr_reader :current_user helper_method :current_user before_action :store_previous_url_in_session end def authenticate_sso_user raw_token = cookies[NulogySSO.sso_cookie_key] return redirect_to nulogy_sso.login_path if raw_token.blank? @current_user = Authenticator.new.authenticated_user(raw_token) return redirect_to nulogy_sso.login_path if @current_user.blank? end def store_previous_url_in_session session[:previous_request_url] = request.url unless current_user end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nulogy_sso-1.0.0 | lib/nulogy_sso/controller_helper.rb |
nulogy_sso-0.5.0 | lib/nulogy_sso/controller_helper.rb |