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 @@ -

Resend confirmation instructions

+

<%= t('.resend_confirmation_instructions') %>

<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %> - <%= render "users/shared/error_messages", resource: resource %> + <%= bootstrap_devise_error_messages! %> -
- <%= f.label :email %>
- <%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %> +
+ <%= f.label :email %> + <%= f.email_field :email, autofocus: true, autocomplete: 'email', value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email), class: 'form-control' %>
-
- <%= f.submit "Resend confirmation instructions" %> +
+ <%= f.submit t('.resend_confirmation_instructions'), class: 'btn btn-primary' %>
<% end %> -<%= render "users/shared/links" %> +<%= render 'devise/shared/links' %> diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 468529d..5374b26 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -1,48 +1,7 @@

<%= I18n.t('user.edit.edit_profile_heading') %>


-

<%= I18n.t('user.edit.profile_heading') %>

-<%= form_with(model: @user, local: true) do |form| %> - <% if @user.errors.any? %> - <%= render 'layouts/flash_messages'%> - <% 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.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 %> +

<%= I18n.t('user.edit.profile_settings_heading') %>

+<%= link_to I18n.t('user.edit.edit_profile_settings_heading'), edit_profile_user_path(@user) %>
diff --git a/app/views/users/edit_profile.html.erb b/app/views/users/edit_profile.html.erb new file mode 100644 index 0000000..45a05cf --- /dev/null +++ b/app/views/users/edit_profile.html.erb @@ -0,0 +1,49 @@ +

<%= I18n.t('user.edit.edit_profile_settings_heading') %>

+ +<%= form_with(model: @user, local: true) do |form| %> + <% if @user.errors.any? %> + <%= render 'layouts/flash_messages'%> + <% 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 @@ -

Change your password

+

<%= t('.change_your_password') %>

<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %> - <%= render "users/shared/error_messages", resource: resource %> + <%= bootstrap_devise_error_messages! %> <%= f.hidden_field :reset_password_token %> -
- <%= f.label :password, "New password" %>
+
+ <%= f.label :password, t('.new_password') %> + <%= f.password_field :password, autofocus: true, class: 'form-control' %> + <% if @minimum_password_length %> - (<%= @minimum_password_length %> characters minimum)
+ <%= t('devise.shared.minimum_password_length', count: @minimum_password_length) %> <% end %> - <%= f.password_field :password, autofocus: true, autocomplete: "new-password" %>
-
- <%= f.label :password_confirmation, "Confirm new password" %>
- <%= f.password_field :password_confirmation, autocomplete: "new-password" %> +
+ <%= f.label :password_confirmation, t('.confirm_new_password') %> + <%= f.password_field :password_confirmation, autocomplete: 'off', class: 'form-control' %>
-
- <%= f.submit "Change my password" %> +
+ <%= f.submit t('.change_my_password'), class: 'btn btn-primary' %>
<% end %> -<%= render "users/shared/links" %> +<%= render 'devise/shared/links' %> diff --git a/app/views/users/passwords/new.html.erb b/app/views/users/passwords/new.html.erb index 3b30b06..37e3008 100644 --- a/app/views/users/passwords/new.html.erb +++ b/app/views/users/passwords/new.html.erb @@ -1,16 +1,16 @@ -

Forgot your password?

+

<%= t('.forgot_your_password') %>

<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %> - <%= render "users/shared/error_messages", resource: resource %> + <%= bootstrap_devise_error_messages! %> -
- <%= f.label :email %>
- <%= f.email_field :email, autofocus: true, autocomplete: "email" %> +
+ <%= f.label :email %> + <%= f.email_field :email, autofocus: true, autocomplete: 'email', class: 'form-control' %>
-
- <%= f.submit "Send me reset password instructions" %> +
+ <%= f.submit t('.send_me_reset_password_instructions'), class: 'btn btn-primary' %>
<% end %> -<%= render "users/shared/links" %> +<%= render 'devise/shared/links' %> diff --git a/app/views/users/registrations/edit.html.erb b/app/views/users/registrations/edit.html.erb index 038cd94..5119bf4 100644 --- a/app/views/users/registrations/edit.html.erb +++ b/app/views/users/registrations/edit.html.erb @@ -1,43 +1,32 @@ -

Edit <%= resource_name.to_s.humanize %>

+

<%= t('.title') %>

<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> - <%= render "users/shared/error_messages", resource: resource %> + <%= bootstrap_devise_error_messages! %> -
- <%= f.label :email %>
- <%= f.email_field :email, autofocus: true, autocomplete: "email" %> -
+
+ <%= f.label :password %> + <%= f.password_field :password, autocomplete: 'new-password', class: 'form-control' %> - <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> -
Currently waiting confirmation for: <%= resource.unconfirmed_email %>
- <% end %> - -
- <%= f.label :password %> (leave blank if you don't want to change it)
- <%= f.password_field :password, autocomplete: "new-password" %> - <% if @minimum_password_length %> -
- <%= @minimum_password_length %> characters minimum - <% end %> + <%= t('leave_blank_if_you_don_t_want_to_change_it') %>
-
- <%= f.label :password_confirmation %>
- <%= f.password_field :password_confirmation, autocomplete: "new-password" %> +
+ <%= f.label :password_confirmation %> + <%= f.password_field :password_confirmation, autocomplete: 'new-password', class: 'form-control' %>
-
- <%= f.label :current_password %> (we need your current password to confirm your changes)
- <%= f.password_field :current_password, autocomplete: "current-password" %> +
+ <%= f.label :current_password %> + <%= f.password_field :current_password, autocomplete: 'current-password', class: 'form-control' %> + + <%= t('.we_need_your_current_password_to_confirm_your_changes') %>
-
- <%= f.submit "Update" %> +
+ <%= f.submit t('.update'), class: 'btn btn-primary' %>
<% end %> -

Cancel my account

- -

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 @@ -

Sign up

+

<%= t('.sign_up') %>

<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> - <%= render "users/shared/error_messages", resource: resource %> + <%= bootstrap_devise_error_messages! %> -
- <%= f.label :email %>
- <%= f.email_field :email, autofocus: true, autocomplete: "email" %> +
+ <%= f.label :email %> + <%= f.email_field :email, autofocus: true, autocomplete: 'email', class: 'form-control' %>
-
+
<%= f.label :password %> + <%= f.password_field :password, autocomplete: 'current-password', class: 'form-control' %> + <% if @minimum_password_length %> - (<%= @minimum_password_length %> characters minimum) - <% end %>
- <%= f.password_field :password, autocomplete: "new-password" %> + <%= t('devise.shared.minimum_password_length', count: @minimum_password_length) %> + <% end %>
-
- <%= f.label :password_confirmation %>
- <%= f.password_field :password_confirmation, autocomplete: "new-password" %> +
+ <%= f.label :password_confirmation %> + <%= f.password_field :password_confirmation, autocomplete: 'current-password', class: 'form-control' %>
-
- <%= f.submit "Sign up" %> +
+ <%= f.submit t('.sign_up'), class: 'btn btn-primary' %>
<% end %> -<%= render "users/shared/links" %> +<%= render 'devise/shared/links' %> diff --git a/app/views/users/sessions/new.html.erb b/app/views/users/sessions/new.html.erb index 8c4864b..171f460 100644 --- a/app/views/users/sessions/new.html.erb +++ b/app/views/users/sessions/new.html.erb @@ -1,26 +1,28 @@ -

Log in

+

<%= t('.sign_in') %>

<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> -
- <%= f.label :email %>
- <%= f.email_field :email, autofocus: true, autocomplete: "email" %> +
+ <%= f.label :email %> + <%= f.email_field :email, autofocus: true, autocomplete: 'email', class: 'form-control' %>
-
- <%= f.label :password %>
- <%= f.password_field :password, autocomplete: "current-password" %> +
+ <%= f.label :password %> + <%= f.password_field :password, autocomplete: 'current-password', class: 'form-control' %>
<% if devise_mapping.rememberable? %> -
- <%= f.check_box :remember_me %> - <%= f.label :remember_me %> +
+ <%= f.check_box :remember_me, class: 'form-check-input' %> + <%= f.label :remember_me, class: 'form-check-label' do %> + <%= resource.class.human_attribute_name('remember_me') %> + <% end %>
<% end %> -
- <%= f.submit "Log in" %> +
+ <%= f.submit t('.sign_in'), class: 'btn btn-primary' %>
<% end %> -<%= render "users/shared/links" %> +<%= render 'devise/shared/links' %> diff --git a/app/views/users/shared/_links.erb b/app/views/users/shared/_links.erb new file mode 100644 index 0000000..f6ecca0 --- /dev/null +++ b/app/views/users/shared/_links.erb @@ -0,0 +1,25 @@ +<%- if controller_name != 'sessions' %> +<%= link_to t(".sign_in", :default => "Sign in"), new_session_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.registerable? && controller_name != 'registrations' %> +<%= link_to t(".sign_up", :default => "Sign up"), new_registration_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.recoverable? && controller_name != 'passwords' %> +<%= link_to t(".forgot_your_password", :default => "Forgot your password?"), new_password_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> +<%= link_to t('.didn_t_receive_confirmation_instructions', :default => "Didn't receive confirmation instructions?"), new_confirmation_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> +<%= link_to t('.didn_t_receive_unlock_instructions', :default => "Didn't receive unlock instructions?"), new_unlock_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.omniauthable? %> + <%- resource_class.omniauth_providers.each do |provider| %> + <%= link_to t('.sign_in_with_provider', :provider => provider.to_s.titleize, :default => "Sign in with #{provider.to_s.titleize}"), omniauth_authorize_path(resource_name, provider) %>
+ <% end -%> +<% end -%> diff --git a/app/views/users/shared/_links.html.erb b/app/views/users/shared/_links.html.erb index 084af70..3c97f4c 100644 --- a/app/views/users/shared/_links.html.erb +++ b/app/views/users/shared/_links.html.erb @@ -1,25 +1,27 @@ -<%- if controller_name != 'sessions' %> - <%= link_to "Log in", new_session_path(resource_name) %>
-<% end %> +
+ <%- if controller_name != 'sessions' %> + <%= link_to t(".sign_in"), new_session_path(resource_name) %>
+ <% end -%> -<%- if devise_mapping.registerable? && controller_name != 'registrations' %> - <%= link_to "Sign up", new_registration_path(resource_name) %>
-<% end %> + <%- if devise_mapping.registerable? && controller_name != 'registrations' %> + <%= link_to t(".sign_up"), new_registration_path(resource_name) %>
+ <% end -%> -<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %> - <%= link_to "Forgot your password?", new_password_path(resource_name) %>
-<% end %> + <%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %> + <%= link_to t(".forgot_your_password"), new_password_path(resource_name) %>
+ <% end -%> -<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> - <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
-<% end %> + <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> + <%= link_to t('.didn_t_receive_confirmation_instructions'), new_confirmation_path(resource_name) %>
+ <% end -%> -<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> - <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %>
-<% end %> + <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> + <%= link_to t('.didn_t_receive_unlock_instructions'), new_unlock_path(resource_name) %>
+ <% end -%> -<%- if devise_mapping.omniauthable? %> - <%- resource_class.omniauth_providers.each do |provider| %> - <%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %>
- <% end %> -<% end %> + <%- if devise_mapping.omniauthable? %> + <%- resource_class.omniauth_providers.each do |provider| %> + <%= link_to t('.sign_in_with_provider', provider: OmniAuth::Utils.camelize(provider)), omniauth_authorize_path(resource_name, provider) %>
+ <% end -%> + <% end -%> +
diff --git a/app/views/users/unlocks/new.html.erb b/app/views/users/unlocks/new.html.erb index 2f4fab8..d70aa2f 100644 --- a/app/views/users/unlocks/new.html.erb +++ b/app/views/users/unlocks/new.html.erb @@ -1,16 +1,16 @@ -

Resend unlock instructions

+

<%= t('.resend_unlock_instructions') %>

<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %> - <%= render "users/shared/error_messages", resource: resource %> + <%= bootstrap_devise_error_messages! %> -
- <%= f.label :email %>
- <%= f.email_field :email, autofocus: true, autocomplete: "email" %> +
+ <%= f.label :email %> + <%= f.email_field :email, autofocus: true, autocomplete: 'email', class: 'form-control' %>
-
- <%= f.submit "Resend unlock instructions" %> +
+ <%= f.submit t('.resend_unlock_instructions'), class: 'btn btn-primary'%>
<% end %> -<%= render "users/shared/links" %> +<%= render 'devise/shared/links' %> diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index bf89a2e..00b0314 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -244,7 +244,7 @@ # Turn scoped views on. Before rendering "sessions/new", it will first check for # "users/sessions/new". It's turned off by default because it's slower if you # are using only default views. - # config.scoped_views = false + config.scoped_views = true # Configure the default scope given to Warden. By default it's the first # devise role declared in your routes (usually :user). diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml index 90b78c8..e7f978c 100644 --- a/config/locales/devise.en.yml +++ b/config/locales/devise.en.yml @@ -1,61 +1,96 @@ -# Additional translations at https://github.com/heartcombo/devise/wiki/I18n - en: - devise: + users: confirmations: - confirmed: "Your email address has been successfully confirmed." - send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes." - send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes." + new: + resend_confirmation_instructions: "Resend confirmation instructions" + confirmed: "Your account was successfully confirmed." + send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes." + send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes." failure: already_authenticated: "You are already signed in." inactive: "Your account is not activated yet." - invalid: "Invalid %{authentication_keys} or password." + invalid: "Invalid email or password." + invalid_token: "Invalid authentication token." locked: "Your account is locked." - last_attempt: "You have one more attempt before your account is locked." - not_found_in_database: "Invalid %{authentication_keys} or password." + not_found_in_database: "Invalid email or password." timeout: "Your session expired. Please sign in again to continue." unauthenticated: "You need to sign in or sign up before continuing." - unconfirmed: "You have to confirm your email address before continuing." + unconfirmed: "You have to confirm your account before continuing." mailer: confirmation_instructions: + action: "Confirm my account" + greeting: "Welcome %{recipient}!" + instruction: "You can confirm your account email through the link below:" subject: "Confirmation instructions" reset_password_instructions: + action: "Change my password" + greeting: "Hello %{recipient}!" + instruction: "Someone has requested a link to change your password, and you can do this through the link below." + instruction_2: "If you didn't request this, please ignore this email." + instruction_3: "Your password won't change until you access the link above and create a new one." subject: "Reset password instructions" unlock_instructions: - subject: "Unlock instructions" - email_changed: - subject: "Email Changed" - password_change: - subject: "Password Changed" + action: "Unlock my account" + greeting: "Hello %{recipient}!" + instruction: "Click the link below to unlock your account:" + message: "Your account has been locked due to an excessive amount of unsuccessful sign in attempts." + subject: "Unlock Instructions" omniauth_callbacks: failure: "Could not authenticate you from %{kind} because \"%{reason}\"." success: "Successfully authenticated from %{kind} account." passwords: + new: + forgot_your_password: "Forgot your password?" + send_me_reset_password_instructions: "Send me reset password instructions" + edit: + change_your_password: "Change your password" + new_password: "New password" + confirm_new_password: "Confirm new password" + change_my_password: "Change my password" no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided." - send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes." + send_instructions: "You will receive an email with instructions about how to reset your password in a few minutes." send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes." - updated: "Your password has been changed successfully. You are now signed in." - updated_not_active: "Your password has been changed successfully." + updated: "Your password was changed successfully. You are now signed in." + updated_not_active: "Your password was changed successfully." registrations: - destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon." + edit: + are_you_sure: "Are you sure?" + cancel_my_account: "Cancel my account" + leave_blank_if_you_don_t_want_to_change_it: "leave blank if you dont want to change it" + title: "Change Password" + we_need_your_current_password_to_confirm_your_changes: "we need your current password to confirm your changes" + update: "Update" + unhappy: "Unhappy" + new: + sign_up: "Sign up" + destroyed: "Bye! Your account was successfully cancelled. We hope to see you again soon." signed_up: "Welcome! You have signed up successfully." signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated." signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked." - signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account." - update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address." - updated: "Your account has been updated successfully." - updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again" + signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please open the link to activate your account." + update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address." + updated: "You updated your account successfully." sessions: signed_in: "Signed in successfully." signed_out: "Signed out successfully." - already_signed_out: "Signed out successfully." + new: + sign_in: "Sign in" + shared: + links: + didn_t_receive_confirmation_instructions: "Didn't receive confirmation instructions?" + didn_t_receive_unlock_instructions: "Didn't receive unlock instructions?" + forgot_your_password: "Forgot your password?" + sign_in: "Sign in" + sign_in_with_provider: "Sign in with %{provider}" + sign_up: "Sign up" unlocks: - send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes." - send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes." + new: + resend_unlock_instructions: "Resend unlock instructions" + send_instructions: "You will receive an email with instructions about how to unlock your account in a few minutes." + send_paranoid_instructions: "If your account exists, you will receive an email with instructions about how to unlock it in a few minutes." unlocked: "Your account has been unlocked successfully. Please sign in to continue." errors: messages: - authentication_failed: "Authentication failed" already_confirmed: "was already confirmed, please try signing in" confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one" expired: "has expired, please request a new one" @@ -64,3 +99,12 @@ en: not_saved: one: "1 error prohibited this %{resource} from being saved:" other: "%{count} errors prohibited this %{resource} from being saved:" + activerecord: + models: + user: "User" + attributes: + user: + current_sign_in_at: "Signed in at" + email: "Email" + password: "Password" + last_sign_in_at: "Last signed in at" diff --git a/config/locales/en.yml b/config/locales/en.yml index 4b78aae..8c71b47 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -78,7 +78,8 @@ en: view: 'View my requests' edit: edit_profile_heading: 'Edit profile' - profile_heading: 'Profile' + profile_settings_heading: 'Profile settings' + edit_profile_settings_heading: 'Edit profile settings' social_accounts: attributes: social_network: 'Social network' diff --git a/config/routes.rb b/config/routes.rb index 622e430..8b53e8f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,6 +9,7 @@ resources :users, only: %i[show edit update index] do patch 'status', to: 'users#update_status', as: 'update_status', on: :member + get :edit_profile, on: :member resources :social_accounts get 'search', to: 'users#search', on: :collection resources :contacts, only: %i[index] diff --git a/spec/features/user_edit_profile_picture_spec.rb b/spec/features/user_edit_profile_picture_spec.rb index 25e7731..4fb3f71 100644 --- a/spec/features/user_edit_profile_picture_spec.rb +++ b/spec/features/user_edit_profile_picture_spec.rb @@ -12,7 +12,7 @@ it 'is possible to upload a profile picture' do sign_in user - visit edit_user_path(user) + visit edit_profile_user_path(user) attach_file 'user_avatar', 'spec/support/assets/new-avatar.jpeg' click_button 'Update User' visit user_path(user) @@ -21,7 +21,7 @@ it 'is not possible to upload a picture larger than 5 MB' do sign_in user - visit edit_user_path(user) + visit edit_profile_user_path(user) attach_file 'user_avatar', 'spec/support/assets/avatar-big.jpeg' click_button 'Update User' expect(page).to have_text('Avatar File size should be less than 5 MB') @@ -29,7 +29,7 @@ it 'is not possible to upload files with arbitrary extensions' do sign_in user - visit edit_user_path(user) + visit edit_profile_user_path(user) attach_file 'user_avatar', 'spec/support/assets/avatar.gif' click_button 'Update User' expect(page).to have_text('Avatar is not a valid file format') diff --git a/spec/requests/users/users_update_spec.rb b/spec/requests/users/users_update_spec.rb index c0ba249..ba1f13c 100644 --- a/spec/requests/users/users_update_spec.rb +++ b/spec/requests/users/users_update_spec.rb @@ -21,7 +21,7 @@ let(:attributes) { super().merge(username: '') } it 'renders the user edit page' do - expect(response).to render_template(:edit) + expect(response).to render_template(:edit_profile) end end end