diff --git a/Gemfile b/Gemfile index 81344e2..d9047fd 100644 --- a/Gemfile +++ b/Gemfile @@ -33,6 +33,8 @@ gem 'bootsnap', '>= 1.4.2', require: false # https://github.com/Shopify/bootsnap gem 'devise', '~> 4.7', '>= 4.7.3' # https://github.com/plataformatec/devise gem 'devise-i18n', '~> 1.9', '>= 1.9.2' # https://github.com/tigrish/devise-i18n gem 'devise-bootstrap-views', '~> 1.1' # https://github.com/hisea/devise-bootstrap-views +gem 'devise-i18n-bootstrap' + gem 'activestorage-validator' # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] # https://github.com/tzinfo/tzinfo-data diff --git a/Gemfile.lock b/Gemfile.lock index 4fdd319..131c169 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -106,6 +106,7 @@ GEM devise-bootstrap-views (1.1.0) devise-i18n (1.9.2) devise (>= 4.7.1) + devise-i18n-bootstrap (0.3.0.beta) diff-lcs (1.4.4) docile (1.3.4) erubi (1.10.0) @@ -311,6 +312,7 @@ DEPENDENCIES devise (~> 4.7, >= 4.7.3) devise-bootstrap-views (~> 1.1) devise-i18n (~> 1.9, >= 1.9.2) + devise-i18n-bootstrap factory_bot_rails (~> 6.1) faker (~> 2.14) font-awesome-rails (~> 4.7, >= 4.7.0.5) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4ce1763..6e18a4c 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -13,6 +13,12 @@ def edit @social_account = @user.social_accounts.build end + def edit_profile + return unless authorize_to_update! + + @user = User.find(params[:id]) + end + def update return unless authorize_to_update! # prototype for create social account form @@ -20,7 +26,7 @@ def update handle_error @social_account = @user.social_accounts.build - render :edit + render :edit_profile end def update_status @@ -54,7 +60,7 @@ def handle_error end def user_params - params.require(:user).permit(:username, :firstname, :lastname, :birthdate, :place_of_residence, :avatar) + params.require(:user).permit(:username, :firstname, :lastname, :email, :birthdate, :place_of_residence, :avatar) end def authorize diff --git a/app/views/users/confirmations/new.html.erb b/app/views/users/confirmations/new.html.erb index 4af186b..cf9dc73 100644 --- a/app/views/users/confirmations/new.html.erb +++ b/app/views/users/confirmations/new.html.erb @@ -1,16 +1,16 @@ -
- <%= image_tag @user.avatar, height: 160, width: 160, :style => "margin-bottom: 10px; display: block; margin-left: auto; margin-right: auto;", class: "rounded-circle" %> -
- -- <%= form.file_field :avatar %> -
- -- <%= form.label I18n.t('user.attributes.username') %> - <%= form.text_field :username %> -
- -- <%= form.label I18n.t('user.attributes.firstname') %> - <%= form.text_field :firstname %> -
- -- <%= form.label I18n.t('user.attributes.lastname') %> - <%= form.text_field :lastname %> -
- -- <%= form.label I18n.t('user.attributes.place_of_residence') %> - <%= form.text_field :place_of_residence %> -
- -- <%= form.label I18n.t('user.attributes.birthdate') %> - <%= form.date_select :birthdate, start_year: 1900, end_year: Time.now.year %> -
- -- <%= form.submit %> -
-<% end %> ++ <%= image_tag @user.avatar, height: 160, width: 160, :style => "margin-bottom: 10px; display: block; margin-left: auto; margin-right: auto;", class: "rounded-circle" %> +
+ ++ <%= form.file_field :avatar %> +
+ ++ <%= form.label I18n.t('user.attributes.username') %> + <%= form.text_field :username %> +
+ ++ <%= form.label I18n.t('user.attributes.firstname') %> + <%= form.text_field :firstname %> +
+ ++ <%= form.label I18n.t('user.attributes.lastname') %> + <%= form.text_field :lastname %> +
+ ++ <%= form.label I18n.t('user.attributes.email') %> + <%= form.text_field :email %> +
+ ++ <%= form.label I18n.t('user.attributes.place_of_residence') %> + <%= form.text_field :place_of_residence %> +
+ ++ <%= form.label I18n.t('user.attributes.birthdate') %> + <%= form.date_select :birthdate, start_year: 1900, end_year: Time.now.year %> +
+ ++ <%= form.submit %> +
+<% end %> diff --git a/app/views/users/mailer/confirmation_instructions.html.erb b/app/views/users/mailer/confirmation_instructions.html.erb index dc55f64..5620c5a 100644 --- a/app/views/users/mailer/confirmation_instructions.html.erb +++ b/app/views/users/mailer/confirmation_instructions.html.erb @@ -1,5 +1,6 @@ -Welcome <%= @email %>!
+<%= t('.greeting', :recipient => @resource.email, :default => "Welcome #{@resource.email}!") %>
-You can confirm your account email through the link below:
+<%= t('.instruction', :default => "You can confirm your account email through the link below:") %>
-<%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %>
+<%= link_to t('.action', :default => "Confirm my account"), + confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %>
diff --git a/app/views/users/mailer/reset_password_instructions.html.erb b/app/views/users/mailer/reset_password_instructions.html.erb index f667dc1..e1555a5 100644 --- a/app/views/users/mailer/reset_password_instructions.html.erb +++ b/app/views/users/mailer/reset_password_instructions.html.erb @@ -1,8 +1,8 @@ -Hello <%= @resource.email %>!
+<%= t('.greeting', :recipient => @resource.email, :default => "Hello #{@resource.email}!") %>
-Someone has requested a link to change your password. You can do this through the link below.
+<%= t('.instruction', :default => "Someone has requested a link to change your password, and you can do this through the link below.") %>
-<%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %>
+<%= link_to t('.action', :default => "Change my password"), edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %>
-If you didn't request this, please ignore this email.
-Your password won't change until you access the link above and create a new one.
+<%= t('.instruction_2', :default => "If you didn't request this, please ignore this email.") %>
+<%= t('.instruction_3', :default => "Your password won't change until you access the link above and create a new one.") %>
diff --git a/app/views/users/mailer/unlock_instructions.html.erb b/app/views/users/mailer/unlock_instructions.html.erb index 41e148b..8bd4887 100644 --- a/app/views/users/mailer/unlock_instructions.html.erb +++ b/app/views/users/mailer/unlock_instructions.html.erb @@ -1,7 +1,7 @@ -Hello <%= @resource.email %>!
+<%= t('.greeting', :recipient => @resource.email, :default => "Hello #{@resource.email}!") %>
-Your account has been locked due to an excessive number of unsuccessful sign in attempts.
+<%= t('.message', :default => "Your account has been locked due to an excessive amount of unsuccessful sign in attempts.") %>
-Click the link below to unlock your account:
+<%= t('.instruction', :default => "Click the link below to unlock your account:") %>
-<%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %>
+<%= link_to t('.action', :default => "Unlock my account"), unlock_url(@resource, :unlock_token => @resource.unlock_token) %>
diff --git a/app/views/users/passwords/edit.html.erb b/app/views/users/passwords/edit.html.erb index 863ffbb..acdc167 100644 --- a/app/views/users/passwords/edit.html.erb +++ b/app/views/users/passwords/edit.html.erb @@ -1,25 +1,26 @@ -Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>
+<%= t('.unhappy') %>? <%= link_to t('.cancel_my_account'), registration_path(resource_name), data: { confirm: t('.are_you_sure') }, method: :delete %>.
-<%= link_to "Back", :back %> +<%= link_to t('.back'), :back %> diff --git a/app/views/users/registrations/new.html.erb b/app/views/users/registrations/new.html.erb index 61d1e4c..3a95df6 100644 --- a/app/views/users/registrations/new.html.erb +++ b/app/views/users/registrations/new.html.erb @@ -1,29 +1,30 @@ -