mirror of
https://github.com/wekan/wekan.git
synced 2025-04-23 13:37:09 -04:00
feature: add user to default board after login
This commit is contained in:
parent
b9ec43c0f7
commit
00826660b4
1 changed files with 24 additions and 1 deletions
|
@ -42,7 +42,7 @@ OAuth.registerService('oidc', 2, null, function (query) {
|
|||
|
||||
if (userinfo.ocs) userinfo = userinfo.ocs.data; // Nextcloud hack
|
||||
if (userinfo.metadata) userinfo = userinfo.metadata // Openshift hack
|
||||
if (debug) console.log('XXX: userinfo:', userinfo);
|
||||
if (debug) console.log('IIII: userinfo:', userinfo);
|
||||
|
||||
serviceData.id = userinfo[process.env.OAUTH2_ID_MAP]; // || userinfo["id"];
|
||||
serviceData.username = userinfo[process.env.OAUTH2_USERNAME_MAP]; // || userinfo["uid"];
|
||||
|
@ -108,6 +108,7 @@ OAuth.registerService('oidc', 2, null, function (query) {
|
|||
// Fix OIDC login loop for integer user ID. Thanks to danielkaiser.
|
||||
// https://github.com/wekan/wekan/issues/4795
|
||||
Meteor.call('groupRoutineOnLogin',serviceData, ""+serviceData.id);
|
||||
Meteor.call('boardRoutineOnLogin',serviceData, ""+serviceData.id);
|
||||
|
||||
return {
|
||||
serviceData: serviceData,
|
||||
|
@ -304,6 +305,28 @@ Meteor.methods({
|
|||
}
|
||||
});
|
||||
|
||||
Meteor.methods({
|
||||
'boardRoutineOnLogin': function(info, oidcUserId)
|
||||
{
|
||||
check(info, Object);
|
||||
check(oidcUserId, String);
|
||||
|
||||
const defaultBoardId = process.env.DEFAULT_BOARD_ID || false;
|
||||
|
||||
if (defaultBoardId)
|
||||
{
|
||||
const board = Boards.findOne(defaultBoardId)
|
||||
const user = Users.findOne({ 'services.oidc.id': oidcUserId })
|
||||
const memberIndex = _.pluck(board.members, 'userId').indexOf(user._id);
|
||||
|
||||
if(board && memberIndex < 0)
|
||||
{
|
||||
board.addMember(user._id)
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Oidc.retrieveCredential = function (credentialToken, credentialSecret) {
|
||||
return OAuth.retrieveCredential(credentialToken, credentialSecret);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue