2017-09-21 12:50:17 +00:00
|
|
|
class PseudoSessionController < ApplicationController
|
|
|
|
helper_method :current_pseudo_user
|
|
|
|
|
|
|
|
def is_user_authorized?
|
|
|
|
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
|
|
|
|
|
2017-12-21 19:40:17 +00:00
|
|
|
def member_login_path
|
|
|
|
"/" + I18n.locale.to_s + Page.where(:module => "pseudo_member").first.url
|
|
|
|
end
|
|
|
|
|
2017-09-21 12:50:17 +00:00
|
|
|
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
|