mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
- Views use lazy t(".key") lookups; sentences with values or links stay
whole (interpolation, _html keys); counts use one/other plurals
- Stored-value labels (statuses, types, priorities...) are LabelSets read
from labels: in the current locale; field names and validation messages
under activerecord:; flash and activity text under flash:
- Services, models, helpers, mailer subjects, the logbook PDF, procedures
templates, records package README and transcription warnings localized;
the PDF reuses LogbookEntry#certification_statement instead of a copy
- Scripts read js: strings from a JSON tag via app/javascript/i18n.js
- Dates through I18n.l (app, weekday, month_year, long formats); html lang
follows the locale
- APP_LOCALE picks the language (falls back to English); missing
translations raise in development and tests
- README: Translating section and APP_LOCALE
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)
|
|
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
|