plz support save email faild on log in with Oath types #2942
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
could you plz support save email failed on log in with oath types and mack user log with the same email if it is already log in with other Oauth
also could you plz add support make username as email
thanks
my code on cloud for google that do this behave
var AppValues = require('./controllers/AppValues.js');
var _ = require('underscore');
var Buffer = require('buffer').Buffer;
var clientsIds = [AppValues.iOSGoogleserverClientsId,AppValues.AndroidGoogleserverClientsId];
var googleValidateEndpoint = 'https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=';
Parse.Cloud.define('accessGoogleUser', function(req, res) {
Parse.Cloud.useMasterKey()
});
var callTokenInfoEndPoint = function(accessToken) {
return Parse.Cloud.httpRequest({
url: googleValidateEndpoint + accessToken
});
};
var upsertGoogleUser = function(accessToken, userId,email,name,AnonymousUser,exp) {
var userquery = new Parse.Query(Parse.User);
userquery.equalTo('email', email);
return userquery.first({useMasterKey: true}).then(function(user) {
if (!user) {
return newGoogleUser(accessToken,email,name,userId,AnonymousUser,exp);
}
return user.fetch({useMasterKey: true}).then(function(user) {
var password = new Buffer(24);
_.times(24, function(i) {
password[i]= _.random(0, 255);
});
user.setPassword(password.toString('base64'));
user.set('googleId', {"id":userId})
if(user.get("nikName")=="U"){
user.set("nikName",name)
}
return SaveAndLogIn(accessToken,email,name,userId,user,exp,password.toString('base64'))
};
var SaveAndLogIn = function(accessToken,email,name,userId,user,exp,password) {
return user.save(null,{useMasterKey: true}).then(function(user){
return Parse.User.logIn(user.getUsername(), password)
}).then(function(usere) {
return unlinkFromAnonymous(usere,userId,accessToken,exp);
});
};
var newGoogleUser = function(accessToken,email,name,userId,AnonymousUser,exp) {
var user;
};
var upsetUser = function(accessToken,email,name,userId,user,exp) {
var password = new Buffer(24);
_.times(24, function(i) {
password[i]= _.random(0, 255);
});
user.set("username", email);
user.set("password", password.toString('base64'));
user.set("nikName", name);
user.set("email", email);
user.set('googleId', {"id":userId})
return user.signUp().then(function(usere) {
return unlinkFromAnonymous(usere,userId,accessToken,exp);
});
};
var liknWithgoogle = function(user,userId,accessToken,exp) {
};
var unlinkFromAnonymous = function(user,userId,accessToken,exp) {
if(user._isLinked('anonymous')){
};
var AnonymousProvider = {
getAuthType: function () {
return 'anonymous';
},
restoreAuthentication: function () {
return true;
},
};