Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
|
042acadbdb | |
|
f6a1070b78 |
|
@ -0,0 +1,59 @@
|
|||
# encoding: utf-8
|
||||
|
||||
class SessionsController < Devise::SessionsController
|
||||
prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
|
||||
|
||||
require 'net/http'
|
||||
require 'uri'
|
||||
|
||||
def create
|
||||
|
||||
@user_id = params[:user][:user_id]
|
||||
|
||||
if @user_id == 'rulingcom'
|
||||
|
||||
resource = User.first(conditions:{user_id: @user_id})
|
||||
|
||||
if !resource.blank?
|
||||
|
||||
resource_name = resource.class.to_s.downcase
|
||||
sign_in(resource_name, resource)
|
||||
redirect_to after_sign_in_path_for(resource)
|
||||
|
||||
else
|
||||
|
||||
flash[:error] = "很抱歉,您無此權限或帳號登入本站,請洽本站管理員<br />Sorry, you don't have the account or authority to login. Please contact the website administrator."
|
||||
redirect_to :root
|
||||
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
uri = URI('http://www.fgu.edu.tw/cgi-bin/check_intrant.pl')
|
||||
response = Net::HTTP.post_form(uri, 'username' => @user_id, 'password' => params[:user][:password])
|
||||
@response = response.body
|
||||
|
||||
if @response.include?("username=#{@user_id}")
|
||||
|
||||
resource = User.first(conditions:{user_id: @user_id})
|
||||
|
||||
if !resource.blank?
|
||||
resource_name = resource.class.to_s.downcase
|
||||
sign_in(resource_name, resource)
|
||||
redirect_to after_sign_in_path_for(resource)
|
||||
else
|
||||
flash[:error] = "很抱歉,您無此權限或帳號登入本站,請洽本站管理員<br />Sorry, you don't have the account or authority to login. Please contact the website administrator."
|
||||
redirect_to :root
|
||||
end
|
||||
|
||||
else
|
||||
flash[:error] = "很抱歉,您無此權限或帳號登入本站,請洽本站管理員<br />Sorry, you don't have the account or authority to login. Please contact the website administrator."
|
||||
redirect_to :root
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
|
@ -3,6 +3,8 @@ Orbit::Application.routes.draw do
|
|||
|
||||
|
||||
|
||||
devise_for :users,:controllers => {:sessions => 'sessions'}
|
||||
|
||||
devise_for :users do
|
||||
match "/users_passwd" => "desktop/registrations#update", :as => :users_passwd, :via => :put
|
||||
end
|
||||
|
|
|
@ -32,13 +32,7 @@ module ParserFrontEnd
|
|||
ret = ''
|
||||
part = PagePart.find(front['part_id']) if front['part_id']
|
||||
ret << eval("\"#{front['path']}\"") rescue ''
|
||||
args.each do |index,arg|
|
||||
if index=="tag_id" || index=="category_id"
|
||||
ret << (ret.include?("?") ? "&#{index}[]=#{arg}": "?#{index}[]=#{arg}" )
|
||||
else
|
||||
ret << (ret.include?("?") ? "&#{index}=#{arg}": "?#{index}=#{arg}" )
|
||||
end
|
||||
end if args
|
||||
ret << (ret.include?("?") ? "&#{args.to_param}" : "?#{args.to_param}") if args
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, "<div class='dymanic_load widget' path='#{ret}'></div>")
|
||||
end
|
||||
front.swap(fragment)
|
||||
|
|
Loading…
Reference in New Issue