-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Geovelocity and Password change after login working with session_id
- Loading branch information
1 parent
d68a8bc
commit b67b7ae
Showing
5 changed files
with
72 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require 'geocoder' | ||
|
||
module UsualSuspect | ||
module SessionsControllerExtension | ||
extend ActiveSupport::Concern | ||
|
||
def track_usual_suspect_login | ||
user_ip = request.remote_ip | ||
location = Geocoder.search(user_ip).first | ||
session_token = generate_unique_session_token | ||
session[:usual_suspect_session_token] = session_token | ||
|
||
current_user.update_login(user_ip, location, session_token) if current_user | ||
end | ||
|
||
def generate_unique_session_token | ||
SecureRandom.hex(10) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters