mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-03-05 20:44:19 +01:00
Compare commits
1 Commits
785d5d1165
...
php
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3192fb6c83 |
@@ -72,8 +72,11 @@ class QuizController extends AbstractController
|
||||
$candidate = $candidateRepository->getCandidateByHash($season, $nameHash);
|
||||
|
||||
if (!$candidate instanceof Candidate) {
|
||||
// Add option to add new candidate when preregister is disabled
|
||||
$this->addFlash(FlashType::Danger->value, 'Candidate not found');
|
||||
if ($season->isPreregisterCandidates() === false) {
|
||||
// create candidate
|
||||
}
|
||||
|
||||
$this->addFlash(FlashType::Danger->value, "Candidate {${Base64::base64_url_decode($nameHash)}} not found");
|
||||
|
||||
return $this->redirectToRoute('enter_name', ['seasonCode' => $season->getSeasonCode()]);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Helpers;
|
||||
|
||||
use Safe\Exceptions\UrlException;
|
||||
use function rtrim;
|
||||
|
||||
class Base64
|
||||
{
|
||||
@@ -12,14 +13,22 @@ class Base64
|
||||
{
|
||||
}
|
||||
|
||||
public static function base64_url_encode(string $input): string
|
||||
/**
|
||||
* @param string $name name to hash
|
||||
* @return string hashed name
|
||||
*/
|
||||
public static function base64_url_encode(string $name): string
|
||||
{
|
||||
return strtr(base64_encode($input), '+/', '-_');
|
||||
return rtrim(strtr(base64_encode($name), '+/', '-_'), '=');
|
||||
}
|
||||
|
||||
/** @throws UrlException */
|
||||
public static function base64_url_decode(string $input): string
|
||||
/**
|
||||
* @param string $hash hashed name
|
||||
* @return string plaintext name
|
||||
* @throws UrlException
|
||||
*/
|
||||
public static function base64_url_decode(string $hash): string
|
||||
{
|
||||
return \Safe\base64_decode(strtr($input, '-_', '+/'), true);
|
||||
return \Safe\base64_decode(strtr($hash, '-_', '+/'), true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user