Class: DeviseTokenAuth::ConfirmationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/devise_token_auth/confirmations_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#resource_data, #resource_errors

Instance Method Details

#showObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/devise_token_auth/confirmations_controller.rb', line 5

def show
  @resource = resource_class.confirm_by_token(params[:confirmation_token])

  if @resource.errors.empty?
    yield @resource if block_given?

    redirect_header_options = { account_confirmation_success: true }

    # give redirect value from params priority or fall back to default value if provided
    redirect_url = params[:redirect_url] || DeviseTokenAuth.default_confirm_success_url

    if signed_in?(resource_name)
      client_id, token = signed_in_resource.create_token

      redirect_headers = build_redirect_headers(token,
                                                client_id,
                                                redirect_header_options)

      redirect_to_link = signed_in_resource.build_auth_url(redirect_url, redirect_headers)
    else
      redirect_to_link = DeviseTokenAuth::Url.generate(redirect_url, redirect_header_options)
   end

    redirect_to(redirect_to_link)
  else
    raise ActionController::RoutingError, 'Not Found'
  end
end