wekan/config/accounts.js
Julen Landa Alustiza dfeeec308a Fix email settings loading:
MAIL_URL was overriden with database info all the time.
Now if MAIL_URL exists is not overwritten and if neither MAIL_URL nor
exists valid admin panel data MAIL_URL is not set.
MAIL_FROM was ignored. Same behaviour, env variable has bigger priority
than database configuration.
On both cases, althrought environment variable is set, updating admin-panel
mail settings will load new info and ignore the environment variable.
Remove some code that is not needed anymore
2017-04-01 21:46:09 +02:00

70 lines
1.9 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,
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());
};
});
}