• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mgmodell / devise_token_auth_multi_email / #480

06 Mar 2026 02:20AM UTC coverage: 12.235% (-79.0%) from 91.231%
#480

push

mgmodell
version bump and test flow update

0 of 1 new or added line in 1 file covered. (0.0%)

1356 existing lines in 24 files now uncovered.

202 of 1651 relevant lines covered (12.24%)

0.4 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/controllers/devise_token_auth/unlocks_controller.rb
1
# frozen_string_literal: true
2

UNCOV
3
module DeviseTokenAuth
×
UNCOV
4
  class UnlocksController < DeviseTokenAuth::ApplicationController
×
UNCOV
5
    skip_after_action :update_auth_header, only: [:create, :show]
×
6

7
    # this action is responsible for generating unlock tokens and
8
    # sending emails
UNCOV
9
    def create
×
UNCOV
10
      return render_create_error_missing_email unless resource_params[:email]
×
11

UNCOV
12
      @email = get_case_insensitive_field_from_resource_params(:email)
×
UNCOV
13
      @resource = find_resource(:email, @email)
×
14

UNCOV
15
      if @resource
×
UNCOV
16
        yield @resource if block_given?
×
17

UNCOV
18
        @resource.send_unlock_instructions(
×
UNCOV
19
          email: @email,
×
UNCOV
20
          provider: 'email',
×
UNCOV
21
          client_config: params[:config_name]
×
UNCOV
22
        )
×
23

UNCOV
24
        if @resource.errors.empty?
×
UNCOV
25
          return render_create_success
×
UNCOV
26
        else
×
27
          render_create_error @resource.errors
×
UNCOV
28
        end
×
UNCOV
29
      else
×
UNCOV
30
        render_not_found_error
×
UNCOV
31
      end
×
UNCOV
32
    end
×
33

UNCOV
34
    def show
×
UNCOV
35
      @resource = resource_class.unlock_access_by_token(params[:unlock_token])
×
36

UNCOV
37
      if @resource.persisted?
×
UNCOV
38
        token = @resource.create_token
×
UNCOV
39
        @resource.save!
×
UNCOV
40
        yield @resource if block_given?
×
41

UNCOV
42
        redirect_header_options = { unlock: true }
×
UNCOV
43
        redirect_headers = build_redirect_headers(token.token,
×
UNCOV
44
                                                  token.client,
×
UNCOV
45
                                                  redirect_header_options)
×
UNCOV
46
        redirect_to(@resource.build_auth_url(after_unlock_path_for(@resource),
×
UNCOV
47
                                             redirect_headers),
×
UNCOV
48
                                             redirect_options)
×
UNCOV
49
      else
×
UNCOV
50
        render_show_error
×
UNCOV
51
      end
×
UNCOV
52
    end
×
53

UNCOV
54
    private
×
UNCOV
55
    def after_unlock_path_for(resource)
×
56
      #TODO: This should probably be a configuration option at the very least.
UNCOV
57
      '/'
×
UNCOV
58
    end
×
59

UNCOV
60
    def render_create_error_missing_email
×
UNCOV
61
      render_error(401, I18n.t('devise_token_auth.unlocks.missing_email'))
×
UNCOV
62
    end
×
63

UNCOV
64
    def render_create_success
×
UNCOV
65
      render json: {
×
UNCOV
66
        success: true,
×
UNCOV
67
        message: success_message('unlocks', @email)
×
UNCOV
68
      }
×
UNCOV
69
    end
×
70

UNCOV
71
    def render_create_error(errors)
×
72
      render json: {
×
UNCOV
73
        success: false,
×
UNCOV
74
        errors: errors
×
UNCOV
75
      }, status: 400
×
UNCOV
76
    end
×
77

UNCOV
78
    def render_show_error
×
UNCOV
79
      raise ActionController::RoutingError, 'Not Found'
×
UNCOV
80
    end
×
81

UNCOV
82
    def render_not_found_error
×
UNCOV
83
      if Devise.paranoid
×
UNCOV
84
        render_create_success
×
UNCOV
85
      else
×
UNCOV
86
        render_error(404, I18n.t('devise_token_auth.unlocks.user_not_found', email: @email))
×
UNCOV
87
      end
×
UNCOV
88
    end
×
89

UNCOV
90
    def resource_params
×
UNCOV
91
      params.permit(:email, :unlock_token, :config)
×
UNCOV
92
    end
×
UNCOV
93
  end
×
UNCOV
94
end
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc