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

New Auth Method Added. #4484

Closed
wants to merge 32 commits into from
Closed

New Auth Method Added. #4484

wants to merge 32 commits into from

Conversation

kenglou
Copy link

@kenglou kenglou commented Jan 5, 2018

Added the following Authentication Provider:

  1. Game Center.
  2. Google Play Game Services.
  3. Xiao Mi

1. add google Play Games Authentication Method(different from Google due to GPG is using a new ID method).
2. add Game Center Authentication Method. By refering to the URL that provided: https://developer.apple.com/documentation/gamekit/gklocalplayer/1515407-generateidentityverificationsign?language=objc
check using the funciton hasOwnProperty.
fix error for Google Play Games.
Temporary enable this to allow PR Success
1. remove old rest.spec test as it is actually wrong.
2. added the test at AuthenticationAdapters.spec.js.
3. put back the index.js change to search for where to change exactly.
@codecov
Copy link

codecov bot commented Jan 5, 2018

Codecov Report

Merging #4484 into master will decrease coverage by 0.82%.
The diff coverage is 40%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4484      +/-   ##
==========================================
- Coverage    92.8%   91.97%   -0.83%     
==========================================
  Files         118      121       +3     
  Lines        8394     8515     +121     
==========================================
+ Hits         7790     7832      +42     
- Misses        604      683      +79
Impacted Files Coverage Δ
src/Adapters/Auth/index.js 92.85% <100%> (+0.7%) ⬆️
src/Adapters/Auth/gcenter.js 20.37% <20.37%> (ø)
src/Adapters/Auth/gpgames.js 36.36% <36.36%> (ø)
src/Adapters/Auth/xiaomi.js 51.72% <51.72%> (ø)
...dapters/Storage/Postgres/PostgresStorageAdapter.js 97.01% <0%> (-0.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 33890bb...2f954c1. Read the comment docs.


var _AdapterLoader2 = _interopRequireDefault(_AdapterLoader);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
Copy link
Member

@dplewis dplewis Jan 10, 2018

Choose a reason for hiding this comment

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

Looks like you copied compiled babel. Doesn't look like something humans write.

xiaomi
};

function authDataValidator(adapter, appIds, options)
Copy link
Member

Choose a reason for hiding this comment

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

Sticking to the current coding style / ES6 would be ideal.

}

function loadAuthAdapter(provider, authOptions) {
const defaultAdapter = providers[provider];
const adapter = Object.assign({}, defaultAdapter);
const providerOptions = authOptions[provider];

if (!defaultAdapter && !providerOptions) {
if (!defaultAdapter && !providerOptions)
Copy link
Member

Choose a reason for hiding this comment

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

Its recommended to always use brackets for if / else statements. Without them they can lead to bugs. You might want to go over your code again for consistency


const appIds = providerOptions ? providerOptions.appIds : undefined;

// Try the configuration methods
if (providerOptions) {
const optionalAdapter = loadAdapter(providerOptions, undefined, providerOptions);
const optionalAdapter = (0, _AdapterLoader2.default)(providerOptions, undefined, providerOptions);
Copy link
Member

Choose a reason for hiding this comment

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

Babel

@kenglou
Copy link
Author

kenglou commented Jan 15, 2018

already changed accordingly. Please let me know if there is anything else.

Copy link
Author

@kenglou kenglou left a comment

Choose a reason for hiding this comment

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

changes made.

Copy link
Contributor

@montymxb montymxb left a comment

Choose a reason for hiding this comment

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

There's a lot of things that need to be changed here. For starters if you can undo those stylistic changes that will make it much easier for us to stay focused on just the functional changes you're introducing.

If you do feel you want to introduce stylistic changes to existing code, and have justification for doing so, feel free to open up a separate PR specifically for doing that.

::edit:: Additionally diff coverage by this PR is negative. You'll need to inspect the coverage results and account for untested code paths, which may involve adjusting your code to make it testable.

return adapter.validateAppId(appIds, authData, options);
}
return Promise.resolve();
});
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you revert these style changes?

Generally you should avoid unnecessary stylistic changes when adding a feature unless it's part of the change itself (i.e. specifically a stylistic change PR). In this case it's superfluous and adds to what we have to review. It'll make it much easier for us to go through and review your changes if they're only functional changes.

@@ -70,7 +78,7 @@ function loadAuthAdapter(provider, authOptions) {
if (providerOptions) {
const optionalAdapter = loadAdapter(providerOptions, undefined, providerOptions);
if (optionalAdapter) {
['validateAuthData', 'validateAppId'].forEach((key) => {
['validateAuthData', 'validateAppId'].forEach(key => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. This can and should be suggested separately.

@@ -82,18 +90,26 @@ function loadAuthAdapter(provider, authOptions) {
return;
}

return {adapter, appIds, providerOptions};
return { adapter, appIds, providerOptions };
Copy link
Contributor

Choose a reason for hiding this comment

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

and here

// To handle the test cases on configuration
const getValidatorForProvider = function(provider) {
const getValidatorForProvider = function (provider)
{
Copy link
Contributor

Choose a reason for hiding this comment

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

and above here

})
}
});
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Not needed for this PR, let's kept it focused on what you're actually introducing.

src/Adapters/Auth/gcenter.js Show resolved Hide resolved

// Returns a promise that fulfills if this user id is valid.
function validateAuthData(authData, authOptions)
{
Copy link
Contributor

Choose a reason for hiding this comment

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

again, keep the curly braces up on the same line. It's inconsistent throughout this file as well if you can amend that.

var crypto = require('crypto');

const PRODUCTION_URL = "https://cn-api.unity.com";
const DEBUG_URL = " https://cn-api-debug.unity.com";
Copy link
Contributor

Choose a reason for hiding this comment

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

This url doesn't seem right, xiaomi is unity? Can you clarify this 3rd party provider and the urls?

@stale
Copy link

stale bot commented Sep 18, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

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.

4 participants