Files
once-campfire/app/controllers/users/profiles_controller.rb
T
Jeremy Daer c78c3fd7ef Sign out the account's other sessions when its password changes
Changing the password is how someone shuts out whoever else is signed
in to their account, but every session opened with the old password
stayed valid. Now the others end and their live connections close, as
on sign-out. The session the password was changed from stays signed in.

Changing the password outside a request, as from a console, ends every
session.
2026-10-19 10:28:06 -07:00

29 lines
722 B
Ruby

class Users::ProfilesController < ApplicationController
before_action :set_user
def show
@direct_memberships, @shared_memberships =
Current.user.memberships.with_ordered_room.partition { |m| m.room.direct? }
end
def update
@user.update user_params
disconnect_remote_connections if @user.saved_change_to_password_digest?
redirect_to user_profile_url, notice: update_notice
end
private
def set_user
@user = Current.user
end
def user_params
params.require(:user).permit(:name, :avatar, :email_address, :password, :bio).compact
end
def update_notice
params[:user][:avatar] ? "It may take up to 30 minutes to change everywhere." : "✓"
end
end