Ruby on Rails
Wednesday, July 25, 2012
I store the request.session_options[:id] in my user table when one logs in. If another user logs in using another browser, this value is updated. For every action requested by user this value is checked by current value of this variable. If not matched, user is redirected to login page.
Following is the code,
This one is defined in ApplicationController.def deny_multiple_login
if(session[:user])
@session_old_key = (User.where("username =?", session[:user].username)).first.current_sign_in_token
@session_current_key = request.session_options[:id]
if(@session_current_key != @session_old_key)
respond_to do |format|
format.html {redirect_to logout_path}
end
end
end
end
And then I user before_filter :deny_multiple_login in my ContactsController.
Also I have another controller Usercontroller which is responsible for login actions and contacts controller is responsible to manage contacts list of every user.
Regards
Sumit Srivastava
The power of imagination makes us infinite...
On 25 July 2012 15:31, Gintautas Šimkus <dihitales@gmail.com> wrote:
"I added code for session management where one user can login only using one browser at a time"And what if the same user is doing a request from another browser? What actions do you take? It sounds reasonable to me to assume that your logic for determining if the browser detection logic is bugged.--
2012/7/25 sumit srivastava <sumit.theinvincible@gmail.com>Peter,
I added code for session management where one user can login only using one browser at a time. Other than that I tried production mode of the app.
Regards
Sumit Srivastava
The power of imagination makes us infinite...
On 25 July 2012 15:25, Peter Hicks <peter.hicks@poggs.co.uk> wrote:
What did you change between the last time it worked, and now?
On 25 Jul 2012, at 10:45, sumit srivastava wrote:
> The same code was running fine earlier but now I am not able to get where it has got problem.
Peter
--
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 https://groups.google.com/groups/opt_out.
--
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 https://groups.google.com/groups/opt_out.
Pagarbiai,
Gintautas
--
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 https://groups.google.com/groups/opt_out.
--
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 https://groups.google.com/groups/opt_out.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment