hps_member/app/controllers/member_counselors_controlle...

71 lines
1.6 KiB
Ruby
Raw Normal View History

2017-05-18 12:12:35 +00:00
class MemberCounselorsController < CUserController
before_filter :is_user_authorized?, :only => ["show"]
def index
if !current_counselor_user.nil?
redirect_to member_dash_path(current_counselor_user.account)
end
end
def logoutuser
destroy_cpanel_session
redirect_to member_login_path
end
def loginuser
user = HpsMember.where(:account => params[:username]).first rescue nil
if user.nil?
redirect_to member_login_path(:error=>"invld")
else
if user.enabled
if user.authenticate(params[:password])
create_cuser_session(user)
redirect_to member_dash_path(user.account)
else
redirect_to member_login_path(:error=>"invld")
end
else
redirect_to member_login_path(:error=>"dsbld")
end
end
end
def fileupload
@hpsfile = HpsFile.new
end
def editfileupload
@hpsfile = HpsFile.find(params[:id])
end
def file_upload
hpsfile = HpsFile.new(hps_file_params)
hpsfile.hps_member = current_counselor_user
hpsfile.save
redirect_to member_dash_path(current_counselor_user.account)
end
def update_file_upload
hpsfile = HpsFile.find(params[:id])
hpsfile.update_attributes(hps_file_params)
redirect_to member_dash_path(current_counselor_user.account)
end
def deletefileupload
hpsfile = HpsFile.find(params[:id])
hpsfile.destroy
redirect_to member_dash_path(current_counselor_user.account)
end
def show
@files = current_counselor_user.hps_files
end
private
def hps_file_params
params.require(:hps_file).permit!
end
end