Magic URL improvements
This commit is contained in:
parent
af019369e9
commit
86158838a1
|
@ -8,13 +8,13 @@
|
|||
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Poppins:wght@500;600&display=swap"
|
||||
rel="stylesheet">
|
||||
<style>
|
||||
a { color:currentColor; }
|
||||
a { color:currentColor; word-break: break-all; }
|
||||
body {
|
||||
padding: 32px;
|
||||
color: #616B7C;
|
||||
font-size: 15px;
|
||||
font-family: 'Inter', sans-serif;
|
||||
line-height: 15px;
|
||||
line-height: 150%;
|
||||
}
|
||||
|
||||
table {
|
||||
|
@ -52,7 +52,7 @@
|
|||
<body style="direction: {{direction}}">
|
||||
|
||||
<div style="max-width:650px; word-wrap: break-word; overflow-wrap: break-word;
|
||||
word-break: break-all; margin:0 auto;">
|
||||
word-break: normal; margin:0 auto;">
|
||||
<table style="margin-top: 32px">
|
||||
<tr>
|
||||
<td>
|
||||
|
|
20
app/config/locale/templates/email-magic-url.tpl
Normal file
20
app/config/locale/templates/email-magic-url.tpl
Normal file
|
@ -0,0 +1,20 @@
|
|||
<p>{{hello}}</p>
|
||||
|
||||
<p>{{optionButton}}</p>
|
||||
|
||||
<table border="0" cellspacing="0" cellpadding="0" style="padding-top: 10px; padding-bottom: 10px; display: inline-block;">
|
||||
<tr>
|
||||
<td align="center" style="border-radius: 8px; background-color: #19191D;">
|
||||
<a rel="noopener" target="_blank" href="{{redirect}}" style="font-size: 14px; font-family: Inter; color: #ffffff; text-decoration: none; border-radius: 8px; padding: 14px 9px; border: 1px solid #19191D; display: inline-block;">{{buttonText}}</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>{{optionUrl}}</p>
|
||||
|
||||
<a href="{{redirect}}" target="_blank" style="font-size: 12px; line-height: 100%;">{{redirect}}</a>
|
||||
|
||||
<p>{{clientInfo}}</p>
|
||||
|
||||
<p style="margin-bottom: 0px;">{{thanks}}</p>
|
||||
<p style="margin-top: 0px;">{{signature}}</p>
|
|
@ -9,11 +9,13 @@
|
|||
"emails.verification.footer": "If you didn’t ask to verify this address, you can ignore this message.",
|
||||
"emails.verification.thanks": "Thanks",
|
||||
"emails.verification.signature": "{{project}} team",
|
||||
"emails.magicSession.subject": "Login",
|
||||
"emails.magicSession.hello": "Hey,",
|
||||
"emails.magicSession.body": "Follow this link to login.",
|
||||
"emails.magicSession.footer": "If you didn’t ask to login using this email, you can ignore this message.",
|
||||
"emails.magicSession.thanks": "Thanks",
|
||||
"emails.magicSession.subject": "{{project}} Login",
|
||||
"emails.magicSession.hello": "Hello,",
|
||||
"emails.magicSession.optionButton": "Click the button below to securely sign in to your {{project}} account. It will expire in 1 hour.",
|
||||
"emails.magicSession.buttonText": "Sign in to {{project}}",
|
||||
"emails.magicSession.optionUrl": "If the button above doesn't show, use the following link:",
|
||||
"emails.magicSession.clientInfo": "This sign in was requested using {{agentClient}} on {{agentDevice}} {{agentOs}}. If you didn't request the sign in, you can safely ignore this email.",
|
||||
"emails.magicSession.thanks": "Thanks,",
|
||||
"emails.magicSession.signature": "{{project}} team",
|
||||
"emails.recovery.subject": "Password Reset",
|
||||
"emails.recovery.hello": "Hello {{user}}",
|
||||
|
|
|
@ -1002,7 +1002,7 @@ App::post('/v1/account/sessions/magic-url')
|
|||
Authorization::skip(fn () => $dbForProject->createDocument('users', $user));
|
||||
}
|
||||
|
||||
$loginSecret = Auth::tokenGenerator();
|
||||
$loginSecret = Auth::tokenGenerator(32);
|
||||
$expire = DateTime::formatTz(DateTime::addSeconds(new \DateTime(), Auth::TOKEN_EXPIRATION_CONFIRM));
|
||||
|
||||
$token = new Document([
|
||||
|
@ -1039,11 +1039,19 @@ App::post('/v1/account/sessions/magic-url')
|
|||
$subject = $locale->getText("emails.magicSession.subject");
|
||||
$customTemplate = $project->getAttribute('templates', [])['email.magicSession-' . $locale->default] ?? [];
|
||||
|
||||
$message = Template::fromFile(__DIR__ . '/../../config/locale/templates/email-inner-base.tpl');
|
||||
$detector = new Detector($request->getUserAgent('UNKNOWN'));
|
||||
$agentOs = $detector->getOS();
|
||||
$agentClient = $detector->getClient();
|
||||
$agentDevice = $detector->getDevice();
|
||||
|
||||
$message = Template::fromFile(__DIR__ . '/../../config/locale/templates/email-magic-url.tpl');
|
||||
$message
|
||||
->setParam('{{body}}', $body)
|
||||
->setParam('{{hello}}', $locale->getText("emails.magicSession.hello"))
|
||||
->setParam('{{footer}}', $locale->getText("emails.magicSession.footer"))
|
||||
->setParam('{{optionButton}}', $locale->getText("emails.magicSession.optionButton"))
|
||||
->setParam('{{buttonText}}', $locale->getText("emails.magicSession.buttonText"))
|
||||
->setParam('{{optionUrl}}', $locale->getText("emails.magicSession.optionUrl"))
|
||||
->setParam('{{clientInfo}}', $locale->getText("emails.magicSession.clientInfo"))
|
||||
->setParam('{{thanks}}', $locale->getText("emails.magicSession.thanks"))
|
||||
->setParam('{{signature}}', $locale->getText("emails.magicSession.signature"));
|
||||
$body = $message->render();
|
||||
|
@ -1100,7 +1108,10 @@ App::post('/v1/account/sessions/magic-url')
|
|||
'user' => '',
|
||||
'team' => '',
|
||||
'project' => $project->getAttribute('name'),
|
||||
'redirect' => $url
|
||||
'redirect' => $url,
|
||||
'agentDevice' => $agentDevice['deviceBrand'] ?? $agentDevice['deviceBrand'] ?? 'UNKNOWN',
|
||||
'agentClient' => $agentClient['clientName'] ?? 'UNKNOWN',
|
||||
'agentOs' => $agentOs['osName'] ?? 'UNKNOWN'
|
||||
];
|
||||
|
||||
$queueForMails
|
||||
|
|
|
@ -67,7 +67,7 @@ class Auth
|
|||
public const TOKEN_EXPIRATION_LOGIN_LONG = 31536000; /* 1 year */
|
||||
public const TOKEN_EXPIRATION_LOGIN_SHORT = 3600; /* 1 hour */
|
||||
public const TOKEN_EXPIRATION_RECOVERY = 3600; /* 1 hour */
|
||||
public const TOKEN_EXPIRATION_CONFIRM = 3600 * 24 * 7; /* 7 days */
|
||||
public const TOKEN_EXPIRATION_CONFIRM = 3600 * 1; /* 1 hour */
|
||||
public const TOKEN_EXPIRATION_PHONE = 60 * 15; /* 15 minutes */
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue