Skip to content

Commit

Permalink
improve manage active sessions post
Browse files Browse the repository at this point in the history
  • Loading branch information
yshmarov committed Mar 24, 2024
1 parent e45c333 commit 6a3a6f0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions _posts/2024-03-19-turbo-8-instantclick-prefetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ title: "Turbo 8 Prefetch (InstantClick)"
author: Yaroslav Shmarov
tags: turbo-rails prefetch instantclick
thumbnail: /assets/thumbnails/turbo.png
youtube_id: CxWPMnRoud0
---

Inspired by [instaclick.io](http://instantclick.io/), instaclick [has been added](https://github.com/hotwired/turbo/pull/1101) as a default behaviour in Turbo 8.
Expand Down
17 changes: 16 additions & 1 deletion _posts/2024-03-24-secutiry-manage-active-sessions.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@ thumbnail: /assets/thumbnails/encryption-lock.png

Ok, so sometimes to enchance security of your application you will want to allow users to see all the devices/browsers they are logged in with. You would also provided a button to sign out of a device/browser.

Here's how you can do it:
Here's how you can manage your login activity in Meta/Facebook:

![meta-account-login-activity](/assets/images/meta-account-login-activity.png)

![meta-where-youre-logged-in](/assets/images/meta-where-youre-logged-in.png)

Here's how it can look in a Rails app using devise:

![manage active sessions](/assets/images/manage-active-sessions.gif)

- Sign in creates a login
- Sign out deletes a login
- Deleting a login will log the user out of a device

### 1. Store current login (device/browser) info and ensure the current device/browser has not been logged out.

Expand Down Expand Up @@ -83,6 +95,8 @@ rails generate devise:controllers users -c=sessions
```ruby
# app/controllers/users/sessions_controller.rb
class Users::SessionsController < Devise::SessionsController
# skip_before_action :require_login, only: :create

def create
super do |resource|
create_login if resource.persisted?
Expand Down Expand Up @@ -172,3 +186,4 @@ That's it! 🤗
Inspired by:
- [vitobotta - Manage active sessions in Rails](https://vitobotta.com/2016/10/19/manage-active-sessions-)
- [adamcooke/authie](https://github.com/adamcooke/authie)
- [Facebook Login activity](https://accountscenter.facebook.com/password_and_security/login_activity)
Binary file added assets/images/manage-active-sessions.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/meta-account-login-activity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/meta-where-youre-logged-in.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6a3a6f0

Please sign in to comment.