mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 15:30:13 +01:00
Add new importUsernames field for import user mapping
This commit is contained in:
parent
62ba8ed8d8
commit
0446999c63
7 changed files with 68 additions and 7 deletions
|
|
@ -169,7 +169,10 @@ BlazeComponent.extendComponent({
|
||||||
this._refreshMembers(
|
this._refreshMembers(
|
||||||
this.members().map(member => {
|
this.members().map(member => {
|
||||||
if (!member.wekanId) {
|
if (!member.wekanId) {
|
||||||
const user = Users.findOne({ username: member.username });
|
let user = Users.findOne({ username: member.username });
|
||||||
|
if (!user) {
|
||||||
|
user = Users.findOne({ importUsernames: member.username });
|
||||||
|
}
|
||||||
if (user) {
|
if (user) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log('found username:', user.username);
|
console.log('found username:', user.username);
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,7 @@ template(name="peopleGeneral")
|
||||||
th {{_ 'createdAt'}}
|
th {{_ 'createdAt'}}
|
||||||
th {{_ 'active'}}
|
th {{_ 'active'}}
|
||||||
th {{_ 'authentication-method'}}
|
th {{_ 'authentication-method'}}
|
||||||
|
th {{_ 'import-usernames'}}
|
||||||
th
|
th
|
||||||
+newUserRow
|
+newUserRow
|
||||||
each user in peopleList
|
each user in peopleList
|
||||||
|
|
@ -257,6 +258,10 @@ template(name="peopleRow")
|
||||||
td <s>{{_ userData.authenticationMethod }}</s>
|
td <s>{{_ userData.authenticationMethod }}</s>
|
||||||
else
|
else
|
||||||
td {{_ userData.authenticationMethod }}
|
td {{_ userData.authenticationMethod }}
|
||||||
|
if userData.loginDisabled
|
||||||
|
td <s>{{ userData.importUsernamesString }}</s>
|
||||||
|
else
|
||||||
|
td {{ userData.importUsernamesString }}
|
||||||
td
|
td
|
||||||
a.edit-user
|
a.edit-user
|
||||||
i.fa.fa-edit
|
i.fa.fa-edit
|
||||||
|
|
@ -346,6 +351,9 @@ template(name="editUserPopup")
|
||||||
input.js-profile-email(type="email" value="{{user.emails.[0].address}}" readonly)
|
input.js-profile-email(type="email" value="{{user.emails.[0].address}}" readonly)
|
||||||
else
|
else
|
||||||
input.js-profile-email(type="email" value="{{user.emails.[0].address}}" required)
|
input.js-profile-email(type="email" value="{{user.emails.[0].address}}" required)
|
||||||
|
label
|
||||||
|
| {{_ 'import-usernames'}}
|
||||||
|
input.js-import-usernames(type="text" value=user.importUsernames)
|
||||||
label
|
label
|
||||||
| {{_ 'verified'}}
|
| {{_ 'verified'}}
|
||||||
select.select-verified.js-profile-email-verified
|
select.select-verified.js-profile-email-verified
|
||||||
|
|
@ -444,6 +452,9 @@ template(name="newUserPopup")
|
||||||
// input.js-profile-email(type="email" value="{{user.emails.[0].address}}" readonly)
|
// input.js-profile-email(type="email" value="{{user.emails.[0].address}}" readonly)
|
||||||
//else
|
//else
|
||||||
input.js-profile-email(type="email" value="" required)
|
input.js-profile-email(type="email" value="" required)
|
||||||
|
label
|
||||||
|
| {{_ 'import-usernames'}}
|
||||||
|
input.js-import-usernames(type="text" value="")
|
||||||
label
|
label
|
||||||
| {{_ 'admin'}}
|
| {{_ 'admin'}}
|
||||||
select.select-role.js-profile-isadmin
|
select.select-role.js-profile-isadmin
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ BlazeComponent.extendComponent({
|
||||||
const orgs = Org.find(this.findOrgsOptions.get(), {
|
const orgs = Org.find(this.findOrgsOptions.get(), {
|
||||||
fields: { _id: true },
|
fields: { _id: true },
|
||||||
});
|
});
|
||||||
this.numberOrgs.set(org.count(false));
|
this.numberOrgs.set(orgs.count(false));
|
||||||
return orgs;
|
return orgs;
|
||||||
},
|
},
|
||||||
teamList() {
|
teamList() {
|
||||||
|
|
@ -421,6 +421,9 @@ Template.editUserPopup.events({
|
||||||
const authentication = templateInstance
|
const authentication = templateInstance
|
||||||
.find('.js-authenticationMethod')
|
.find('.js-authenticationMethod')
|
||||||
.value.trim();
|
.value.trim();
|
||||||
|
const importUsernames = templateInstance
|
||||||
|
.find('.js-import-usernames')
|
||||||
|
.value.trim();
|
||||||
|
|
||||||
const isChangePassword = password.length > 0;
|
const isChangePassword = password.length > 0;
|
||||||
const isChangeUserName = username !== user.username;
|
const isChangeUserName = username !== user.username;
|
||||||
|
|
@ -441,6 +444,7 @@ Template.editUserPopup.events({
|
||||||
isAdmin: isAdmin === 'true',
|
isAdmin: isAdmin === 'true',
|
||||||
loginDisabled: isActive === 'true',
|
loginDisabled: isActive === 'true',
|
||||||
authenticationMethod: authentication,
|
authenticationMethod: authentication,
|
||||||
|
importUsernames: Users.parseImportUsernames(importUsernames),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -563,6 +567,9 @@ Template.newUserPopup.events({
|
||||||
const isAdmin = templateInstance.find('.js-profile-isadmin').value.trim();
|
const isAdmin = templateInstance.find('.js-profile-isadmin').value.trim();
|
||||||
const isActive = templateInstance.find('.js-profile-isactive').value.trim();
|
const isActive = templateInstance.find('.js-profile-isactive').value.trim();
|
||||||
const email = templateInstance.find('.js-profile-email').value.trim();
|
const email = templateInstance.find('.js-profile-email').value.trim();
|
||||||
|
const importUsernames = templateInstance
|
||||||
|
.find('.js-import-usernames')
|
||||||
|
.value.trim();
|
||||||
|
|
||||||
Meteor.call(
|
Meteor.call(
|
||||||
'setCreateUser',
|
'setCreateUser',
|
||||||
|
|
@ -572,6 +579,7 @@ Template.newUserPopup.events({
|
||||||
isAdmin,
|
isAdmin,
|
||||||
isActive,
|
isActive,
|
||||||
email.toLowerCase(),
|
email.toLowerCase(),
|
||||||
|
importUsernames,
|
||||||
function(error) {
|
function(error) {
|
||||||
const usernameMessageElement = templateInstance.$('.username-taken');
|
const usernameMessageElement = templateInstance.$('.username-taken');
|
||||||
const emailMessageElement = templateInstance.$('.email-taken');
|
const emailMessageElement = templateInstance.$('.email-taken');
|
||||||
|
|
|
||||||
|
|
@ -530,6 +530,7 @@
|
||||||
"custom-login-logo-link-url": "Custom Login Logo Link URL",
|
"custom-login-logo-link-url": "Custom Login Logo Link URL",
|
||||||
"text-below-custom-login-logo": "Text below Custom Login Logo",
|
"text-below-custom-login-logo": "Text below Custom Login Logo",
|
||||||
"username": "Username",
|
"username": "Username",
|
||||||
|
"import-usernames": "Import Usernames",
|
||||||
"view-it": "View it",
|
"view-it": "View it",
|
||||||
"warn-list-archived": "warning: this card is in an list at Archive",
|
"warn-list-archived": "warning: this card is in an list at Archive",
|
||||||
"watch": "Watch",
|
"watch": "Watch",
|
||||||
|
|
|
||||||
|
|
@ -338,6 +338,13 @@ Users.attachSchema(
|
||||||
type: Number,
|
type: Number,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
|
importUsernames: {
|
||||||
|
/**
|
||||||
|
* username for imported
|
||||||
|
*/
|
||||||
|
type: [String],
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -433,7 +440,18 @@ if (Meteor.isClient) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Users.parseImportUsernames = usernamesString => {
|
||||||
|
return usernamesString.trim().split(new RegExp('\\s*[,;]\\s*'));
|
||||||
|
};
|
||||||
|
|
||||||
Users.helpers({
|
Users.helpers({
|
||||||
|
importUsernamesString() {
|
||||||
|
if (this.importUsernames) {
|
||||||
|
return this.importUsernames.join(', ');
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
|
||||||
boards() {
|
boards() {
|
||||||
return Boards.find(
|
return Boards.find(
|
||||||
{ 'members.userId': this._id },
|
{ 'members.userId': this._id },
|
||||||
|
|
@ -779,7 +797,15 @@ Meteor.methods({
|
||||||
|
|
||||||
if (Meteor.isServer) {
|
if (Meteor.isServer) {
|
||||||
Meteor.methods({
|
Meteor.methods({
|
||||||
setCreateUser(fullname, username, password, isAdmin, isActive, email) {
|
setCreateUser(
|
||||||
|
fullname,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
isAdmin,
|
||||||
|
isActive,
|
||||||
|
email,
|
||||||
|
importUsernames,
|
||||||
|
) {
|
||||||
if (Meteor.user() && Meteor.user().isAdmin) {
|
if (Meteor.user() && Meteor.user().isAdmin) {
|
||||||
check(fullname, String);
|
check(fullname, String);
|
||||||
check(username, String);
|
check(username, String);
|
||||||
|
|
@ -787,6 +813,7 @@ if (Meteor.isServer) {
|
||||||
check(isAdmin, String);
|
check(isAdmin, String);
|
||||||
check(isActive, String);
|
check(isActive, String);
|
||||||
check(email, String);
|
check(email, String);
|
||||||
|
check(importUsernames, Array);
|
||||||
|
|
||||||
const nUsersWithUsername = Users.find({ username }).count();
|
const nUsersWithUsername = Users.find({ username }).count();
|
||||||
const nUsersWithEmail = Users.find({ email }).count();
|
const nUsersWithEmail = Users.find({ email }).count();
|
||||||
|
|
@ -803,10 +830,10 @@ if (Meteor.isServer) {
|
||||||
email: email.toLowerCase(),
|
email: email.toLowerCase(),
|
||||||
from: 'admin',
|
from: 'admin',
|
||||||
});
|
});
|
||||||
user = Users.findOne(username) || Users.findOne({ username });
|
const user = Users.findOne(username) || Users.findOne({ username });
|
||||||
if (user) {
|
if (user) {
|
||||||
Users.update(user._id, {
|
Users.update(user._id, {
|
||||||
$set: { 'profile.fullname': fullname },
|
$set: { 'profile.fullname': fullname, importUsernames },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ Meteor.publish('people', function(query, limit) {
|
||||||
createdAt: 1,
|
createdAt: 1,
|
||||||
loginDisabled: 1,
|
loginDisabled: 1,
|
||||||
authenticationMethod: 1,
|
authenticationMethod: 1,
|
||||||
|
importUsernames: 1,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,18 @@ Meteor.publish('user-miniprofile', function(usernames) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
// console.log('usernames:', usernames);
|
// console.log('usernames:', usernames);
|
||||||
return Users.find(
|
return Users.find(
|
||||||
{ username: { $in: usernames } },
|
{
|
||||||
{ fields: Users.safeFields },
|
$or: [
|
||||||
|
{ username: { $in: usernames } },
|
||||||
|
{ importUsernames: { $in: usernames } },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fields: {
|
||||||
|
...Users.safeFields,
|
||||||
|
importUsernames: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue