|
@@ -460,15 +460,31 @@ if (Meteor.isServer) {
|
|
}
|
|
}
|
|
|
|
|
|
if (user.services.oidc) {
|
|
if (user.services.oidc) {
|
|
|
|
+ var email = user.services.oidc.email.toLowerCase();
|
|
|
|
+
|
|
user.username = user.services.oidc.username;
|
|
user.username = user.services.oidc.username;
|
|
- user.emails = [{
|
|
|
|
- address: user.services.oidc.email.toLowerCase(),
|
|
|
|
- verified: false,
|
|
|
|
- }];
|
|
|
|
- const initials = user.services.oidc.fullname.match(/\b[a-zA-Z]/g).join('').toUpperCase();
|
|
|
|
|
|
+ user.emails = [{ address: email,
|
|
|
|
+ verified: true }];
|
|
|
|
+ var initials = user.services.oidc.fullname.match(/\b[a-zA-Z]/g).join('').toUpperCase();
|
|
user.profile = { initials: initials, fullname: user.services.oidc.fullname };
|
|
user.profile = { initials: initials, fullname: user.services.oidc.fullname };
|
|
- }
|
|
|
|
|
|
|
|
|
|
+ // see if any existing user has this email address or username, otherwise create new
|
|
|
|
+ var existingUser = Meteor.users.findOne({$or: [{'emails.address': email}, {'username':user.username}]});
|
|
|
|
+ console.log("user to create : ");
|
|
|
|
+ console.log(user);
|
|
|
|
+ if (!existingUser)
|
|
|
|
+ return user;
|
|
|
|
+
|
|
|
|
+ // copy across new service info
|
|
|
|
+ var service = _.keys(user.services)[0];
|
|
|
|
+ existingUser.services[service] = user.services[service];
|
|
|
|
+ existingUser.emails = user.emails;
|
|
|
|
+ existingUser.username = user.username;
|
|
|
|
+ existingUser.profile = user.profile;
|
|
|
|
+
|
|
|
|
+ Meteor.users.remove({_id: existingUser._id}); // remove existing record
|
|
|
|
+ return existingUser;
|
|
|
|
+ }
|
|
|
|
|
|
if (options.from === 'admin') {
|
|
if (options.from === 'admin') {
|
|
user.createdThroughApi = true;
|
|
user.createdThroughApi = true;
|