Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Add v3.34.1
Browse files Browse the repository at this point in the history
  • Loading branch information
YannickRe committed Sep 24, 2020
1 parent 525bca4 commit c83f1cb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/server/api/canary/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ module.exports = {
frame.response = async function (req, res) {
try {
const {token, action} = frame.options;
const updatedEmailAddress = membersService.settings.getEmailFromToken({token});
const updatedEmailAddress = await membersService.settings.getEmailFromToken({token});
const actionToKeyMapping = {
fromAddressUpdate: 'members_from_address',
supportAddressUpdate: 'members_support_address'
Expand Down
14 changes: 9 additions & 5 deletions core/server/services/members/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const settingsCache = require('../settings/cache');
const logging = require('../../../shared/logging');
const mail = require('../mail');
const updateEmailTemplate = require('./emails/updateEmail');
const SingleUseTokenProvider = require('./SingleUseTokenProvider');
const models = require('../../models');
const MAGIC_LINK_TOKEN_VALIDITY = 4 * 60 * 60 * 1000;

const ghostMailer = new mail.GhostMailer();

Expand Down Expand Up @@ -63,14 +66,14 @@ function createSettingsInstance(config) {

const magicLinkService = new MagicLink({
transporter,
secret: config.getAuthSecret(),
tokenProvider: new SingleUseTokenProvider(models.SingleUseToken, MAGIC_LINK_TOKEN_VALIDITY),
getSigninURL,
getText,
getHTML,
getSubject
});

const sendEmailAddressUpdateMagicLink = ({email, payload = {}, type = 'fromAddressUpdate'}) => {
const sendEmailAddressUpdateMagicLink = ({email, type = 'fromAddressUpdate'}) => {
const [,toDomain] = email.split('@');
let fromEmail = `noreply@${toDomain}`;
if (fromEmail === email) {
Expand All @@ -90,11 +93,12 @@ function createSettingsInstance(config) {
return ghostMailer.send(msg);
}
};
return magicLinkService.sendMagicLink({email, payload, subject: email, type});
return magicLinkService.sendMagicLink({email, tokenData: {email}, subject: email, type});
};

const getEmailFromToken = ({token}) => {
return magicLinkService.getUserFromToken(token);
const getEmailFromToken = async ({token}) => {
const data = await magicLinkService.getDataFromToken(token);
return data.email;
};

const getAdminRedirectLink = ({type}) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ghost",
"version": "3.34.0",
"version": "3.34.1",
"description": "The professional publishing platform",
"author": "Ghost Foundation",
"homepage": "https://ghost.org",
Expand Down

0 comments on commit c83f1cb

Please sign in to comment.