Hello All,
I am getting a problem while login for inactive users.
While login I am getting -
Processing by Devise::SessionsController#new as HTML
User Load (0.7ms) SELECT "users".* FROM "users" WHERE
"users"."id" = 2
LIMIT 1
Redirected to http://localhost:3000/
Filter chain halted as :require_no_authentication rendered or redirected.
Inactive users still login, but while debugging, it doesn''t show
anything.
It goes to the else part, still logs in.
session_controller:-
prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
prepend_before_filter :allow_params_authentication!, :only => :create
prepend_before_filter { request.env["devise.skip_timeout"] = true }
skip_before_filter :verify_authenticity_token
def create
user_email = User.find_by_email(resource_params[''email''])
if user_email
if server_emails.include?(resource_params[''email'']) ||
params[:client_login] != nil
if
user_email.valid_password?(resource_params[''password''])
if (user_email.status == "Verified" || user_email.status ==
nil)
/// This part is fine... It allows to login.
else
flash[:notice] = "User Not Active"
respond_with({:errors => "User Not Active"}, :location
=>
sign_in_path)
end
else
flash[:notice] = "Password doesn''t match"
respond_with({:errors => "Password doesn''t
match"}, :location =>
sign_in_path)
end
else
puts "NOT AUTHORIZED"
flash[:notice] = "You are not authorized to login. Admin login
only."
respond_with({:errors => "Not authorized"}, :location =>
sign_in_path)
end
else
flash[:notice] = "Email doesn''t exists."
respond_with({:errors => "Email doesn''t exists."},
:location =>
sign_in_path)
end
end
Thanks,
Avi
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/e0ba1dfb-3f0e-4e95-9e04-514a11ec6c27%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Hello, Any suggestion on this. Even I reverted back to the code 2 months back where the same code was working. The same problem exists. What I need to do ? Thanks On Thursday, September 26, 2013 1:13:47 PM UTC+5:30, Avi wrote:> > Hello All, > > I am getting a problem while login for inactive users. > While login I am getting - > > Processing by Devise::SessionsController#new as HTML > User Load (0.7ms) SELECT "users".* FROM "users" WHERE "users"."id" = 2 > LIMIT 1 > Redirected to http://localhost:3000/ > Filter chain halted as :require_no_authentication rendered or redirected. > > Inactive users still login, but while debugging, it doesn''t show anything. > It goes to the else part, still logs in. > > > session_controller:- > > prepend_before_filter :require_no_authentication, :only => [ :new, :create > ] > prepend_before_filter :allow_params_authentication!, :only => :create > prepend_before_filter { request.env["devise.skip_timeout"] = true } > skip_before_filter :verify_authenticity_token > > def create > user_email = User.find_by_email(resource_params[''email'']) > > if user_email > if server_emails.include?(resource_params[''email'']) || > params[:client_login] != nil > if user_email.valid_password?(resource_params[''password'']) > if (user_email.status == "Verified" || user_email.status == nil) > > /// This part is fine... It allows to login. > > else > flash[:notice] = "User Not Active" > respond_with({:errors => "User Not Active"}, :location => > sign_in_path) > end > else > flash[:notice] = "Password doesn''t match" > respond_with({:errors => "Password doesn''t match"}, :location => > sign_in_path) > end > else > puts "NOT AUTHORIZED" > flash[:notice] = "You are not authorized to login. Admin login > only." > respond_with({:errors => "Not authorized"}, :location => > sign_in_path) > end > else > flash[:notice] = "Email doesn''t exists." > respond_with({:errors => "Email doesn''t exists."}, :location => > sign_in_path) > end > > end > > > > > > Thanks, > Avi >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/6d238fd6-7431-4a0f-a97f-5db21dcf2af5%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Hi Avi, Can you answer a few questions? 1. What is your rails, ruby and devise version you are using? 2. What is exactly your problem and why you customising the sessions controller exactly? It was pretty confusing your post, so maybe put your code on a gist: https://gist.github.com/ 3. Have you tried using a debugger, to see why your code is not hittin what you want? look at this gem: https://rubygems.org/gems/ruby-debug or https://github.com/cldwalker/debugger depending on ruby version. all the best, Andre -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ad7d64a0-a8b9-427b-8d20-69fd9c22ffca%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.