-
Notifications
You must be signed in to change notification settings - Fork 0
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
API for social login #1
Conversation
include Spree::Core::ControllerHelpers::Common | ||
include Spree::Core::ControllerHelpers::Order | ||
include Spree::Core::ControllerHelpers::Auth | ||
include Spree::Core::ControllerHelpers::Store |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need all of these modules?
skip_before_action :verify_authenticity_token | ||
|
||
def login | ||
eligible_providers = SpreeSocial::OAUTH_PROVIDERS.map { |p| p[1] if p[2] == 'true' }.compact |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't there any helper method for this available yet? does not look like it really belongs to login method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to use more sensible variable names instead of p?
eligible_providers = SpreeSocial::OAUTH_PROVIDERS.map { |p| p[1] if p[2] == 'true' }.compact | ||
|
||
if !(eligible_providers.include?(auth_hash['provider'])) | ||
render json: {error: I18n.t('devise.omniauth_callbacks.provider_not_found', kind: auth_hash['provider'])}, status: :unprocessable_entity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use failure_message method from https://github.com/heartcombo/devise/blob/master/app/controllers/devise/omniauth_callbacks_controller.rb ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should be able to just raise error and base controller should be able to handle the exceptions..
we have lots of things going inside this action
config/routes.rb
Outdated
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
last line missing
@shradhaN you have sensitive information in above description, We have checked this change and is working for us, you can create pr in spree-contrib's repo as well. Thank you |
we will also need documentation in repo for this :D |
API endpoint:
{base_url}/v1/spree_oauth/social_login/:provider
method: POST
Request Body:
Response Body: