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


--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Colin Law at Jan 20, 2012 at 10:30 am

    On 20 January 2012 10:20, sachin kewale 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 rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Sachin kewale at Jan 20, 2012 at 10:54 am

    On Fri, Jan 20, 2012 at 3:59 PM, Colin Law wrote:
    On 20 January 2012 10:20, sachin kewale 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 rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to
    rubyonrails-talk+unsubscribe@googlegroups.com.
    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 rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Colin Law at Jan 20, 2012 at 11:12 am

    On 20 January 2012 10:54, sachin kewale wrote:
    On Fri, Jan 20, 2012 at 3:59 PM, Colin Law wrote:
    On 20 January 2012 10:20, sachin kewale 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.
    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
    [snipped some very complex code that I am not even going to attempt to understand]
    I think you had better have a look at the Rails Guide on Debugging.
    That will show you how to use ruby-debug to break into your code to
    inspect data and follow the flow. Then you should be able to work out
    what is going wrong.

    I would also say that code looks incredibly complex and should be
    refactored to make it simpler. Personally I would not even attempt to
    debug code as complex as this, but would refactor it into simpler
    chunks first, there is a good chance it will then work. Sending email
    and rendering inside a method called validate_user, for example, is
    ridiculous (IMHO).

    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 rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Sachin kewale at Jan 23, 2012 at 1:13 pm

    On Fri, Jan 20, 2012 at 4:41 PM, Colin Law wrote:
    On 20 January 2012 10:54, sachin kewale wrote:

    On Fri, Jan 20, 2012 at 3:59 PM, Colin Law wrote:
    On 20 January 2012 10:20, sachin kewale 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.
    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
    [snipped some very complex code that I am not even going to attempt to
    understand]

    I think you had better have a look at the Rails Guide on Debugging.
    That will show you how to use ruby-debug to break into your code to
    inspect data and follow the flow. Then you should be able to work out
    what is going wrong.

    I would also say that code looks incredibly complex and should be
    refactored to make it simpler. Personally I would not even attempt to
    debug code as complex as this, but would refactor it into simpler
    chunks first, there is a good chance it will then work. Sending email
    and rendering inside a method called validate_user, for example, is
    ridiculous (IMHO).

    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 rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to
    rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/rubyonrails-talk?hl=en.
    hi colin,
    i debug the code(method) but method giving the right values.My problem
    is that as i said when user logs in
    it is done in that method but i have to refresh the url to take the user
    on to new page if it valid user.

    --
    Regards
    Sachin

    --
    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 rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Hassan Schroeder at Jan 23, 2012 at 3:40 pm
    On Mon, Jan 23, 2012 at 5:13 AM, sachin kewale wrote:
    ,
    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 debug the code(method) but method giving the right values.My problem is
    that as i said when user logs in
    it is done in that method but i have to refresh the url to take the user
    on to new page if it valid user.
    Just as an aside; this

    session['user'] = myapp_user

    is almost certainly a bad idea; better to just store the user_id and
    fetch the user details as necessary. And this

    cookies[:user_password] = { :value => user_typed, :expires =>
    Time.now + 20160}

    is a terrible idea, security-wise. Don't do that.
    ( read: http://guides.rubyonrails.org/security.html#session-storage )

    To your problem -- are you using cookie-based sessions? If so, try
    using ActiveRecord (or memcache) session storage.

    HTH,
    --
    Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
    http://about.me/hassanschroeder
    twitter: @hassan

    --
    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 rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Colin Law at Jan 23, 2012 at 9:55 pm

    On 23 January 2012 13:13, sachin kewale wrote:
    On Fri, Jan 20, 2012 at 4:41 PM, Colin Law wrote:
    On 20 January 2012 10:54, sachin kewale wrote:


    On Fri, Jan 20, 2012 at 3:59 PM, Colin Law <clanlaw@googlemail.com>
    wrote:
    On 20 January 2012 10:20, sachin kewale 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.
    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
    [snipped some very complex code that I am not even going to attempt to
    understand]
    I think you had better have a look at the Rails Guide on Debugging.
    That will show you how to use ruby-debug to break into your code to
    inspect data and follow the flow.  Then you should be able to work out
    what is going wrong.

    I would also say that code looks incredibly complex and should be
    refactored to make it simpler.  Personally I would not even attempt to
    debug code as complex as this, but would refactor it into simpler
    chunks first, there is a good chance it will then work.  Sending email
    and rendering inside a method called validate_user, for example, is
    ridiculous (IMHO).
    hi colin,
    i debug the code(method) but method giving the right values.My problem is
    that as i said when user logs in
    it is done in that method but i have to refresh the url to take the user
    on to new page if it valid user.
    I don't fully understand what you mean and as I said I have not looked
    in detail at the code, you say that it is following the correct flow,
    at the end does it instruct it to render or redirect to an appropriate
    page? If so does the log say that it is doing that correctly?

    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 rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJan 20, '12 at 10:20a
activeJan 23, '12 at 9:55p
posts7
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2021 Grokbase