mirror of
https://github.com/standardebooks/web.git
synced 2025-07-07 07:10:29 -04:00
Improve error message for people trying to log in to the Patrons Circle
This commit is contained in:
parent
95d1b9e02e
commit
cf5f488cae
9 changed files with 104 additions and 11 deletions
|
@ -1,4 +1,6 @@
|
|||
<?
|
||||
|
||||
use Exceptions\InvalidLoginException;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Safe\DateTimeImmutable;
|
||||
|
||||
|
@ -72,7 +74,21 @@ class Session{
|
|||
self::SetSessionCookie($this->SessionId);
|
||||
}
|
||||
catch(Exceptions\UserNotFoundException){
|
||||
throw new Exceptions\InvalidLoginException();
|
||||
// We couldn't find a *registered * `User`. But, often people make a small donation assuming it automatically adds them to the Patrons Circle. So, check if they made a donation less than 7 days ago, and if so, notify them about the requirements to join the Patrons Circle.
|
||||
$ex = new Exceptions\InvalidLoginException();
|
||||
try{
|
||||
$user = User::GetByIdentifier($identifier);
|
||||
/** @throws void */
|
||||
if($user->LastPayment !== null && $user->LastPayment->Created > new DateTimeImmutable('7 days ago')){
|
||||
$ex = new InvalidLoginException('<p>We couldn’t find you in the Patrons Circle, but you recently ' . ($user->LastPayment->IsRecurring ? 'started a recurring' : 'made a one-time') . ' donation of ' . Formatter::FormatCurrency($user->LastPayment->Amount) . '.</p><p>To join the Patrons Circle, supporters must <a href="/donate#patrons-circle">start a recurring donation</a> of ' . Formatter::FormatCurrency(PATRONS_CIRCLE_MONTHLY_COST, true) . '/month or more, or <a href="/donate#patrons-circle">make a one-time donation</a> of ' . Formatter::FormatCurrency(PATRONS_CIRCLE_YEARLY_COST, true) . ' or more to join for one year.</p><p>Once you join the Patrons Circle, you’ll be able to log in and access member benefits.</p>');
|
||||
$ex->MessageType = Enums\ExceptionMessageType::Html;
|
||||
}
|
||||
}
|
||||
catch(Exceptions\UserNotFoundException){
|
||||
// Pass.
|
||||
}
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue