feat: encrypted user passwords
This commit is contained in:
1 parent
5fe88fc0f2
commit
fb6665668b
16 files changed
+292
-79
No files matched your search
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Traits;
|
||||
|
||||
use App\BusProNet\Model\Booking;
|
||||
use App\BusProNet\Model\Notification;
|
||||
use Psr\Cache\InvalidArgumentException;
|
||||
use Symfony\Contracts\Cache\ItemInterface;
|
||||
|
||||
trait BookingDataTrait
|
||||
{
|
||||
public function fetchBookingData(string $email, string $password, int $id): Booking|Notification|null
|
||||
{
|
||||
// Fetch booking data via API and cache result for a short ttl to check permissions
|
||||
$cacheKey = sprintf('bpn_booking_%d', $id);
|
||||
try {
|
||||
$bookingData = $this->cache->get($cacheKey, function (ItemInterface $item) use ($email, $password, $id) {
|
||||
$item->expiresAfter(300);
|
||||
|
||||
return $this->apiClient->getBooking($email, $password, $id);
|
||||
});
|
||||
} catch (InvalidArgumentException $e) {
|
||||
$bookingData = null;
|
||||
}
|
||||
|
||||
return $bookingData;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Traits;
|
||||
|
||||
use App\BusProNet\Security\User;
|
||||
use App\Security\Crypt;
|
||||
|
||||
trait CredentialsTrait
|
||||
{
|
||||
public function getPasswordPlain(User $bpnUser, string $pathToKeys): string
|
||||
{
|
||||
$crypt = new Crypt($pathToKeys);
|
||||
|
||||
return $crypt->decrypt($bpnUser->getPassword());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user