Now with ability to email license sign in link
This commit is contained in:
@@ -151,7 +151,7 @@ let events_session_data_struct: key_val = {
|
||||
|
||||
entered_search_str: null,
|
||||
|
||||
lead_data_changed: false,
|
||||
lead_data_changed: null,
|
||||
|
||||
qr_scan_start: true,
|
||||
qr_scan_result: null,
|
||||
|
||||
@@ -103,6 +103,51 @@ onMount(() => {
|
||||
goto(new_url, {replaceState: true});
|
||||
}
|
||||
|
||||
// Look for a license key (email address) and passcode in the URL params. The email address may have had a plus symbol and replaced with a space. (example: test+more@example.com) This needs to be fixed.
|
||||
let url_lic_key = data.url.searchParams.get('key');
|
||||
let url_lic_pass = data.url.searchParams.get('pass');
|
||||
if (url_lic_key && url_lic_pass) {
|
||||
// Replace the space with a plus symbol.
|
||||
url_lic_key = url_lic_key.replace(/ /g, '+');
|
||||
|
||||
console.log(`ae_events_leads exhibit [slug] +page.svelte: event_exhibit_id=${$events_slct.exhibit_id}; key=${url_lic_key}; pass=${url_lic_pass}`);
|
||||
|
||||
// Check the license key and passcode against the event exhibit object.
|
||||
console.log($events_slct.exhibit_obj.license_li_json);
|
||||
// We need to loop through the $events_slct.exhibit_obj.license_li_json list/array and check if the "email" and "passcode" matches.
|
||||
if ($events_slct.exhibit_obj.license_li_json && $events_slct.exhibit_obj.license_li_json.length) {
|
||||
for (let i = 0; i < $events_slct.exhibit_obj.license_li_json.length; i++) {
|
||||
console.log(`${i} License email: ${$events_slct.exhibit_obj.license_li_json[i].email}; License passcode: ${$events_slct.exhibit_obj.license_li_json[i].passcode}`);
|
||||
|
||||
if ($events_slct.exhibit_obj.license_li_json[i].email == url_lic_key && $events_slct.exhibit_obj.license_li_json[i].passcode == url_lic_pass) {
|
||||
console.log('License key passcode matched');
|
||||
$events_loc.leads.auth_exhibit_kv[$events_slct.exhibit_id] = {
|
||||
key: url_lic_key,
|
||||
updated_on: new Date().toISOString()
|
||||
};
|
||||
data.url.searchParams.delete('key');
|
||||
data.url.searchParams.delete('pass');
|
||||
let new_url = data.url.toString()
|
||||
console.log(new_url);
|
||||
goto(new_url, {replaceState: true});
|
||||
} else {
|
||||
console.log('License key passcode does not match');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// if ($events_slct.exhibit_obj.license_li_json[url_lic_key] && $events_slct.exhibit_obj.license_li_json[url_lic_key].passcode == url_lic_pass) {
|
||||
// console.log('License key passcode matched');
|
||||
// $events_loc.leads.auth_exhibit_kv[$events_slct.exhibit_id] = {
|
||||
// key: url_lic_key,
|
||||
// updated_on: new Date().toISOString()
|
||||
// };
|
||||
// } else {
|
||||
// console.log('License key passcode does not match');
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
|
||||
// // We need to remove the url_passcode from the URL GET params after we use it. It should be safe to assume that onMount is a safe place to do this.
|
||||
// if (url_passcode) {
|
||||
// // console.log('Remove the passcode from the URL.');
|
||||
@@ -383,32 +428,36 @@ async function handle_update__exhibit({
|
||||
|
||||
|
||||
|
||||
function send_init_confirm_email({to_email}) {
|
||||
console.log(`*** send_init_confirm_email() *** to ${to_email}.`);
|
||||
function send_init_confirm_email({index, lic_key, lic_pass}) {
|
||||
console.log(`*** send_init_confirm_email() *** to ${lic_key}.`);
|
||||
|
||||
let license_key = to_email;
|
||||
let to_email = lic_key;
|
||||
|
||||
let sign_in_url = encodeURI(`${data.url.origin}/events_leads/exhibit/${$events_slct.exhibit_id}?key=${lic_key}&pass=${lic_pass}`);
|
||||
|
||||
let subject = `Leads License Link for ${$event_exhibit_obj?.name} (ID: ${$events_slct.exhibit_id})`;
|
||||
|
||||
let body_html = `
|
||||
<div>${$event_exhibit_obj?.license_li_json[license_key].full_name},
|
||||
<div>${$event_exhibit_obj?.license_li_json[index].full_name},
|
||||
<p>If this was sent to you incorrectly, please ignore.</p>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<div>
|
||||
Exhibit ID: ${$events_slct.exhibit_id}<br>
|
||||
<p>Use your license key sign in link below.<br>
|
||||
Copy and paste link: <a href="${data.url.origin}/events_leads/exhibit/${$events_slct.exhibit_id}?license_key=${license_key}">${data.url.origin}/events_leads/exhibit/${$events_slct.exhibit_id}?license_key=${license_key}&event_id=${$events_slct.event_id}</a></p>
|
||||
<p>If the email or passcode for your exhibit is changed, this link will no longer work.</p>
|
||||
<p>Exhibit: ${$event_exhibit_obj?.name}<br>
|
||||
Exhibit ID: ${$events_slct.exhibit_id}</p>
|
||||
|
||||
<p>Use the link below to sign in using your leads license.<br>
|
||||
Copy and paste link: <a href="${sign_in_url}">${sign_in_url}</a></p>
|
||||
<p>If the email or passcode for your license is changed, this link will no longer work.</p>
|
||||
</div>
|
||||
`;
|
||||
|
||||
api.send_email({
|
||||
api_cfg: $ae_api,
|
||||
from_email: 'noreply+leads@oneskyit.com',
|
||||
from_name: 'OSIT Events - Leads',
|
||||
from_name: 'OSIT Exhibit Leads',
|
||||
to_email: to_email,
|
||||
subject: subject,
|
||||
body_html: body_html,
|
||||
@@ -561,7 +610,7 @@ function send_init_confirm_email({to_email}) {
|
||||
<h2 class="h3">
|
||||
<!-- {$events_slct.exhibit_obj.name} -->
|
||||
<strong>{$event_exhibit_obj?.name ?? 'Welcome to Leads for Exhibits!'}</strong>
|
||||
<strong>{$event_exhibit_obj?.code ?? ''}</strong>
|
||||
<strong># {$event_exhibit_obj?.code ?? ''}</strong>
|
||||
</h2>
|
||||
<h3 class="h4">
|
||||
{#if $events_loc.leads.auth_exhibit_kv[$events_slct.exhibit_id] && $events_loc.leads.auth_exhibit_kv[$events_slct.exhibit_id].key}
|
||||
@@ -742,18 +791,21 @@ function send_init_confirm_email({to_email}) {
|
||||
on:click={() => {
|
||||
console.log('Send Email');
|
||||
// Send an email with the login link
|
||||
send_init_confirm_email({ to_email: license.email });
|
||||
if (confirm(`Are you sure you want to send an email with the login link to ${license.email}?`)) {
|
||||
send_init_confirm_email({ index: index, lic_key: license.email, lic_pass: license.passcode});
|
||||
}
|
||||
// send_init_confirm_email({ index: index, lic_key: license.email, lic_pass: license.passcode});
|
||||
}}
|
||||
disabled={!$ae_loc.trusted_access}
|
||||
disabled={!$ae_loc.trusted_access && 2==4}
|
||||
class="btn btn-sm text-sm variant-soft-secondary"
|
||||
title={`TEMPORARILY DISABLED: Send an email with the license login link to ${license.email}`}
|
||||
title={`Send an email with the license login link to ${license.email}`}
|
||||
>
|
||||
<span class="fas fa-envelope mx-1"></span>
|
||||
Email
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
use:clipboard={$events_slct.exhibit_obj.url}
|
||||
use:clipboard={encodeURI(`${data.url.origin}/events_leads/exhibit/${$events_slct.exhibit_id}?key=${license.email}&pass=${license.passcode}`)}
|
||||
class="btn btn-sm text-sm variant-soft-tertiary"
|
||||
class:hidden={!$ae_loc.trusted_access || !$events_loc.show_details}
|
||||
title={`Copy link to this exhibit (ID: ${$events_slct.exhibit_id})`}
|
||||
|
||||
@@ -57,6 +57,9 @@ export let get_event_exhibit_tracking_export = async function get_event_exhibit_
|
||||
<div class="space-y-2">
|
||||
<p class="mb-4"><strong>{@html $event_exhibit_obj?.priority ? '<span class="fas fa-check text-green-500"></span> Leads license(s) marked as paid for this exhibit!' : 'The leads license have not been marked as paid yet. If you have already paid, please wait and this will be reflected here within 48 business hours.'}</strong></p>
|
||||
|
||||
<p>Exhibit name: <strong>{$events_slct.exhibit_obj.name} # {$events_slct.exhibit_obj.code}</strong></p>
|
||||
|
||||
<div class="space-y-2">
|
||||
<strong>Logged in and using license for:</strong>
|
||||
{#if $event_exhibit_obj?.license_li_json}
|
||||
<!-- <div class="flex flex-row wrap gap-1"> -->
|
||||
@@ -78,6 +81,8 @@ export let get_event_exhibit_tracking_export = async function get_event_exhibit_
|
||||
<span class="ae_label">Started:</span>
|
||||
<span class="ae_value">{ae_util.iso_datetime_formatter($events_loc.leads.auth_exhibit_kv[$events_slct.exhibit_id].updated_on, 'datetime_long')}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Show the full_name of the person associated with that license key email address. The license information is stored in an array. The license key is not the index number value in the array. Ideally I was planning to make the key the email address, not an array index number. -->
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -178,10 +178,12 @@ async function handle_submit_form_lead_update(event) {
|
||||
</div>
|
||||
{:then update__exhibit_tracking_obj}
|
||||
<!-- {#if update__exhibit_tracking_obj} -->
|
||||
{#if $events_sess.leads.lead_data_changed === false}
|
||||
<div class="modal-loading">
|
||||
<span class="fas fa-check-circle"></span>
|
||||
<span class="loading-text">Successfully saved!</span>
|
||||
</div>
|
||||
{/if}
|
||||
<!-- {/if} -->
|
||||
{:catch error}
|
||||
<div class="modal-loading">
|
||||
@@ -195,6 +197,7 @@ async function handle_submit_form_lead_update(event) {
|
||||
type="button"
|
||||
class="btn variant-soft-primary"
|
||||
on:click={() => {
|
||||
$events_sess.leads.lead_data_changed = null;
|
||||
$events_sess.leads.show_form__view_lead = false;
|
||||
}}
|
||||
>
|
||||
@@ -613,6 +616,7 @@ async function handle_submit_form_lead_update(event) {
|
||||
class="btn variant-soft-primary"
|
||||
on:click={() => {
|
||||
$events_sess.leads.show_form__view_lead = false;
|
||||
$events_sess.leads.lead_data_changed = null;
|
||||
}}
|
||||
>
|
||||
<span class="fas fa-times mx-1"></span>
|
||||
|
||||
Reference in New Issue
Block a user