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

Yandex & Mail.ru services #301

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open

Conversation

mche
Copy link

@mche mche commented Oct 30, 2016

Hi!

Push big russian Yandex and Mail.ru services.

@mche mche force-pushed the development branch 3 times, most recently from ea5da36 to 7feb3d7 Compare October 30, 2016 10:44
@mche mche changed the title Yandex service Yandex & Mail.ru services Oct 30, 2016
@mche mche force-pushed the development branch 2 times, most recently from 605d981 to 4d5ee0e Compare October 30, 2016 12:02
@nraboy
Copy link
Owner

nraboy commented Nov 3, 2016

Just to confirm, since I am not familiar with this service. You've tested it and it works great with your PR?

Once you confirm it is working, I'll merge it.

Referencing #299

@mche
Copy link
Author

mche commented Nov 4, 2016

Sorry for PR #299 there is incorrect response_type=code. Now works response_type=token.

Im recheck api and had tests works fine for this PR.

Copy link
Contributor

@matheusrocha89 matheusrocha89 left a comment

Choose a reason for hiding this comment

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

Besides my comments LGTM

if($cordovaOauthUtility.isInAppBrowserInstalled()) {
if(options === undefined) { options = {}; }
if(appScope === undefined) { appScope = []; }
if(! options.hasOwnProperty("redirect_uri")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[MINOR] remove the space after !

//~ deferred.reject({error: "You must set option redirect_uri that is an any url within YOUR DOMAIN! The redirect_uri:'http://localhost/callback' doesnt works."});
//~ return deferred.promise;
}
if(! options.hasOwnProperty("display")) {
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

if(! options.hasOwnProperty("display")) {
options.display = "mobile";
}
if(! options.hasOwnProperty("browserWindow")) {
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

}
var flowUrl = "https://connect.mail.ru/oauth/authorize?response_type=token&client_id=" + clientId + "&redirect_uri=" + options.redirect_uri + '&display=' + options.display + '&scope=' + appScope.join(" ");

var browserRef = window.cordova.InAppBrowser.open(flowUrl, '_blank', options.browserWindow);//,clearsessioncache=yes,clearcache=yes);
Copy link
Contributor

Choose a reason for hiding this comment

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

You can remove the comment since you are not using the code inside

browserRef.addEventListener('loadstart', function(event) {
if((event.url).indexOf(options.redirect_uri) === 0) {
browserRef.removeEventListener("exit",function(event){});
browserRef.close();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the indentation of this block of code is wrong.

var callbackResponse = (event.url).split("#")[1];
var responseParameters = (callbackResponse).split("&");
var parameterMap = {};
for(var i = 0; i < responseParameters.length; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can replace the for loop with a forEach and use some vars to let the code easier to understand. (Please test first cause I don't remember right now if the Array forEach is ES6 or ES5)

responseParameters.forEach(function(param) {
  var splittedParam = param.split('=');
  var mapKey = splittedParam[0];
  var mapValue = splittedParam[1];
  parameterMap[mapKey] = mapValue;
});

if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
deferred.resolve(parameterMap);
} else {
//~ deferred.reject("Problem authenticating");
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this comment

}
var flowUrl = "https://oauth.yandex.ru/authorize?response_type=token&client_id=" + clientId + "&redirect_uri=" + options.redirect_uri + "&force_confirm=" + options.force_confirm;

var browserRef = window.cordova.InAppBrowser.open(flowUrl, '_blank', options.browserWindow);//,clearsessioncache=yes,clearcache=yes
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

var callbackResponse = (event.url).split("#")[1];
var responseParameters = (callbackResponse).split("&");
var parameterMap = {};
for(var i = 0; i < responseParameters.length; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) {
deferred.resolve(parameterMap);
} else {
//~ deferred.reject("Problem authenticating");
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

@matheusrocha89
Copy link
Contributor

matheusrocha89 commented Nov 9, 2016

Great job @mche I Like the code. 👍 If it's working and after some changes I think this PR can be merged. @mche Thanks for your contribution

@nraboy
Copy link
Owner

nraboy commented Nov 10, 2016

Thanks @matheusrocha89

@mche
Copy link
Author

mche commented Nov 11, 2016

Ok, I had inspected the recomendations.

@nraboy
Copy link
Owner

nraboy commented Nov 12, 2016

We ready to merge?

@mche
Copy link
Author

mche commented Nov 14, 2016

Does my comments in README.md are clean? Or may be remove them?

@matheusrocha89
Copy link
Contributor

matheusrocha89 commented Nov 14, 2016

The comments for me are fine. I think you can remove the comments on the code and let them there on readme

@mche
Copy link
Author

mche commented Nov 15, 2016

@matheusrocha89 Im sorry but comments in code does needs like for me.

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