mirror of
https://github.com/wekan/wekan.git
synced 2025-04-23 13:37:09 -04:00
Merge pull request #5098 from scout-ch/feature/default-board-for-users
Proposal: default board for users
This commit is contained in:
commit
65a231a040
1 changed files with 23 additions and 0 deletions
|
@ -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,
|
||||
|
@ -305,6 +306,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