confirmations_controller.rb 1.14 KB
Newer Older
1 2
# frozen_string_literal: true

3
class ConfirmationsController < Devise::ConfirmationsController
4
  include AcceptsPendingInvitations
5

6
  feature_category :users
7

Phil Hughes's avatar
Phil Hughes committed
8 9 10 11 12
  def almost_there
    flash[:notice] = nil
    render layout: "devise_empty"
  end

13 14
  protected

Phil Hughes's avatar
Phil Hughes committed
15
  def after_resending_confirmation_instructions_path_for(resource)
16 17
    return users_almost_there_path unless Feature.enabled?(:soft_email_confirmation)

18
    stored_location_for(resource) || dashboard_projects_path
Phil Hughes's avatar
Phil Hughes committed
19 20
  end

Brett Walker's avatar
Brett Walker committed
21
  def after_confirmation_path_for(resource_name, resource)
22 23
    accept_pending_invitations

24 25
    # incoming resource can either be a :user or an :email
    if signed_in?(:user)
26
      after_sign_in(resource)
27
    else
28
      Gitlab::AppLogger.info("Email Confirmed: username=#{resource.username} email=#{resource.email} ip=#{request.remote_ip}")
29
      flash[:notice] = flash[:notice] + _(" Please sign in.")
30
      new_session_path(:user, anchor: 'login-pane', invite_email: resource.email)
31 32
    end
  end
33 34 35 36

  def after_sign_in(resource)
    after_sign_in_path_for(resource)
  end
37 38 39 40

  def context_user
    resource
  end
41
end
42

43
ConfirmationsController.prepend_mod_with('ConfirmationsController')