You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tmikoss/accounts-eveonline#4
Currently I'm stuck providing currently logged in user, since you want that if person first created account with passwords and then is adding chars. The accounts.js is outdated.
// import Accounts from 'accounts-base'
var Ap = Accounts.updateOrCreateUserFromExternalService
Meteor.startup(function(){
Accounts.updateOrCreateUserFromExternalService = function (
serviceName,
serviceData,
options
) {
if (serviceName == "eveonline") {
var selector = {}
var serviceIdKey = "services.eveonline.list.name"
selector[serviceIdKey] = serviceData.name;
var user = this.users.findOne(selector);
// if (serviceData.serviceData.name == "list") {
// throw new Error("You're black sheep")
// }
//check that user on record is not previoius owner
if (!!user && user.services.eveonline[serviceData.name].eveAccount != serviceData.eveAccount){
EveonlineHelpers.changeOwnerShip(user._id, serviceData.name)
// XXX would ideally conduct these operations within update operation instead of js
delete user.services.eveonline[serviceData.name]
user.services.eveonline.list.filter((x)=>{
return x.name == serviceData.name
})
this.users.update(user._id, {
$set: {
"services.eveonline": user.services.eveonline
}
})
user = false
}
var abc = user()
console.log(abc)
//make sure that if previous owner exists, new user is created
if (!!abc && user != false) {
user = abc
}
if (user) {
console.log("UPDATING USER")
pinEncryptedFieldsToUser(serviceData, user._id);
// We *don't* process options (eg, profile) for update, but we do replace
// the serviceData (eg, so that we keep an unexpired access token and
// don't cache old email addresses in serviceData.email).
// XXX provide an onUpdateUser hook which would let apps update
// the profile too
var setAttrs = {};
_.each(serviceData, function (value, key) {
setAttrs["services.eveonline."+ serviceData.name +"."+ key] = value;
});
// XXX Maybe we should re-use the selector above and notice if the update
// touches nothing?
if(serviceName=="eveonline") {
this.users.update(user._id, {
$set: setAttrs,
$addToSet: {"services.eveonline.list": {name: serviceData.name, id: serviceData.id}}
});
}
return {
type: serviceName,
userId: user._id
};
} else {
console.log("CREATING USER", abc)
// Create a new user with the service data. Pass other options through to
// insertUserDoc.
user = {services: {}};
user.services[serviceName] = {list: [{name: serviceData.name, id: serviceData.id}]};
user.services[serviceName][serviceData.name] = serviceData
return {
type: serviceName,
userId: this.insertUserDoc(options, user)
};
}
/// XXX beginning of common/original SSO
} else {
Ap(
serviceName,
serviceData,
options
)
}
};
})
function pinEncryptedFieldsToUser(serviceData, userId) {
_.each(_.keys(serviceData), function (key) {
var value = serviceData[key];
if (OAuthEncryption && OAuthEncryption.isSealed(value))
value = OAuthEncryption.seal(OAuthEncryption.open(value), userId);
serviceData[key] = value;
});
}
and ye, I made a couple of mistakes in other files.
The text was updated successfully, but these errors were encountered:
tmikoss/accounts-eveonline#4
Currently I'm stuck providing currently logged in user, since you want that if person first created account with passwords and then is adding chars. The accounts.js is outdated.
and ye, I made a couple of mistakes in other files.
The text was updated successfully, but these errors were encountered: