Class: DeviseTokenAuth::UnlocksController
- Inherits:
-
ApplicationController
- Object
- DeviseController
- ApplicationController
- DeviseTokenAuth::UnlocksController
- Defined in:
- app/controllers/devise_token_auth/unlocks_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
this action is responsible for generating unlock tokens and sending emails.
- #show ⇒ Object
Methods inherited from ApplicationController
#resource_data, #resource_errors
Instance Method Details
#create ⇒ Object
this action is responsible for generating unlock tokens and sending emails
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/unlocks_controller.rb', line 9 def create return render_create_error_missing_email unless resource_params[:email] @email = get_case_insensitive_field_from_resource_params(:email) @resource = find_resource(:email, @email) if @resource yield @resource if block_given? @resource.send_unlock_instructions( email: @email, provider: 'email', client_config: params[:config_name] ) if @resource.errors.empty? return render_create_success else render_create_error @resource.errors end else render_not_found_error end end |
#show ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/devise_token_auth/unlocks_controller.rb', line 34 def show @resource = resource_class.unlock_access_by_token(params[:unlock_token]) if @resource.persisted? token = @resource.create_token @resource.save! yield @resource if block_given? = { unlock: true } redirect_headers = build_redirect_headers(token.token, token.client, ) redirect_to(@resource.build_auth_url(after_unlock_path_for(@resource), redirect_headers)) else render_show_error end end |