Permalink
Browse files

Fix login & signup errors

  • Loading branch information...
1 parent 1f16d59 commit ba05391dac6df8b785123642b1fe54969f27fe92 @saizai saizai committed Jun 10, 2012
Showing with 27 additions and 28 deletions.
  1. +26 −27 app/controllers/users/registrations_controller.rb
  2. +1 −1 app/models/user.rb
@@ -12,32 +12,31 @@ def new_from_id
end
def create
- build_resource
-
- if session["devise.identity"] and identity = Identity.find(session["devise.identity"])
- resource.identities << identity
- end
-
- if resource.save
- if resource.active_for_authentication?
- set_flash_message :notice, :signed_up if is_navigational_format?
- sign_in(resource_name, resource)
- respond_with resource, :location => after_sign_up_path_for(resource)
- else
- set_flash_message :notice, :inactive_signed_up, :reason => inactive_reason(resource) if is_navigational_format?
- expire_session_data_after_sign_in!
- respond_with resource, :location => after_inactive_sign_up_path_for(resource)
+ build_resource
+
+ if session["devise.identity"] and identity = Identity.find(session["devise.identity"])
+ resource.identities << identity
+ end
+
+ if resource.save
+ if resource.active_for_authentication?
+ set_flash_message :notice, :signed_up if is_navigational_format?
+ sign_in(resource_name, resource)
+ respond_with resource, :location => after_sign_up_path_for(resource)
+ else
+ set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_navigational_format?
+ expire_session_data_after_sign_in!
+ respond_with resource, :location => after_inactive_sign_up_path_for(resource)
+ end
+ else
+ clean_up_passwords resource
+ respond_with_navigational(resource) do
+ if session["devise.identity"]
+ render :new_from_id
+ else
+ render :new
+ end
end
- else
- clean_up_passwords(resource)
- respond_with_navigational(resource) do
- if session["devise.identity"]
- render :new_from_id
- else
- render :new
- end
- end
- end
- end
-
+ end
+ end
end
View
@@ -20,7 +20,7 @@ class User < ActiveRecord::Base
def self.find_first_by_auth_conditions(warden_conditions)
conditions = warden_conditions.dup
login = conditions.delete(:login_or_email)
- where(conditions).where(["lower(login) = :value OR lower(email) = :value", { :value => login.downcase }]).first
+ where(conditions).where(login ? ["lower(login) = :value OR lower(email) = :value", { :value => login.downcase }] : nil).first
end
def password_required?

0 comments on commit ba05391

Please sign in to comment.