2

In my application I have a login page and I need to prevent multiple logins from the same user (same username and password). I have used different methods like having a boolean value and updating it from true to false. But it has the drawback that whenever a user closes her browser (without logging of) the flag is not updated.

Are there any ways to achieve that by using session_id or something along those lines?

Kostas Rousis
  • 5,918
  • 1
  • 33
  • 38
Sanju B Myh
  • 271
  • 1
  • 15

1 Answers1

0

I will use Devise and enable trackable which will save last_sign_in_at, last_sign_in_ip, current_sign_in_at, current_sign_in_ip into database. Then simply inherit Devise::SessionsController and override the action create to check if current IP is the same as last_sign_in_ip and last_sign_in_at is not before half an hour ago.

Aetherus
  • 8,720
  • 1
  • 22
  • 36