From 9b5f4e47756def058053bd4620ed4e50cad7f07e Mon Sep 17 00:00:00 2001 From: chris Date: Fri, 26 Oct 2012 17:42:14 +0800 Subject: [PATCH] Fix bug: User cannot connect using the orbit button (Devise configuration) --- app/controllers/sessions_controller.rb | 26 -------------------------- app/models/user/user.rb | 3 --- app/views/devise/sessions/new.html.erb | 4 ++-- app/views/layouts/_orbit_bar.html.erb | 2 +- config/initializers/devise.rb | 2 +- config/routes.rb | 2 +- 6 files changed, 5 insertions(+), 34 deletions(-) delete mode 100644 app/controllers/sessions_controller.rb diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb deleted file mode 100644 index 929c316a..00000000 --- a/app/controllers/sessions_controller.rb +++ /dev/null @@ -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 diff --git a/app/models/user/user.rb b/app/models/user/user.rb index 3ae7bf5d..5893dae2 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -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 diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 1ab2e89b..f394700c 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -3,11 +3,11 @@

<%= t(:login) %>

- <%= 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| %>
<% flash.each do |key, msg| %> <%= content_tag :span, msg, :class => [key, "notice label label-warning"] %> - <% end%> + <% end %>

You need to sign in or sign up before continuing.

diff --git a/app/views/layouts/_orbit_bar.html.erb b/app/views/layouts/_orbit_bar.html.erb index c3decff8..1769d1ca 100644 --- a/app/views/layouts/_orbit_bar.html.erb +++ b/app/views/layouts/_orbit_bar.html.erb @@ -90,7 +90,7 @@
  • - <%= 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 %>
  • diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index ea19b137..817f12ea 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -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. diff --git a/config/routes.rb b/config/routes.rb index 88a39f42..0fb8cd24 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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