Skip to content

Commit

Permalink
Merge branch 'release/3.6.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Mar 14, 2022
2 parents 3ff1f09 + 7e6567c commit b9280a5
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 17 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v3.6.3
## 03/14/2022

1. [](#improved)
* Improved multi-site support in user emails

# v3.6.2
## 01/12/2022

Expand All @@ -10,7 +16,7 @@

1. [](#bugfix)
* Fixed issue with forgot password error message translation [#285](https://github.com/getgrav/grav-plugin-login/pull/285)
*

# v3.6.0
## 10/26/2021

Expand Down
2 changes: 1 addition & 1 deletion blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Login
slug: login
type: plugin
version: 3.6.2
version: 3.6.3
testing: false
description: Enables user authentication and login screen.
icon: sign-in
Expand Down
26 changes: 15 additions & 11 deletions classes/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
use Grav\Common\Config\Config;
use Grav\Common\Grav;
use Grav\Common\Language\Language;
use Grav\Common\Page\Pages;
use Grav\Common\Uri;
use Grav\Common\User\Interfaces\UserCollectionInterface;
use Grav\Common\User\Interfaces\UserInterface;
use Grav\Common\Utils;
use Grav\Plugin\Email\Utils as EmailUtils;
use Grav\Plugin\Form\Form;
use Grav\Plugin\Form\Forms;
use Grav\Plugin\Login\Events\UserLoginEvent;
use Grav\Plugin\Login\Invitations\Invitation;
Expand Down Expand Up @@ -343,7 +343,9 @@ public function taskLogout()
*/
protected function taskForgot()
{
$param_sep = $this->grav['config']->get('system.param_sep', ':');
/** @var Config $config */
$config = $this->grav['config'];
$param_sep = $config->get('system.param_sep', ':');
$data = $this->post;

/** @var UserCollectionInterface $users */
Expand Down Expand Up @@ -386,7 +388,7 @@ protected function taskForgot()
return true;
}

$from = $this->grav['config']->get('plugins.email.from');
$from = $config->get('plugins.email.from');

if (empty($from)) {
$messages->add($language->translate('PLUGIN_LOGIN.FORGOT_EMAIL_NOT_CONFIGURED'), 'error');
Expand All @@ -412,19 +414,21 @@ protected function taskForgot()
$user->reset = $token . '::' . $expire;
$user->save();

$author = $this->grav['config']->get('site.author.name', '');
$author = $config->get('site.author.name', '');
$fullname = $user->fullname ?: $user->username;

if ($this->grav['language']->getDefault() != $this->grav['language']->getLanguage()) {
$lang = '/'.$this->grav['language']->getLanguage();
} else {
$lang = '';
$resetRoute = $this->login->getRoute('reset');
if (!$resetRoute) {
throw new \RuntimeException('Password reset route does not exist!');
}

$resetRoute = $this->login->getRoute('reset');
$reset_link = $this->grav['base_url_absolute'] . $lang . $resetRoute . '/task' . $param_sep . 'login.reset/token' . $param_sep . $token . '/user' . $param_sep . $user->username . '/nonce' . $param_sep . Utils::getNonce('reset-form');
/** @var Pages $pages */
$pages = $this->grav['pages'];
$route = $pages->url($resetRoute, null, true);

$reset_link = $route . '/task' . $param_sep . 'login.reset/token' . $param_sep . $token . '/user' . $param_sep . $user->username . '/nonce' . $param_sep . Utils::getNonce('reset-form');

$sitename = $this->grav['config']->get('site.title', 'Website');
$sitename = $config->get('site.title', 'Website');

$to = $user->email;

Expand Down
20 changes: 16 additions & 4 deletions classes/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,13 @@ public function sendActivationEmail(UserInterface $user)

$param_sep = $this->config->get('system.param_sep', ':');
$activationRoute = $this->getRoute('activate');
$activation_link = $this->grav['base_url_absolute'] . $activationRoute . '/token' . $param_sep . $token . '/username' . $param_sep . $user->username;
if (!$activationRoute) {
throw new \RuntimeException('User activation route does not exist!');
}

/** @var Pages $pages */
$pages = $this->grav['pages'];
$activationLink = $pages->url($activationRoute . '/token' . $param_sep . $token . '/username' . $param_sep . $user->username, null, true);

$site_name = $this->config->get('site.title', 'Website');
$author = $this->grav['config']->get('site.author.name', '');
Expand All @@ -536,7 +542,7 @@ public function sendActivationEmail(UserInterface $user)
$subject = $this->language->translate(['PLUGIN_LOGIN.ACTIVATION_EMAIL_SUBJECT', $site_name]);
$content = $this->language->translate(['PLUGIN_LOGIN.ACTIVATION_EMAIL_BODY',
$fullname,
$activation_link,
$activationLink,
$site_name,
$author
]);
Expand Down Expand Up @@ -566,12 +572,18 @@ public function sendInviteEmail(Invitation $invitation, string $message = null,

$param_sep = $this->config->get('system.param_sep', ':');
$inviteRoute = $this->getRoute('register', true);
$invitationLink = $this->grav['base_url_absolute'] . "{$inviteRoute}/{$param_sep}{$invitation->token}";
if (!$inviteRoute) {
throw new \RuntimeException('User registration route does not exist!');
}

/** @var Pages $pages */
$pages = $this->grav['pages'];
$invitationLink = $pages->url("{$inviteRoute}/{$param_sep}{$invitation->token}", null, true);

$siteName = $this->config->get('site.title', 'Website');

$subject = $this->language->translate(['PLUGIN_LOGIN.INVITATION_EMAIL_SUBJECT', $siteName]);
$message = $message ?? $this->language->translate(['PLUGIN_LOGIN.INVITATION_EMAIL_MESSAGE']);
$message = $message ?? (string)$this->language->translate(['PLUGIN_LOGIN.INVITATION_EMAIL_MESSAGE']);
$content = $this->language->translate(['PLUGIN_LOGIN.INVITATION_EMAIL_BODY',
$siteName,
$message,
Expand Down

0 comments on commit b9280a5

Please sign in to comment.