Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MaskyS created an issue. See original summary.

MaskyS’s picture

MaskyS’s picture

gvso’s picture

Status: Needs review » Needs work

I haven't tested it, but I found some issues with the code.

  1. +++ b/social_auth_amazon.install
    @@ -11,20 +11,13 @@ use Drupal\social_auth\Controller\SocialAuthController;
    -  $requirements = [];
    -
    -  // Social API should be installed at this point in order to check library.
    -  \Drupal::service('module_installer')->install(['social_api']);
    -
    -  if ($phase == 'install') {
         $requirements = SocialApiImplementerInstaller::checkLibrary('social_auth_amazon', 'Social Auth Amazon', 'luchianenco/oauth2-amazon', 1.1, 1.1);
    -  }
    

    I don't think we should deal with this issue here.

  2. +++ b/social_auth_amazon.install
    @@ -43,3 +36,16 @@ function social_auth_amazon_install() {
    +/**
    + * Implements hook_update_N().
    + *
    + * The key api_calls was changed to endpoints. This update copies the values
    + * in 'api_calls' to 'endpoints'.
    + */
    +function social_auth_amazon_update_8201(&$sandbox) {
    +  $config = \Drupal::configFactory()->getEditable('social_auth_amazon.settings');
    +  $endpoints = $config->get('api_calls');
    +
    +  $config->set('endpoints', $endpoints)->save();
    +}
    

    We might not need this since there's no a release for Social Auth Amazon yet and no site is using the module

  3. +++ b/src/Controller/AmazonAuthController.php
    @@ -172,27 +172,15 @@ class AmazonAuthController extends ControllerBase {
    +    return $this->userManager->authenticateUser($profile->getName(), $profile->getEmail(), $profile->getId(), $this->amazonManager->getAccessToken(), json_encode($data));
    

    Should be just $data instead of json_encode($data)

  4. +++ b/src/Form/AmazonAuthSettingsForm.php
    @@ -115,19 +115,27 @@ class AmazonAuthSettingsForm extends SocialAuthSettingsForm {
    +      '#description' => $this->t('Define the requested scopes to make API calls, separated by a comma. The scopes \'profile\' is added by default and always requested.<br> See the <a href="https://developer.amazon.com/docs/login-with-amazon/customer-profile.html">LWA API Guide</a> for a full list of scopes and their description.'),
    

    The description in the other implementers is slightly different.

  5. +++ b/src/Form/AmazonAuthSettingsForm.php
    @@ -115,19 +115,27 @@ class AmazonAuthSettingsForm extends SocialAuthSettingsForm {
    +                                  /user/repos|user_repos'),
    

    This needs to be an example from Amazon

Thanks!

MaskyS’s picture

Status: Needs work » Needs review
FileSize
10.51 KB
2.91 KB

Thanks for the review. Let's give it another try :)

gvso’s picture

Status: Needs review » Needs work

Thanks!

  1. +++ b/social_auth_amazon.install
    @@ -11,20 +11,13 @@ use Drupal\social_auth\Controller\SocialAuthController;
    -  $requirements = [];
    -
    -  // Social API should be installed at this point in order to check library.
    -  \Drupal::service('module_installer')->install(['social_api']);
    -
    -  if ($phase == 'install') {
         $requirements = SocialApiImplementerInstaller::checkLibrary('social_auth_amazon', 'Social Auth Amazon', 'luchianenco/oauth2-amazon', 1.1, 1.1);
    -  }
    

    These changes shouldn't be done in this issue. Leave the .install file as it is.

  2. +++ b/src/Form/AmazonAuthSettingsForm.php
    @@ -115,19 +115,29 @@ class AmazonAuthSettingsForm extends SocialAuthSettingsForm {
    +                                  <b>For instance:</b><br>
    +                                  /user/profile|user_profile'),
    

    This should be a semicolon.

ankitjain28may’s picture

Status: Needs work » Needs review
FileSize
9.56 KB
1.72 KB

Fixed as per comment #6

MaskyS’s picture

@ankitjain, there was a closing square bracket missing too so fixed it. Now, this just needs to be tested to see whether auth functionality is still working as intended.

gvso’s picture

Status: Needs review » Needs work

I just read Amazon docs, and they don't offer much in terms of scopes and endpoints. Why even bother adding those options in the form and AuthManager? Their service seems to be a simple 'login with' functionality, not a complete API such as Facebook's, Google's, Microsoft's, and others'.

Also, please test your changes before submitting patches. It's not fun to test patches that fail straightforward routines. Plus, you can not guarantee that a patch fixes an issue if you don't try it yourself.

  • gvso committed bd111c4 on 8.x-2.x
    Issue #2947737 by MaskyS, ankitjain28may: Implement new methods in...
gvso’s picture

Version: » 8.x-2.x-dev
Status: Needs work » Fixed

I considered this an important issue to make a beta release. We can keep improving the module if necessary later.

Thanks guys!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.