diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 0045ed1a..87105b75 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -16,19 +16,13 @@ def create begin authorization = Authorization.handle_authorization(current_user, request.env['omniauth.auth']) sign_in(authorization.user) - options = { notice: t('flash.logged_in', name: current_user.name) } + user_name = current_user.missing_name? ? '' : current_user.name + options = { notice: t('flash.logged_in', name: user_name) } rescue User::DuplicateNickname => e options = { alert: t('flash.duplicate_nick', name: e.nickname) } end - redirect_path = request.env['omniauth.origin'].presence || root_path - - if current_user&.missing_name? - options = { alert: t('flash.update_profile_details') } - redirect_path = edit_user_path(current_user) - end - - redirect_to redirect_path, options + redirect_to request.env['omniauth.origin'].presence || root_path, options end def destroy diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c6b24a9e..588bb83f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -88,7 +88,7 @@ def hint(close = true) end def user_name(user) - user.missing_name? ? '-' : user.name + user.display_name end private diff --git a/app/models/user.rb b/app/models/user.rb index de0e9bb0..f425c618 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -123,6 +123,10 @@ def missing_name? name == EMPTY_NAME end + def display_name + missing_name? ? '-' : name + end + class DuplicateNickname < StandardError attr_reader :nickname diff --git a/app/views/application/_hint.slim b/app/views/application/_hint.slim index 175a1357..6544c5f6 100644 --- a/app/views/application/_hint.slim +++ b/app/views/application/_hint.slim @@ -25,3 +25,11 @@ li.mb-4 span.job-toggle= link_to fa_icon("chevron-up"), '#', title: t("hint.click_to_refresh") if index == 0 .job.ml-4== job_description(job) + +- if current_user&.missing_name? + = hint(false) do + .highlights + => fa_icon("exclamation-triangle") + strong=> t("flash.update_profile_details") + - unless current_page?(edit_user_path(current_user)) + = link_to t("login.edit_profile"), edit_user_path(current_user) diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index b86d9518..5cb69a29 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -62,13 +62,5 @@ expect(response).to have_http_status(:unprocessable_entity) end end - - context 'GET :create' do - it 'creates the user and redirects to edit', :aggregate_failures do - get :create, params: { provider: :email } - expect(controller.send(:signed_in?)).to be_truthy - expect(response).to redirect_to(edit_user_path(User.last)) - end - end end end