Skip to content

Commit

Permalink
Merge pull request #1091 from Mailtrain-org/fix-1046
Browse files Browse the repository at this point in the history
Fix for #1046
  • Loading branch information
bures authored Jun 9, 2021
2 parents 91cb4ba + ac389ea commit e38f80e
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 71 deletions.
142 changes: 71 additions & 71 deletions client/src/account/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ export default class API extends Component {
</div>
</div>

<div class="accordion" id="apicalls">
<div class="card">
<div class="card-header">
<button type="button" class="btn btn-link" data-toggle="collapse" data-target="#moresubscribers"><h4>GET /api/subscriptions/:listCid – {t('getSubscribers')}</h4></button>
<div className="accordion" id="apicalls">
<div className="card">
<div className="card-header">
<button type="button" className="btn btn-link" data-toggle="collapse" data-target="#moresubscribers"><h4>GET /api/subscriptions/:listCid – {t('getSubscribers')}</h4></button>
</div>
<div id="moresubscribers" class="collapse" data-parent="#apicalls">
<div class="card-body">
<div id="moresubscribers" className="collapse" data-parent="#apicalls">
<div className="card-body">
<p>
{t('getSubscribers')}
</p>
Expand All @@ -118,12 +118,12 @@ export default class API extends Component {
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<h4><button type="button" class="btn btn-link" data-toggle="collapse" data-target="#moresubscribe"><h4>POST /api/subscribe/:listCid – {t('addSubscription')}</h4></button></h4>
<div className="card">
<div className="card-header">
<h4><button type="button" className="btn btn-link" data-toggle="collapse" data-target="#moresubscribe"><h4>POST /api/subscribe/:listCid – {t('addSubscription')}</h4></button></h4>
</div>
<div id="moresubscribe" class="collapse" data-parent="#apicalls">
<div class="card-body">
<div id="moresubscribe" className="collapse" data-parent="#apicalls">
<div className="card-body">
<p>
{t('thisApiCallEitherInsertsANewSubscription')}
</p>
Expand Down Expand Up @@ -175,12 +175,12 @@ export default class API extends Component {
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<button type="button" class="btn btn-link" data-toggle="collapse" data-target="#moreunsubscribe"><h4>POST /api/unsubscribe/:listCId – {t('removeSubscription')}</h4></button>
<div className="card">
<div className="card-header">
<button type="button" className="btn btn-link" data-toggle="collapse" data-target="#moreunsubscribe"><h4>POST /api/unsubscribe/:listCId – {t('removeSubscription')}</h4></button>
</div>
<div id="moreunsubscribe" class="collapse" data-parent="#apicalls">
<div class="card-body">
<div id="moreunsubscribe" className="collapse" data-parent="#apicalls">
<div className="card-body">
<p>
{t('thisApiCallMarksASubscriptionAs')}
</p>
Expand Down Expand Up @@ -214,12 +214,12 @@ export default class API extends Component {
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<button type="button" class="btn btn-link" data-toggle="collapse" data-target="#moredelete"><h4>POST /api/delete/:listCId – {t('deleteSubscription')}</h4></button>
<div className="card">
<div className="card-header">
<button type="button" className="btn btn-link" data-toggle="collapse" data-target="#moredelete"><h4>POST /api/delete/:listCId – {t('deleteSubscription')}</h4></button>
</div>
<div id="moredelete" class="collapse" data-parent="#apicalls">
<div class="card-body">
<div id="moredelete" className="collapse" data-parent="#apicalls">
<div className="card-body">
<p>
{t('thisApiCallDeletesASubscription')}
</p>
Expand Down Expand Up @@ -252,12 +252,12 @@ export default class API extends Component {
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<button type="button" class="btn btn-link" data-toggle="collapse" data-target="#morefield"><h4>POST /api/field/:listId – {t('addNewCustomField')}</h4></button>
<div className="card">
<div className="card-header">
<button type="button" className="btn btn-link" data-toggle="collapse" data-target="#morefield"><h4>POST /api/field/:listId – {t('addNewCustomField')}</h4></button>
</div>
<div id="morefield" class="collapse" data-parent="#apicalls">
<div class="card-body">
<div id="morefield" className="collapse" data-parent="#apicalls">
<div className="card-body">
<p>
{t('thisApiCallCreatesANewCustomFieldForA')}
</p>
Expand Down Expand Up @@ -310,12 +310,12 @@ export default class API extends Component {
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<button type="button" class="btn btn-link" data-toggle="collapse" data-target="#moreblacklistget"><h4>GET /api/blacklist/get – {t('getListOfBlacklistedEmails')}</h4></button>
<div className="card">
<div className="card-header">
<button type="button" className="btn btn-link" data-toggle="collapse" data-target="#moreblacklistget"><h4>GET /api/blacklist/get – {t('getListOfBlacklistedEmails')}</h4></button>
</div>
<div id="moreblacklistget" class="collapse" data-parent="#apicalls">
<div class="card-body">
<div id="moreblacklistget" className="collapse" data-parent="#apicalls">
<div className="card-body">
<p>
{t('thisApiCallGetListOfBlacklistedEmails')}
</p>
Expand All @@ -342,12 +342,12 @@ export default class API extends Component {
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<button type="button" class="btn btn-link" data-toggle="collapse" data-target="#moreblacklistadd"><h4>POST /api/blacklist/add – {t('addEmailToBlacklist')}</h4></button>
<div className="card">
<div className="card-header">
<button type="button" className="btn btn-link" data-toggle="collapse" data-target="#moreblacklistadd"><h4>POST /api/blacklist/add – {t('addEmailToBlacklist')}</h4></button>
</div>
<div id="moreblacklistadd" class="collapse" data-parent="#apicalls">
<div class="card-body">
<div id="moreblacklistadd" className="collapse" data-parent="#apicalls">
<div className="card-body">
<p>
{t('thisApiCallEitherAddEmailsToBlacklist')}
</p>
Expand Down Expand Up @@ -375,12 +375,12 @@ export default class API extends Component {
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<button type="button" class="btn btn-link" data-toggle="collapse" data-target="#moreblacklistdelete"><h4>POST /api/blacklist/delete – {t('deleteEmailFromBlacklist')}</h4></button>
<div className="card">
<div className="card-header">
<button type="button" className="btn btn-link" data-toggle="collapse" data-target="#moreblacklistdelete"><h4>POST /api/blacklist/delete – {t('deleteEmailFromBlacklist')}</h4></button>
</div>
<div id="moreblacklistdelete" class="collapse" data-parent="#apicalls">
<div class="card-body">
<div id="moreblacklistdelete" className="collapse" data-parent="#apicalls">
<div className="card-body">
<p>
{t('thisApiCallEitherDeleteEmailsFrom')}
</p>
Expand Down Expand Up @@ -408,12 +408,12 @@ export default class API extends Component {
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<button type="button" class="btn btn-link" data-toggle="collapse" data-target="#morelistsemail"><h4>GET /api/lists/:email – {t('getTheListsAUserHasSubscribedTo')}</h4></button>
<div className="card">
<div className="card-header">
<button type="button" className="btn btn-link" data-toggle="collapse" data-target="#morelistsemail"><h4>GET /api/lists/:email – {t('getTheListsAUserHasSubscribedTo')}</h4></button>
</div>
<div id="morelistsemail" class="collapse" data-parent="#apicalls">
<div class="card-body">
<div id="morelistsemail" className="collapse" data-parent="#apicalls">
<div className="card-body">
<p>
{t('retrieveTheListsThatTheUserWithEmailHas')}
</p>
Expand All @@ -433,12 +433,12 @@ export default class API extends Component {
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<button type="button" class="btn btn-link" data-toggle="collapse" data-target="#morelistsnamespace"><h4>GET /api/lists-by-namespace/:namespaceId – {t('getTheListsInANamespace')}</h4></button>
<div className="card">
<div className="card-header">
<button type="button" className="btn btn-link" data-toggle="collapse" data-target="#morelistsnamespace"><h4>GET /api/lists-by-namespace/:namespaceId – {t('getTheListsInANamespace')}</h4></button>
</div>
<div id="morelistsnamespace" class="collapse" data-parent="#apicalls">
<div class="card-body">
<div id="morelistsnamespace" className="collapse" data-parent="#apicalls">
<div className="card-body">
<p>
{t('retrieveTheListsThatTheNamespaceWith')}
</p>
Expand All @@ -458,12 +458,12 @@ export default class API extends Component {
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<button type="button" class="btn btn-link" data-toggle="collapse" data-target="#morecreatelist"><h4>POST /api/list – {t('createList')}</h4></button>
<div className="card">
<div className="card-header">
<button type="button" className="btn btn-link" data-toggle="collapse" data-target="#morecreatelist"><h4>POST /api/list – {t('createList')}</h4></button>
</div>
<div id="morecreatelist" class="collapse" data-parent="#apicalls">
<div class="card-body">
<div id="morecreatelist" className="collapse" data-parent="#apicalls">
<div className="card-body">
<p>
{t('createsANewListOfSubscribers')}
</p>
Expand Down Expand Up @@ -530,12 +530,12 @@ export default class API extends Component {
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<button type="button" class="btn btn-link" data-toggle="collapse" data-target="#moredeletelist"><h4>DELETE /api/list/:listCId – {t('deleteList')}</h4></button>
<div className="card">
<div className="card-header">
<button type="button" className="btn btn-link" data-toggle="collapse" data-target="#moredeletelist"><h4>DELETE /api/list/:listCId – {t('deleteList')}</h4></button>
</div>
<div id="moredeletelist" class="collapse" data-parent="#apicalls">
<div class="card-body">
<div id="moredeletelist" className="collapse" data-parent="#apicalls">
<div className="card-body">
<p>
{t('deletesAListOfSubscribers')}
</p>
Expand All @@ -559,12 +559,12 @@ export default class API extends Component {
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<button type="button" class="btn btn-link" data-toggle="collapse" data-target="#morerss"><h4>GET /api/rss/fetch/:campaignCid – {t('triggerFetchOfACampaign')}</h4></button>
<div className="card">
<div className="card-header">
<button type="button" className="btn btn-link" data-toggle="collapse" data-target="#morerss"><h4>GET /api/rss/fetch/:campaignCid – {t('triggerFetchOfACampaign')}</h4></button>
</div>
<div id="morerss" class="collapse" data-parent="#apicalls">
<div class="card-body">
<div id="morerss" className="collapse" data-parent="#apicalls">
<div className="card-body">
<p>
{t('forcesTheRssFeedCheckToImmediatelyCheck')}
</p>
Expand All @@ -584,12 +584,12 @@ export default class API extends Component {
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<button type="button" class="btn btn-link" data-toggle="collapse" data-target="#moretemplate"><h4>POST /api/templates/:templateId/send – {t('sendTransactionalEmail')}</h4></button>
<div className="card">
<div className="card-header">
<button type="button" className="btn btn-link" data-toggle="collapse" data-target="#moretemplate"><h4>POST /api/templates/:templateId/send – {t('sendTransactionalEmail')}</h4></button>
</div>
<div id="moretemplate" class="collapse" data-parent="#apicalls">
<div class="card-body">
<div id="moretemplate" className="collapse" data-parent="#apicalls">
<div className="card-body">
<p>
{t('sendSingleEmailByTemplateWithGiven')}
</p>
Expand Down
4 changes: 4 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ MYSQL_PASSWORD=${MYSQL_PASSWORD:-'mailtrain'}
WITH_ZONE_MTA=${WITH_ZONE_MTA:-'true'}
POOL_NAME=${POOL_NAME:-$(hostname)}
LOG_LEVEL=${LOG_LEVEL:-'info'}
ADMIN_PASSWORD=${ADMIN_PASSWORD:-'test'}
ADMIN_ACCESS_TOKEN=${ADMIN_ACCESS_TOKEN:-''}

# Warning for users that already rely on the MAILTRAIN_SETTING variable
# Can probably be removed in the future.
Expand Down Expand Up @@ -191,4 +193,6 @@ if [ "$WITH_LDAP" = "true" ]; then
fi
fi

NODE_ENV=production node setup/docker-entrypoint-db-setup.js "$ADMIN_PASSWORD" "$ADMIN_ACCESS_TOKEN"

NODE_ENV=production node index.js
38 changes: 38 additions & 0 deletions server/setup/docker-entrypoint-db-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use strict';

const log = require('../lib/log');
const dbcheck = require('../lib/dbcheck');
const knex = require('../lib/knex');
const {getAdminId} = require("../../shared/users");
const bluebird = require('bluebird');
const bcrypt = require('bcrypt-nodejs');
const bcryptHash = bluebird.promisify(bcrypt.hash.bind(bcrypt));

async function init() {
const args = process.argv.slice(2);

if (args.length !== 2) {
log.error('Usage: NODE_ENV=production node setup/docker-entrypoint-db-setup.js <admin password> <admin access token>')
return;
}

const passwd = args[0];
const accessToken = args[1];

await dbcheck();
await knex.migrate.latest();


const hashedPasswd = await bcryptHash(passwd, null, null);
await knex('users').where({id: getAdminId()}).update({password: hashedPasswd});

if (accessToken !== '') {
await knex('users').where({id: getAdminId()}).update({access_token: accessToken});
}

process.exit(0);
}

init().catch(err => {log.error('', err); process.exit(1); });


0 comments on commit e38f80e

Please sign in to comment.