first commit
This commit is contained in:
parent
06e8148634
commit
99d63dbaed
|
@ -1,30 +1,3 @@
|
|||
require 'mcrypt'
|
||||
class SsoLoginBoxController < SessionsController
|
||||
def tku_login
|
||||
redirect_to root_url and return if !params[:t].present?
|
||||
str_decoded = Base64.decode64(params[:sso_userid].to_s)
|
||||
mc = Mcrypt.new(:des,:ecb)
|
||||
mc.padding = :pkcs
|
||||
mc.key = "3M7PvTSE"
|
||||
plain = mc.decrypt(str_decoded)
|
||||
t = mc.decrypt(Base64.decode64(params[:t])).to_i
|
||||
nt = DateTime.now.to_time.to_i
|
||||
if (nt - t) < 10
|
||||
user = MemberProfile.where(:sid => plain).first.user rescue nil
|
||||
if !user.nil?
|
||||
session[:user_id] = user.id
|
||||
session[:login_referer] = nil
|
||||
if params[:referer_url]
|
||||
redirect_to URI.parse(params[:referer_url]).path
|
||||
else
|
||||
redirect_to admin_dashboards_path
|
||||
end
|
||||
else
|
||||
flash.now.alert = "User not found."
|
||||
render "new"
|
||||
end
|
||||
else
|
||||
redirect_to root_url
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
en:
|
||||
nccu_lib_login: Library acoount login
|
|
@ -0,0 +1,2 @@
|
|||
zh_tw:
|
||||
nccu_lib_login: 圖書館帳號登入
|
|
@ -4,7 +4,7 @@ module SsoLoginBox
|
|||
initializer "sso_login_box" do
|
||||
OrbitApp.registration "SsoLoginBox", :type => "ModuleApp" do
|
||||
base_url File.expand_path File.dirname(__FILE__)
|
||||
set_keyword_contstraints ['/sso/tku_redirect']
|
||||
#set_keyword_contstraints ['/sso/tku_redirect']
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
module SsoLoginBox::LoginTag
|
||||
def self.show
|
||||
url_for_sso = File.read("#{ENV['PWD']}/sso_url.txt").force_encoding('utf-8').gsub(/\n/,'')
|
||||
"<div class=\"pull-right\"><a href=\"#{url_for_sso}\">SSO Login</a></div>"
|
||||
"<div style=\"text-align: right;\" class=\"pull-right\">
|
||||
<a style=\"border: 0.1em solid;padding: 0.5em;\" href=\"#{url_for_sso}\">#{t('nccu_lib_login')}</a></div>"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue