Added dynamic user creation

This commit is contained in:
Steffo Weber 2017-05-12 22:38:33 +02:00
parent 83327a1bd5
commit 53e2321dd9
2 changed files with 22 additions and 4 deletions

View file

@ -1,7 +1,7 @@
Package.describe({
name:"steffo:meteor-accounts-saml",
summary: "SAML Login (SP) for Meteor. Works with OpenAM, OpenIDP and provides Single Logout.",
version: "0.0.9",
version: "0.0.10",
git: "https://github.com/steffow/meteor-accounts-saml.git"
});

View file

@ -72,12 +72,30 @@ Accounts.registerLoginHandler(function (loginRequest) {
console.log("RESULT :" + JSON.stringify(loginResult));
}
if (loginResult && loginResult.profile && loginResult.profile.email) {
console.log("Profile: " + JSON.stringify(loginResult.profile.email));
var user = Meteor.users.findOne({
'emails.address': loginResult.profile.email
});
if (!user)
if (!user) {
if (Meteor.settings.saml[0].dynamicProfile) {
Accounts.createUser({
email: loginResult.profile.email,
password: "",
username: loginResult.profile.nameID,
profile: ""
});
user = Meteor.users.findOne({
"emails.address": loginResult.profile.email
});
if (Meteor.settings.debug) {
console.log("Created new user");
}
} else {
throw new Error("Could not find an existing user with supplied email " + loginResult.profile.email);
}
}
//creating the token and adding to the user
@ -215,7 +233,7 @@ middleware = function (req, res, next) {
});
res.end();
} else {
// TBD thinking of sth meaning full.
// TBD thinking of sth meaning full.
}
})
break;
@ -297,4 +315,4 @@ var closePopup = function (res, err) {
if (err)
content = '<html><body><h2>Sorry, an annoying error occured</h2><div>' + err + '</div><a onclick="window.close();">Close Window</a></body></html>';
res.end(content, 'utf-8');
};
};