mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05: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 changed files with 13 additions and 6 deletions
|
@ -1,7 +1,14 @@
|
||||||
const errors = require('@tryghost/errors');
|
const errors = require('@tryghost/errors');
|
||||||
const i18n = require('../../../shared/i18n');
|
const tpl = require('@tryghost/tpl');
|
||||||
const models = require('../../models');
|
const models = require('../../models');
|
||||||
const security = require('@tryghost/security');
|
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) {
|
async function accept(invitation) {
|
||||||
const data = invitation.invitation[0];
|
const data = invitation.invitation[0];
|
||||||
|
@ -11,19 +18,19 @@ async function accept(invitation) {
|
||||||
let invite = await models.Invite.findOne({token: inviteToken, status: 'sent'}, options);
|
let invite = await models.Invite.findOne({token: inviteToken, status: 'sent'}, options);
|
||||||
|
|
||||||
if (!invite) {
|
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()) {
|
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});
|
let user = await models.User.findOne({email: data.email});
|
||||||
if (user) {
|
if (user) {
|
||||||
throw new errors.ValidationError({
|
throw new errors.ValidationError({
|
||||||
message: i18n.t('errors.api.invites.inviteEmailAlreadyExist.message'),
|
message: tpl(messages.inviteEmailAlreadyExist.message),
|
||||||
context: i18n.t('errors.api.invites.inviteEmailAlreadyExist.context'),
|
context: tpl(messages.inviteEmailAlreadyExist.context),
|
||||||
help: i18n.t('errors.api.invites.inviteEmailAlreadyExist.help')
|
help: tpl(messages.inviteEmailAlreadyExist.help)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue