class PseudoSessionController < ApplicationController helper_method :current_pseudo_user def is_user_authorized? return if (OrbitHelper.current_user.is_admin? rescue false) dt = Time.now session[:current_pseudo_user_login_time] = Time.now if session[:current_pseudo_user_login_time].nil? dt1 = session[:current_pseudo_user_login_time] + @module_settings.timeout.minutes if dt > dt1 redirect_to member_logout_path and return else session[:current_pseudo_user_login_time] = Time.now end redirect_to member_login_path if current_pseudo_user.nil? end def create_pseudo_session(user=nil) if !user.nil? and current_pseudo_user.nil? session[:current_pseudo_user_id] = user.id session[:current_pseudo_user_login_time] = Time.now user.last_login = Time.now user.save end end def member_login_path "/" + I18n.locale.to_s + Page.where(:module => "pseudo_member").first.url end def destroy_pseudo_session session.delete(:current_pseudo_user_id) end def current_pseudo_user @current_pseudo_user = PseudoUser.find(session[:current_pseudo_user_id]) rescue nil end def set_key_for_this @key = Site.first.template @module_settings = PseudoMemberSetting.first if @module_settings.nil? @module_settings = PseudoMemberSetting.create end end end