Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
Get date of last login with restul authentication
4 Posts
Get date of last login with restul authentication

Hello,

I am using restful_authentication and was wondering if it is possible to get the last time (date) a user logged on the web, knowing that he may not have logout (only closed the browser.

Thanks Nicolas

restful_authentication actually supports a range of different auth types (cookie/persistence/basic auth) so it depends on which scenario youre using. That said tho - even when using a database it doesn't record the actual login time, etc. (it just compares the incoming credentials). Would be very easy to add a hook of your own in your generated model that recorded a user's last logged in time in the authenticate method.

thanks, I am using cookie sessions, do you suggest to add the date in the session?

restful_authentication does it self. you just have to add the attribute column that restful suggest. Just create user table with the columns suggested by restful_auth. You find your ans in "last_login_at" attribute

4 Posts
Login to add your message