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

Edit RegistrationsController#create to use ResourceFinder::provider #998

Merged
merged 3 commits into from
Oct 27, 2017

Conversation

m4-miranda
Copy link
Contributor

As discussed in comments of #997,
I've added a provider paramter to find_resource method. I've updated the calls to find_resource method in passwords controller:

@resource = find_resource(:uid, @email, provider)

sessions controller:

@resource = find_resource(field, q_value, provider)

Unlocks controller, I assume, would require an 'email' provider hence I've hardcoded the paramter there:

@resource = find_resource(:email, @email, 'email')

P.S I'm fairly new to devise_token_auth and devise in general so not sure about the best practices etc.
@MaicolBen @zachfeldman

@zachfeldman zachfeldman self-assigned this Oct 27, 2017
@zachfeldman zachfeldman self-requested a review October 27, 2017 15:25
Copy link
Contributor

@zachfeldman zachfeldman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a problem with these changes, they're fairly straightforward.

Copy link
Collaborator

@MaicolBen MaicolBen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your PR!

@@ -12,10 +12,9 @@ def get_case_insensitive_field_from_resource_params(field)
q_value
end

def find_resource(field, value)
def find_resource(field, value, provider)
Copy link
Collaborator

@MaicolBen MaicolBen Oct 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why the parameter, this won't call the method.

UPDATE: I tested this PR locally and breaks, I would remove this and just use the method

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, could you help me out with how to go about overriding the concern in my project that utilises this repo? I would write a concern that extends DeviseTokenAuth::Concerns::ResourceFinder with a def provider and override the controllers to include customResourceFinder. Is this right?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that won't work, you need to create a concern with def provider in there and add that concern in each override controller. But if you need to add it to the registrations controller, you add it there. But you need to add PR here with only this:
screen shot 2017-10-27 at 12 56 28 pm

Copy link
Collaborator

@MaicolBen MaicolBen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the commit message and PR title because now you aren't changing the parameter of find_resource

@@ -28,7 +28,7 @@ def create
end

@email = get_case_insensitive_field_from_resource_params(:email)
@resource = find_resource(:uid, @email)
@resource = find_resource(:uid, @email, provider)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to remove from here

Copy link
Collaborator

@MaicolBen MaicolBen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I will change the commit message from here

@MaicolBen MaicolBen merged commit 915058a into lynndylanhurley:master Oct 27, 2017
@m4-miranda m4-miranda changed the title Added provider parameter to find_resource Edit RegistrationsController#create to use ResourceFinder::provider Oct 27, 2017
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

Successfully merging this pull request may close these issues.

3 participants