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

#createObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/devise_token_auth/confirmations_controller.rb', line 32

def create
  return render_create_error_missing_email if resource_params[:email].blank?

  @email = get_case_insensitive_field_from_resource_params(:email)

  @resource = resource_class.dta_find_by(uid: @email, provider: provider)

  return render_not_found_error unless @resource

  @resource.send_confirmation_instructions({
    redirect_url: redirect_url,
    client_config: resource_params[:config_name]
  })

  return render_create_success
end

#showObject



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
# File 'app/controllers/devise_token_auth/confirmations_controller.rb', line 6

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

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

    redirect_header_options = { account_confirmation_success: true }

    if signed_in?(resource_name)
      token = signed_in_resource.create_token

      redirect_headers = build_redirect_headers(token.token,
                                                token.client,
                                                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