mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 05:50:35 +03:00
Replaced i18n with tpl in accept.js (#13471)
refs: #13380 - The i18n package is deprecated. It is being replaced with the tpl package.
This commit is contained in:
parent
940d10fc3b
commit
684721b1bd
@ -1,7 +1,14 @@
|
||||
const errors = require('@tryghost/errors');
|
||||
const i18n = require('../../../shared/i18n');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
const models = require('../../models');
|
||||
const security = require('@tryghost/security');
|
||||
const messages = {inviteNotFound: 'Invite not found.',
|
||||
inviteExpired: 'Invite is expired.',
|
||||
inviteEmailAlreadyExist: {
|
||||
message: 'Could not create an account, email is already in use.',
|
||||
context: 'Attempting to create an account with existing email address.',
|
||||
help: 'Use different email address to register your account.'
|
||||
}};
|
||||
|
||||
async function accept(invitation) {
|
||||
const data = invitation.invitation[0];
|
||||
@ -11,19 +18,19 @@ async function accept(invitation) {
|
||||
let invite = await models.Invite.findOne({token: inviteToken, status: 'sent'}, options);
|
||||
|
||||
if (!invite) {
|
||||
throw new errors.NotFoundError({message: i18n.t('errors.api.invites.inviteNotFound')});
|
||||
throw new errors.NotFoundError({message: tpl(messages.inviteNotFound)});
|
||||
}
|
||||
|
||||
if (invite.get('expires') < Date.now()) {
|
||||
throw new errors.NotFoundError({message: i18n.t('errors.api.invites.inviteExpired')});
|
||||
throw new errors.NotFoundError({message: tpl(messages.inviteExpired)});
|
||||
}
|
||||
|
||||
let user = await models.User.findOne({email: data.email});
|
||||
if (user) {
|
||||
throw new errors.ValidationError({
|
||||
message: i18n.t('errors.api.invites.inviteEmailAlreadyExist.message'),
|
||||
context: i18n.t('errors.api.invites.inviteEmailAlreadyExist.context'),
|
||||
help: i18n.t('errors.api.invites.inviteEmailAlreadyExist.help')
|
||||
message: tpl(messages.inviteEmailAlreadyExist.message),
|
||||
context: tpl(messages.inviteEmailAlreadyExist.context),
|
||||
help: tpl(messages.inviteEmailAlreadyExist.help)
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user