Magento 2 New Account Confirmation Email Text Broken
after creating new account trying to login but get this kind of error message
This account is not confirmed. <a href="http://example.com/customer/account/confirmation/?email=testuser%40mail.com">Click here</a> to resend confirmation email.
How can i fix this issue to get clickable link instead of html content?
Just use
I override vendor/magento/module-theme/view/frontend/web/js/view/messages.js
file with this one app/design/frontend/<VENDOR_NAME>/<THEME_NAME>/Magento_Theme/web/js/view/messages.js
and then changed prepareMessageForHtml
function like this
define([
'jquery',
'uiComponent',
'Magento_Customer/js/customer-data',
'underscore',
'escaper',
'jquery/jquery-storageapi'
], function ($, Component, customerData, _, escaper) {
'use strict';
return Component.extend({
defaults: {
cookieMessages: [],
messages: [],
allowedTags: ['div', 'span', 'b', 'strong', 'i', 'em', 'u', 'a']
},
/**
* Extends Component object by storage observable messages.
*/
initialize: function () {
this._super();
this.cookieMessages = _.unique($.cookieStorage.get('mage-messages'), 'text');
this.messages = customerData.get('messages').extend({
disposableCustomerData: 'messages'
});
// Force to clean obsolete messages
if (!_.isEmpty(this.messages().messages)) {
customerData.set('messages', {});
}
$.cookieStorage.set('mage-messages', '');
},
/**
* Prepare the given message to be rendered as HTML
*
* @param {String} message
* @return {string}
*/
prepareMessageForHtml: function (message) {
let parser = new DOMParser();
let doc = parser.parseFromString(message, 'text/html');
let html = doc.body.textContent;
if (!html.includes("</a>")) {
return message;
}
return html;
}
});
});