mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Added members-autoredirect data attribute selector. (#261)
closes https://github.com/TryGhost/Team/issues/1800 - Added data attribute selector for custom login / signup forms to optionally prevent redirects coming from the magic link.
This commit is contained in:
parent
08cdddfb92
commit
30284909e9
2 changed files with 4 additions and 2 deletions
|
@ -11,6 +11,7 @@ function formSubmitHandler({event, form, errorEl, siteUrl, submitHandler}) {
|
|||
form.classList.remove('success', 'invalid', 'error');
|
||||
let emailInput = event.target.querySelector('input[data-members-email]');
|
||||
let nameInput = event.target.querySelector('input[data-members-name]');
|
||||
let autoRedirect = form?.dataset?.membersAutoredirect || 'true';
|
||||
let email = emailInput?.value;
|
||||
let name = (nameInput && nameInput.value) || undefined;
|
||||
let emailType = undefined;
|
||||
|
@ -36,7 +37,8 @@ function formSubmitHandler({event, form, errorEl, siteUrl, submitHandler}) {
|
|||
email: email,
|
||||
emailType: emailType,
|
||||
labels: labels,
|
||||
name: name
|
||||
name: name,
|
||||
autoRedirect: (autoRedirect === 'true')
|
||||
})
|
||||
}).then(function (res) {
|
||||
form.addEventListener('submit', submitHandler);
|
||||
|
|
|
@ -131,7 +131,7 @@ describe('Member Data attributes:', () => {
|
|||
|
||||
expect(window.fetch).toHaveBeenCalledTimes(1);
|
||||
|
||||
expect(window.fetch).toHaveBeenCalledWith('https://portal.localhost/members/api/send-magic-link/', {body: '{"email":"jamie@example.com","emailType":"signup","labels":["Gold"],"name":"Jamie Larsen"}', headers: {'Content-Type': 'application/json'}, method: 'POST'});
|
||||
expect(window.fetch).toHaveBeenCalledWith('https://portal.localhost/members/api/send-magic-link/', {body: `{"email":"jamie@example.com","emailType":"signup","labels":["Gold"],"name":"Jamie Larsen","autoRedirect":${true}}`, headers: {'Content-Type': 'application/json'}, method: 'POST'});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue