Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default_confirm_success_url fails in initializer #223

Closed
hiattp opened this issue Apr 23, 2015 · 14 comments
Closed

default_confirm_success_url fails in initializer #223

hiattp opened this issue Apr 23, 2015 · 14 comments

Comments

@hiattp
Copy link

hiattp commented Apr 23, 2015

When I try to set this in the init I get:

undefined method `default_confirm_success_url=' for DeviseTokenAuth:Module (NoMethodError)
@ArneZsng
Copy link
Contributor

Probably not the way its supposed to be but does

  public
    def default_confirm_success_url
      "http://localhost:3000"
    end

help?

@hiattp
Copy link
Author

hiattp commented Apr 27, 2015

Yeah could override but I'd rather the initializer function correctly to prevent confusion in the future.

@gabrielhilal
Copy link

@hiattp How did you override that?

@hiattp
Copy link
Author

hiattp commented Aug 6, 2015

@gabrielhilal We ended up overriding most of the controllers that come with this gem entirely so didn't need to override that particular setting.

@gabrielhilal
Copy link

After updating to version 0.1.32 I was able to use config.default_confirm_success_url ;)

@CJYate
Copy link

CJYate commented Jan 5, 2017

Seems like a similar issue:

Using 0.1.39 I'm hitting a 422 return value because there's no confirm_success_url defined.

Pry output:

   19:       # give redirect value from params priority
 => 20:       @redirect_url = params[:confirm_success_url]
    21: 
    22:       # fall back to default value if provided
   23:       @redirect_url ||= DeviseTokenAuth.default_confirm_success_url
[2] pry(#<ModelAuth::RegistrationsController>)> params
=> <ActionController::Parameters {"email"=>"[email protected]", "password"=>"qwertyuiop", "password_confirmation"=>"qwertyuiop", "controller"=>"model_auth/registrations", "action"=>"create"} permitted: false>
[3] pry(#<ModelAuth::RegistrationsController>)> DeviseTokenAuth.default_confirm_success_url
=> nil
[4] pry(#<ModelAuth::RegistrationsController>)> 

I've overridden the controller in order to break into the debugger in the sign_up method.

This is occurring in a Request spec that looks like:

    describe 'POST /api/model_auth (Sign Up process)', focus: :true do
        it 'Should respond with status 200(OK)' do
            post model_registration_path(email: '[email protected]', password: 'qwertyuiop', password_confirmation: 'qwertyuiop')
            expect(response).to have_http_status(200)
        end

        it 'Should add a new model' do
            expect do
                post model_registration_path(email: '[email protected]', password: 'qwertyuiop')
            end.to change(model, :count).by(1)
        end
    end

Any ideas? Shouldn't the default_confirm_success_url be set to something by default?
... And I don't think an API call should be redirecting in any case (?!)

@CJYate
Copy link

CJYate commented Jan 5, 2017

I added the following to my config/initializers/devise_token_auth.rb

DeviseTokenAuth.setup do |config|
  config.default_confirm_success_url = "http://localhost"
end

But this isn't very nice just to support a test. Should my Angular Javascript front end be passing this value as a parameter? Will this happen by default if I'm using ng-token-auth?

@CJYate
Copy link

CJYate commented Jan 5, 2017

May be fixed by this
#803

Also see a related issue
#241

@jomarbarnobal
Copy link

seem like doesnt work in me

i change the the url but still dont work, do i need to update my gem ?

@CJYate
Copy link

CJYate commented Jan 14, 2017

@jomarbarnobal you might want to try out my fork of this project. It contains the Pull Request that I think fixes this problem.

If you find it helps, you could help apply a little pressure to one of the maintainers to merge my PR! ;-)

@jomarbarnobal
Copy link

I made it work!.
I look at angular2-token documentation, and they have a callback for confirm-success-url

thanks a lot for you response.

@stephanebruckert
Copy link

Or you can just do:

# initializer/devise_token_auth.rb
DeviseTokenAuth.setup do |config|
    config.default_confirm_success_url = "confirmed"
end

@luannguyenkhoa
Copy link

luannguyenkhoa commented Oct 2, 2017

@stephanebruckert
I added it but through error

Processing by DeviseTokenAuth::RegistrationsController#create as */*                                                        │Using rspec 3.6.0
  Parameters: {"email"=>"[email protected]", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}                  │Using rails-dom-testing 2.0.3
   (0.1ms)  BEGIN                                                                                                           │Using globalid 0.4.0
   (0.1ms)  ROLLBACK                                                                                                        │Using activemodel 5.0.6
Completed 500 Internal Server Error in 167ms (ActiveRecord: 2.3ms)                                                          │Using case_transform 0.2
                                                                                                                            │Using factory_girl 4.8.0
                                                                                                                            │Using pundit 1.1.0
                                                                                                                            │Using shoulda-callback-matchers 1.1.4
ArgumentError (wrong number of arguments (given 0, expected 1)):

@MaicolBen
Copy link
Collaborator

Closing as it seems old, @luannguyenkhoa it seems another error, free feel to open a new issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants