On Fri, Jan 20, 2012 at 3:59 PM, Colin Law <[email protected]> wrote:
> On 20 January 2012 10:20, sachin kewale <[email protected]> wrote: > > hi all, > > i have one issue after entering username and password on login popup > and > > clicking login button the user is logged in but i have to refresh the url > > i have check the log but nothing is there,i have set the session key > and > > secret in 'session_store.rb', i am running my local app on 127.0.0.1 ip > on > > 3006 port > > Without showing us the relevant code we have no hope of helping. We > have no idea of how you are handling login or what code is executed > when the login button is clicked. > > Colin > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > i am using ruby 1.8.7 and rails version 2.3.11 with ruby gem 1.6.2 i am setting the key and secret value in session_store.rb with following code ActionController::Base.session = { :key => '_myapp', :secret => '071a1167c4870bfff95a61835288f9fa9eb158298e1c5623e8d7223fa7a68c9d485b4e27a8e705c2485631bfc28f48b895c486536c8f53856ce3480f0d9ea8b' #:domain => :all } from my controller i using validate_user method def validate_user begin login_details = params[:login_details] user_name = login_details['username'] user_password = login_details['password'] user_typed=user_password error_header = 'Please correct the following:' error_header += '<ul>' error_msgs = '' if user_name == nil || user_name.strip.empty? message = "Please Enter Your Email" error_msgs += '<li>' + message + '</li>' end if user_password == nil || user_password.strip.empty? message = "Please Enter Password" error_msgs += '<li>' + message + '</li>' end if error_msgs != '' headers['X-Instruction'] = "ERROR" render :text => error_header + error_msgs else # Check whether the login details are valid user = User.find(:first, :conditions => ["user_name = ? AND user_password = ?", user_name, user_password]) if user == nil message = "Your Email/Password is invalid. Please try again" render :text => message else #Save the user details in session myapp_user = myappUser.new myapp_user.user_id = user.user_id myapp_user.first_name = user.first_name myapp_user.last_name = user.last_name myapp_user.email_id = user.email_id if(user.user_id) logged_user = myappPortalExpert.find(:first, :conditions => ["user_id = ? ", user.user_id]) if logged_user!=nil myapp_user.first_time = 'no' else myapp_user.first_time = 'yes' end end session['user'] = myapp_user if(login_details['remember']) # cookies[:user_user_id] = { :value => (user.user_id).to_s, :expires => Time.now + 20160} # cookies[:user_last_name] = { :value => user.last_name, :expires => Time.now + 20160} cookies[:user_name] = { :value => user_name, :expires => Time.now + 20160} cookies[:user_password] = { :value => user_typed, :expires => Time.now + 20160} elsif cookies cookies[:user_name] = { :value => "", :expires => Time.now} cookies[:user_password] = { :value => "", :expires => Time.now} end headers['X-Instruction'] = "OK" if session['user'].first_time=="yes" headers['X-Portal'] = "abc" else headers['X-Portal'] = "PORTAL" end if $header=='yes' headers['X-Subm'] = "yes" elsif $header=='no' headers['X-Subm'] = "no" end render :nothing => true end end rescue ActiveRecord::ActiveRecordError=>active_record_error @error_num = "#DB100" @error_message = "Active Record Error occured in validate_user method of login_controller" # add logging code here # add mail code here mail_subject=@error_num+" "+@error_message email = ErrorMailer.deliver_error_info(mail_subject) @logger.error "Error:"+mail_subject+active_record_error rescue_action_all(active_record_error) rescue Timeout::Error=>e @error_num = "#TM101" @error_message = "Timeout exception occured in validate_user method of login_controller" # add logging code here mail_subject=@error_num+" "+@error_message @logger.warn "Warning:"+mail_subject retry show_timeout(e) rescue Errno::EBADF => e @error_num = "#FD102" @error_message = "Bad File Descriptor Exception occured in validate_user method of login_controller" mail_subject=@error_num+" "+@error_message email = ErrorMailer.deliver_error_info(mail_subject) @logger.error "Error:"+mail_subject rescue_action_all(e) end # Turn On documentation #++ end -- Thanks and Regards Sachin S. Kewale -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

