wekan/config/accounts.js
lkisme 1dfb6ef477 Admin panel:
Only invited user can register in strict mode,
Set mail server in admin panel,
Switch strict mode in admin panel,
Invite people to system in admin panel
2017-02-24 22:10:38 +08:00

72 lines
2 KiB
JavaScript

const passwordField = AccountsTemplates.removeField('password');
const emailField = AccountsTemplates.removeField('email');
AccountsTemplates.addFields([{
_id: 'username',
type: 'text',
displayName: 'username',
required: true,
minLength: 2,
}, emailField, passwordField, {
_id: 'invitationcode',
type: 'text',
displayName: 'Invitation Code',
required: false,
minLength: 6,
errStr: 'Invitation code doesn\'t exist',
template: 'invitationCode',
}]);
AccountsTemplates.configure({
defaultLayout: 'userFormsLayout',
defaultContentRegion: 'content',
confirmPassword: false,
enablePasswordChange: true,
sendVerificationEmail: true,
showForgotPasswordLink: true,
onLogoutHook() {
const homePage = 'home';
if (FlowRouter.getRouteName() === homePage) {
FlowRouter.reload();
} else {
FlowRouter.go(homePage);
}
},
});
['signIn', 'signUp', 'resetPwd', 'forgotPwd', 'enrollAccount'].forEach(
(routeName) => AccountsTemplates.configureRoute(routeName));
// We display the form to change the password in a popup window that already
// have a title, so we unset the title automatically displayed by useraccounts.
AccountsTemplates.configure({
texts: {
title: {
changePwd: '',
},
},
});
AccountsTemplates.configureRoute('changePwd', {
redirect() {
// XXX We should emit a notification once we have a notification system.
// Currently the user has no indication that his modification has been
// applied.
Popup.back();
},
});
if (Meteor.isServer) {
['resetPassword-subject', 'resetPassword-text', 'verifyEmail-subject', 'verifyEmail-text', 'enrollAccount-subject', 'enrollAccount-text'].forEach((str) => {
const [templateName, field] = str.split('-');
Accounts.emailTemplates[templateName][field] = (user, url) => {
return TAPi18n.__(`email-${str}`, {
url,
user: user.getName(),
siteName: Accounts.emailTemplates.siteName,
}, user.getLanguage());
};
});
}