Sha256: 256a2dede68c68712967549685eebae65ca42e48abe25dba0e551a715a4cd53d

Contents?: true

Size: 1.2 KB

Versions: 41

Compression:

Stored size: 1.2 KB

Contents

module Overrides
  class PasswordsController < DeviseTokenAuth::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 and @resource.id
        client_id  = SecureRandom.urlsafe_base64(nil, false)
        token      = SecureRandom.urlsafe_base64(nil, false)
        token_hash = BCrypt::Password.create(token)
        expiry     = (Time.now + DeviseTokenAuth.token_lifespan).to_i

        @resource.tokens[client_id] = {
          token:  token_hash,
          expiry: expiry
        }

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

        @resource.save!

        redirect_to(@resource.build_auth_url(params[:redirect_url], {
          token:          token,
          client_id:      client_id,
          reset_password: true,
          config:         params[:config],
          override_proof: OVERRIDE_PROOF
        }))
      else
        raise ActionController::RoutingError.new('Not Found')
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 2 rubygems

Version Path
devise_token_auth-0.1.42 test/dummy/app/controllers/overrides/passwords_controller.rb
devise_token_auth-0.1.41 test/dummy/app/controllers/overrides/passwords_controller.rb
devise_token_auth-0.1.40 test/dummy/app/controllers/overrides/passwords_controller.rb
devise_token_auth-0.1.39 test/dummy/app/controllers/overrides/passwords_controller.rb
devise_token_auth-0.1.38 test/dummy/app/controllers/overrides/passwords_controller.rb
devise_token_auth-0.1.37 test/dummy/app/controllers/overrides/passwords_controller.rb
devise_token_auth-0.1.37.beta4 test/dummy/app/controllers/overrides/passwords_controller.rb
cm-devise_token_auth-0.1.30.1 test/dummy/app/controllers/overrides/passwords_controller.rb
devise_token_auth-0.1.37.beta3 test/dummy/app/controllers/overrides/passwords_controller.rb
devise_token_auth-0.1.37.beta2 test/dummy/app/controllers/overrides/passwords_controller.rb
devise_token_auth-0.1.37.beta1 test/dummy/app/controllers/overrides/passwords_controller.rb
devise_token_auth-0.1.36 test/dummy/app/controllers/overrides/passwords_controller.rb
devise_token_auth-0.1.35 test/dummy/app/controllers/overrides/passwords_controller.rb
devise_token_auth-0.1.34 test/dummy/app/controllers/overrides/passwords_controller.rb
devise_token_auth-0.1.33 test/dummy/app/controllers/overrides/passwords_controller.rb
devise_token_auth-0.1.32 test/dummy/app/controllers/overrides/passwords_controller.rb
devise_token_auth-0.1.32.beta10 test/dummy/app/controllers/overrides/passwords_controller.rb
devise_token_auth-0.1.32.beta9 test/dummy/app/controllers/overrides/passwords_controller.rb
devise_token_auth-0.1.32.beta8 test/dummy/app/controllers/overrides/passwords_controller.rb
devise_token_auth-0.1.32.beta7 test/dummy/app/controllers/overrides/passwords_controller.rb