Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brunoocasali/devise_last_seen
Ensure that devise will update a flag/timestamp on the model whenever a user is authenticated.
https://github.com/brunoocasali/devise_last_seen
devise devise-extensions rails ruby
Last synced: 3 months ago
JSON representation
Ensure that devise will update a flag/timestamp on the model whenever a user is authenticated.
- Host: GitHub
- URL: https://github.com/brunoocasali/devise_last_seen
- Owner: brunoocasali
- License: mit
- Created: 2021-08-28T16:35:46.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-05-12T03:03:03.000Z (over 1 year ago)
- Last Synced: 2024-04-26T07:01:55.543Z (9 months ago)
- Topics: devise, devise-extensions, rails, ruby
- Language: Ruby
- Homepage:
- Size: 44.9 KB
- Stars: 9
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# devise_last_seen
This devise extension, will ensure that devise will update a flag/timestamp on the model whenever a user is set.
With this kind of feature you could show in your views something like **last seen 3 weeks ago** or **last seen 2 minutes ago**.[![ruby gem](https://github.com/brunoocasali/devise_last_seen/actions/workflows/gem.yml/badge.svg)](https://github.com/brunoocasali/devise_last_seen/actions/workflows/gem.yml)
[![Test Coverage](https://api.codeclimate.com/v1/badges/056e2b80cbcdb5d7b402/test_coverage)](https://codeclimate.com/github/brunoocasali/devise_last_seen/test_coverage)
[![Maintainability](https://api.codeclimate.com/v1/badges/056e2b80cbcdb5d7b402/maintainability)](https://codeclimate.com/github/brunoocasali/devise_last_seen/maintainability)## Installation
You know, add this line to your application's Gemfile:
```ruby
gem 'devise_last_seen'
```And then execute:
$ bundle
## Usage
In your model, add `:lastseenable` module as such:
```rb
# app/models/user.rbclass User < ApplicationRecord
devise :database_authenticable, ..., :lastseenable
end
```Generate a rails migration to add the column to your devise model:
```
bundle exec rails g migration add_last_seen_to_users last_seen:datetime
``````rb
class AddLastSeenToUsers < ActiveRecord::Migration[6.1]
def change
add_column :users, :last_seen, :datetime
end
end
```## Configuration
Besides the column requirement you don't need customizations, but if you want to...
```rb
# config/initializers/devise.rbDevise.setup do |config|
...# Interval (in seconds) to update the :last_seen_at_attribute attr
# config.last_seen_at_interval = 5.minutes# Attribute who will be updated every time a user is set by the Warden's after_save callback
# Remember to check if this column name is present on the devise model table.
# config.last_seen_at_attribute = :last_seen
end
```## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rspec` to run the tests.
To install this gem onto your local machine, run `bundle exec rake install`.
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/brunoocasali/devise_last_seen. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
## Code of Conduct
Everyone interacting in the `devise_last_seen` project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/devise_last_seen/blob/master/CODE_OF_CONDUCT.md).
## Hall of fame!
This gem only could be done with help of other gems like:
- @shenoudab [devise_traceable](https://github.com/shenoudab/devise_traceable)
- @devise-security [devise-security](https://github.com/devise-security/devise-security)
- @heartcombo [devise](https://github.com/heartcombo/devise)
- @ctide [devise_lastseenable](https://github.com/ctide/devise_lastseenable)
- @iplan [iplan-devise-lastseenable](https://github.com/iplan/iplan-devise-lastseenable)