mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
- Requests run in the viewer's zone: Profile -> Time zone, else their device's (a tz cookie set from the browser), else the installation's; times show in it and "today" is the local date (a new flight's date) - Docker's TZ sets the installation zone (default UTC): scheduled jobs run on its clock (recurring.yml), and it's used before a device's zone is known - The weekly reminder email is worked out in the recipient's zone - Signatures, record history and exports keep exact UTC timestamps - users.time_zone; README, .env.example and guide updated Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
34 lines
1.5 KiB
Ruby
34 lines
1.5 KiB
Ruby
class ProfilesController < ApplicationController
|
|
def edit
|
|
@user = current_user
|
|
end
|
|
|
|
# Changing the email or password needs the current password, so a session
|
|
# left open somewhere can't be turned into a takeover of the account.
|
|
def update
|
|
@user = current_user
|
|
attrs = params.require(:user).permit(:name, :email_address, :password, :password_confirmation, :reminder_emails, :time_zone)
|
|
attrs = attrs.except(:password, :password_confirmation) if attrs[:password].blank?
|
|
new_email = User.normalize_value_for(:email_address, attrs[:email_address].to_s) if attrs.key?(:email_address)
|
|
sensitive = (new_email && new_email != @user.email_address) || attrs.key?(:password)
|
|
# Checked before assigning: setting a new password replaces the digest at once.
|
|
if sensitive && !@user.authenticate_password(params.dig(:user, :current_password).to_s)
|
|
@user.assign_attributes(attrs.except(:password, :password_confirmation))
|
|
@user.errors.add(:base, :current_password_needed)
|
|
return render :edit, status: :unprocessable_entity
|
|
end
|
|
@user.assign_attributes(attrs)
|
|
if @user.save
|
|
@user.sessions.where.not(id: Current.session.id).destroy_all if attrs.key?(:password)
|
|
redirect_to root_path, notice: t("flash.profiles.profile_updated")
|
|
else
|
|
render :edit, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
def sign_out_others
|
|
count = current_user.sessions.where.not(id: Current.session.id).destroy_all.size
|
|
redirect_to edit_profile_path, notice: t("flash.profiles.signed_out_others", count: count)
|
|
end
|
|
end
|