Sha256: 7351548b997d82f91acf4ba764044084de3722a4b72121b77c4b5612698c2e73

Contents?: true

Size: 1.51 KB

Versions: 1

Compression:

Stored size: 1.51 KB

Contents

# frozen_string_literal: true

module Overrides
  class PasswordsController < DeviseJwtAuth::PasswordsController
    OVERRIDE_PROOF = '(^^,)'

    # this is where users arrive after visiting the email confirmation link
    def edit
      @resource = resource_class.reset_password_by_token(
        reset_password_token: resource_params[:reset_password_token]
      )

      if @resource&.id
        # token = @resource.create_token

        # ensure that user is confirmed
        @resource.skip_confirmation! unless @resource.confirmed_at

        @resource.save!

        update_refresh_token_cookie
        redirect_header_options = {
          override_proof: OVERRIDE_PROOF,
          reset_password: true
        }
        redirect_headers = @resource.create_named_token_pair
                             .merge(redirect_header_options)
        redirect_to_link = DeviseJwtAuth::Url.generate(params[:redirect_url], redirect_headers)
        redirect_to redirect_to_link

        # redirect_header_options = {
        #   override_proof: OVERRIDE_PROOF,
        #   reset_password: true
        # }
        # redirect_headers = build_redirect_headers(token.token,
        #                                           token.client,
        #                                           redirect_header_options)
        # redirect_to(@resource.build_auth_url(params[:redirect_url],
        #                                      redirect_headers))
      else
        raise ActionController::RoutingError, 'Not Found'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
devise_jwt_auth-0.1.6 test/dummy/app/controllers/overrides/passwords_controller.rb