Fix bug: User cannot connect using the orbit button (Devise configuration)

This commit is contained in:
chris 2012-10-26 17:42:14 +08:00
parent 2c5539eda9
commit 9b5f4e4775
6 changed files with 5 additions and 34 deletions

View File

@ -1,26 +0,0 @@
class SessionsController < Devise::SessionsController
prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
include Devise::Controllers::InternalHelpers
# POST /resource/sign_in
def create
# login_password = params[:user][:password]
# login_uid = params[:user][:nccu_ldap_uid]
login_password = params[:user][:password]
login_email = params[:user][:email]
result = false
resource = User.first(conditions:{ email: login_email })
set_flash_message(:notice, :signed_in) if is_navigational_format?
if resource.nil?
logger.error "Can't find user #{login_email}"
flash[:notice] = t('devise.failure.invalid')
render :action => "new"
else
logger.info "=== passed"
resource_name = resource.class.to_s.downcase
sign_in(resource_name, resource)
respond_with resource, :location => redirect_location(resource_name, resource)
end
end
end

View File

@ -9,10 +9,7 @@ class User
field :admin, :type => Boolean, :default => true
field :active_role
field :nccu_ldap_uid
field :email
# field :cache_dept
# has_one :cache_dept, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
field :cache_dept,type: Hash
field :status_record,type: Hash

View File

@ -3,7 +3,7 @@
<h3><%= t(:login) %></h3>
</div>
<div id="container" class="sign-in">
<%= form_for :user, :url => user_session_path, :html => {:class => 'user_new form-horizontal'} do |f| %>
<%= form_for resource, :as => resource_name, :url => session_path(resource_name), :html => {:class => 'user_new form-horizontal'} do |f| %>
<div class="content">
<% flash.each do |key, msg| %>
<%= content_tag :span, msg, :class => [key, "notice label label-warning"] %>

View File

@ -90,7 +90,7 @@
<li>
<div class="input-prepend">
<span class="add-on"><i class="icon-user"></i></span>
<%= f.text_field :nccu_ldap_uid, :class => 'span2', :placeholder => t('nccu_c.nccu_ldap_uid'), :size => 16 %>
<%= f.text_field :email, :class => 'span2', :placeholder => t(:email), :size => 16 %>
</div>
</li>
<li>

View File

@ -21,7 +21,7 @@ Devise.setup do |config|
# parameters are used only when authenticating and not when retrieving from
# session. If you need permissions, you should implement that in a before filter.
# config.authentication_keys = [ :email ]
config.authentication_keys = [ :nccu_ldap_uid ]
config.authentication_keys = [ :email ]
# Tell if authentication through request.params is enabled. True by default.

View File

@ -1,6 +1,6 @@
Orbit::Application.routes.draw do
devise_for :users,:controllers => {:sessions => 'sessions'}
devise_for :users
mount Resque::Server, :at => "/admin/resque"
# routes for sinatra app