NCCU 上傳版本 0709
Merge branch 'nccu0621' Conflicts: Gemfile config/resque.god vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb
This commit is contained in:
commit
09d46f2f75
79 files changed
+683
-278
No files matched your search
@@ -56,7 +56,7 @@ class Admin::ModuleAppsNewInterfaceController < OrbitBackendController
|
||||
def get_categorys(id = nil)
|
||||
@bulletin_categorys = []
|
||||
if(is_manager? || is_admin?)
|
||||
@bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true))
|
||||
@bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.all)
|
||||
elsif is_sub_manager?
|
||||
@bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new')
|
||||
end
|
||||
|
||||
@@ -49,7 +49,7 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
|
||||
# def get_categorys(id = nil)
|
||||
# @bulletin_categorys = []
|
||||
# if(is_manager? || is_admin?)
|
||||
# @bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true))
|
||||
# @bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.all)
|
||||
# elsif is_sub_manager?
|
||||
# @bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new')
|
||||
# end
|
||||
|
||||
@@ -3,7 +3,7 @@ require 'mongo'
|
||||
class GridfsController < ActionController::Metal
|
||||
|
||||
def serve
|
||||
gridfs_path = env["PATH_INFO"].gsub("/gridfs/", "").force_encoding("UTF-8")
|
||||
gridfs_path = (params[:path]+'.'+params[:format]).gsub("/gridfs/", "").force_encoding("UTF-8")
|
||||
begin
|
||||
gridfs_file = Mongo::GridFileSystem.new(Mongoid.database).open(gridfs_path, 'r')
|
||||
self.response_body = gridfs_file.read
|
||||
|
||||
@@ -154,15 +154,17 @@ class OrbitBackendController< ApplicationController
|
||||
end
|
||||
|
||||
|
||||
def get_viewable(object_class)
|
||||
objects = get_objects(object_class).order_by(:created_at, :desc)
|
||||
def get_viewable(object_class, query=nil)
|
||||
objects = get_objects(object_class,query).order_by(:created_at, :desc)
|
||||
Kaminari.paginate_array(objects).page(params[:page]).per(10)
|
||||
end
|
||||
|
||||
def get_objects(object_class, query=nil)
|
||||
object_class = object_class.classify.constantize
|
||||
# debugger
|
||||
# a=1
|
||||
if query
|
||||
objects = object_class.all.where(query)
|
||||
objects = object_class.where(query)
|
||||
else
|
||||
objects = object_class.all
|
||||
end
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
class SessionsController < Devise::SessionsController
|
||||
prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
|
||||
include Devise::Controllers::InternalHelpers
|
||||
MiddleSiteConnection.establish
|
||||
NccuLdapConnection.establish
|
||||
|
||||
# POST /resource/sign_in
|
||||
def create
|
||||
@@ -12,42 +10,55 @@ class SessionsController < Devise::SessionsController
|
||||
login_uid = params[:user][:nccu_ldap_uid]
|
||||
result = false
|
||||
ldap_filter = "(uid=#{login_uid})"
|
||||
if $nccu_ldap_connection.bind
|
||||
logger.info "=LDAP Binded password ok..."
|
||||
result =check_auth_with_ldap(login_uid,login_password)
|
||||
if result #&& login_password!=''
|
||||
logger.info "==LDAP password passed..."
|
||||
nccu_id = get_nccu_id_from_mid_site(login_uid)
|
||||
resource = nccu_id.nil? ? nil : (User.first(conditions:{ nccu_ldap_uid: nccu_id }))
|
||||
# resource = env['warden'].authenticate!(:check_nccu_ldap)
|
||||
# resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
|
||||
set_flash_message(:notice, :signed_in) if is_navigational_format?
|
||||
if (resource.nil? || nccu_id.nil?)
|
||||
logger.error "===LDAP passed local block... resource:#{resource.inspect}\n nccu_id:#{nccu_id} \t login_uid:#{login_uid}"
|
||||
flash[:notice] = t('devise.failure.ldap_pass_but_account_not_in_orbit')
|
||||
render :action => "new"
|
||||
else
|
||||
logger.info "===ALL passed"
|
||||
resource_name = resource._type.downcase
|
||||
sign_in(resource_name, resource)
|
||||
respond_with resource, :location => redirect_location(resource_name, resource)
|
||||
end
|
||||
elsif resource = User.first(conditions:{email: login_uid})
|
||||
if /@rulingcom.com$/.match(login_uid).nil?
|
||||
MiddleSiteConnection.establish
|
||||
NccuLdapConnection.establish
|
||||
|
||||
resource_name = resource._type.downcase
|
||||
sign_in(resource_name, resource)
|
||||
respond_with resource, :location => redirect_location(resource_name, resource)
|
||||
if ($nccu_ldap_connection.bind rescue false)
|
||||
logger.info "=LDAP Binded password ok..."
|
||||
result =check_auth_with_ldap(login_uid,login_password)
|
||||
if result && login_password!=''
|
||||
logger.info "==LDAP password passed..."
|
||||
nccu_id = get_nccu_id_from_mid_site(login_uid)
|
||||
resource = nccu_id.nil? ? nil : (User.first(conditions:{ nccu_ldap_uid: nccu_id }))
|
||||
# resource = env['warden'].authenticate!(:check_nccu_ldap)
|
||||
# resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
|
||||
set_flash_message(:notice, :signed_in) if is_navigational_format?
|
||||
if (resource.nil? || nccu_id.nil?)
|
||||
logger.error "===LDAP passed local block... resource:#{resource.inspect}\n nccu_id:#{nccu_id} \t login_uid:#{login_uid}"
|
||||
flash[:notice] = t('devise.failure.ldap_pass_but_account_not_in_orbit')
|
||||
render :action => "new"
|
||||
else
|
||||
logger.info "===ALL passed"
|
||||
resource_name = resource._type.downcase
|
||||
sign_in(resource_name, resource)
|
||||
respond_with resource, :location => redirect_location(resource_name, resource)
|
||||
end
|
||||
else
|
||||
logger.error "==password LDAP fail..."
|
||||
flash[:notice] = t('devise.failure.ldap_invalid')
|
||||
render :action => "new"
|
||||
end
|
||||
else
|
||||
logger.error "==password LDAP fail..."
|
||||
flash[:notice] = t('devise.failure.ldap_invalid')
|
||||
render :action => "new"
|
||||
logger.error "=LDAP fail..."
|
||||
flash[:notice] = t('devise.failure.ldap_connection_failed')
|
||||
render :action => "new"
|
||||
end
|
||||
else
|
||||
logger.error "=LDAP fail..."
|
||||
flash[:notice] = t('devise.failure.ldap_connection_failed')
|
||||
render :action => "new"
|
||||
end
|
||||
logger.info "=======End Debugging======"
|
||||
else #if rulingcom account
|
||||
logger.info "=======Rulingcom account======"
|
||||
resource = User.first(conditions:{email: login_uid})
|
||||
if resource.valid_password?(login_password)
|
||||
resource_name = resource._type.downcase
|
||||
sign_in(resource_name, resource)
|
||||
respond_with resource, :location => redirect_location(resource_name, resource)
|
||||
else
|
||||
logger.error "==password Local fail..."
|
||||
flash[:notice] = t('devise.failure.invalid')
|
||||
render :action => "new"
|
||||
end
|
||||
end
|
||||
logger.info "=======End Debugging======"
|
||||
|
||||
end
|
||||
private
|
||||
def check_auth_with_ldap(login_uid,login_password)
|
||||
|
||||
Reference in new issue
Block a user