Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ylecuyer/devise_session_limit
Devise mixin to limit the number of simultaneous sessions with the same credentials
https://github.com/ylecuyer/devise_session_limit
Last synced: 18 days ago
JSON representation
Devise mixin to limit the number of simultaneous sessions with the same credentials
- Host: GitHub
- URL: https://github.com/ylecuyer/devise_session_limit
- Owner: ylecuyer
- License: mit
- Created: 2012-07-30T09:16:14.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2019-12-03T16:24:03.000Z (almost 5 years ago)
- Last Synced: 2024-04-27T17:46:11.264Z (6 months ago)
- Language: Ruby
- Size: 5.86 KB
- Stars: 2
- Watchers: 23
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DeviseSessionLimit
Devise plugin preventing a user from having multiple open sessions
Using code from [https://github.com/phatworx/devise_security_extension](devise_security_extension)
## Installation
Add this line to your application's Gemfile:
gem 'devise_session_limit'
And then execute:
$ bundle
Or install it yourself as:
$ gem install devise_session_limit
## Usage
In your `User` model:
class User
# Additional field
field :unique_session_id, :type => String# Additional devise module
devise ..., :session_limitend
Add some translation key for the error message:
en:
devise:
failure:
session_limited: "You are already signed in from another place"## Customize
You can customize the behaviour from the `User` model by overriding or chaining this two methods:
# Called at each sign in
def update_unique_session_id!(unique_session_id)
self.unique_session_id = unique_session_id
save(:validate => false)
end# Called at each request, you can override to implement your own behaviour
def check_unique_session_id session_id
self.unique_session_id == session_id
end