37 lines
1.0 KiB
Ruby
37 lines
1.0 KiB
Ruby
class CUserController < ApplicationController
|
|
before_filter :set_key_for_this
|
|
layout "special"
|
|
helper_method :current_counselor_user
|
|
|
|
def is_user_authorized?
|
|
dt = Time.now
|
|
session[:current_counselor_user_login_time] = Time.now if session[:current_counselor_user_login_time].nil?
|
|
dt1 = session[:current_counselor_user_login_time] + 20.minutes
|
|
if dt > dt1
|
|
redirect_to member_logout_path and return
|
|
else
|
|
session[:current_counselor_user_login_time] = Time.now
|
|
end
|
|
redirect_to member_login_path if current_counselor_user.nil?
|
|
end
|
|
|
|
def create_cuser_session(user=nil)
|
|
if !user.nil? and current_counselor_user.nil?
|
|
session[:current_counselor_user_id] = user.id
|
|
session[:current_counselor_user_login_time] = Time.now
|
|
end
|
|
end
|
|
|
|
def destroy_cpanel_session
|
|
session.delete(:current_counselor_user_id)
|
|
end
|
|
|
|
def current_counselor_user
|
|
@current_counselor_user = HpsMember.find(session[:current_counselor_user_id]) rescue nil
|
|
end
|
|
|
|
def set_key_for_this
|
|
@key = Site.first.template
|
|
end
|
|
|
|
end |