chg: pkg: upgrade the doctrine related back-end pkgs to the latest available version #7
This commit is contained in:
@@ -91,7 +91,7 @@ class GameController extends AbstractController
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$contactMessage->setIpAddress($request->getClientIp());
|
||||
$contactMessage->ipAddress = $request->getClientIp();
|
||||
|
||||
$em->persist($contactMessage);
|
||||
$em->flush();
|
||||
|
||||
@@ -137,16 +137,16 @@ class MercureController extends AbstractController
|
||||
|
||||
$result = array_map(static function (PlayedGame $g): array {
|
||||
$name = match (true) {
|
||||
null !== $g->getRed() => $g->getRed()->getUsername(),
|
||||
null !== $g->getRedAnon() => $g->getRedAnon()->getUserName(),
|
||||
null !== $g->getBlue() => $g->getBlue()->getUsername(),
|
||||
default => $g->getBlueAnon()?->getUserName() ?? 'Unknown',
|
||||
null !== $g->red => $g->red->getUsername(),
|
||||
null !== $g->redAnon => $g->redAnon->userName,
|
||||
null !== $g->blue => $g->blue->getUsername(),
|
||||
default => $g->blueAnon?->userName ?? 'Unknown',
|
||||
};
|
||||
|
||||
return [
|
||||
'gameAssoc' => $g->getGameAssoc(),
|
||||
'gameAssoc' => $g->gameAssoc,
|
||||
'name' => $name,
|
||||
'since' => $g->getCreated()?->format(\DateTimeInterface::ATOM) ?? '',
|
||||
'since' => $g->created?->format(\DateTimeInterface::ATOM) ?? '',
|
||||
];
|
||||
}, $games);
|
||||
|
||||
|
||||
@@ -78,22 +78,22 @@ class ProfileController extends AbstractController
|
||||
|
||||
$since = new DateTime('first day of -5 months midnight');
|
||||
$recentGames = $this->repo->findFinishedForUserSince($user, $since);
|
||||
$userId = $user->getId();
|
||||
$userId = $user->id;
|
||||
|
||||
foreach ($recentGames as $game) {
|
||||
if (!$game->getUpdated()) {
|
||||
if (!$game->updated) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$month = $game->getUpdated()->format('Y-m');
|
||||
$month = $game->updated->format('Y-m');
|
||||
if (!isset($monthlyData[$month])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$isRed = $game->getRed()?->getId() === $userId;
|
||||
$myPts = $isRed ? $game->getRedPoints() : $game->getBluePoints();
|
||||
$oppPts = $isRed ? $game->getBluePoints() : $game->getRedPoints();
|
||||
$resign = $game->getResign();
|
||||
$isRed = $game->red?->id === $userId;
|
||||
$myPts = $isRed ? $game->redPoints : $game->bluePoints;
|
||||
$oppPts = $isRed ? $game->bluePoints : $game->redPoints;
|
||||
$resign = $game->resign;
|
||||
$myColor = $isRed ? 'red' : 'blue';
|
||||
$oppColor = $isRed ? 'blue' : 'red';
|
||||
|
||||
@@ -131,12 +131,12 @@ class ProfileController extends AbstractController
|
||||
],
|
||||
'recent' => ($recent = $this->repo->findRecentFinishedForUser($user, 30)),
|
||||
'gamesData' => array_map(function (PlayedGame $game) use ($userId, $cacheManager): array {
|
||||
$isRed = $game->getRed()?->getId() === $userId;
|
||||
$resign = $game->getResign();
|
||||
$isRed = $game->red?->id === $userId;
|
||||
$resign = $game->resign;
|
||||
$myColor = $isRed ? 'red' : 'blue';
|
||||
$oppColor = $isRed ? 'blue' : 'red';
|
||||
$myPts = $isRed ? $game->getRedPoints() : $game->getBluePoints();
|
||||
$oppPts = $isRed ? $game->getBluePoints() : $game->getRedPoints();
|
||||
$myPts = $isRed ? $game->redPoints : $game->bluePoints;
|
||||
$oppPts = $isRed ? $game->bluePoints : $game->redPoints;
|
||||
$result = 'draw';
|
||||
|
||||
if ($resign === $myColor) $result = 'loss';
|
||||
@@ -146,33 +146,33 @@ class ProfileController extends AbstractController
|
||||
elseif ($myPts < $oppPts) $result = 'loss';
|
||||
}
|
||||
|
||||
$redAvatarPath = $game->getRed()?->getAvatarPath();
|
||||
$blueAvatarPath = $game->getBlue()?->getAvatarPath();
|
||||
$redAvatarPath = $game->red?->avatarPath;
|
||||
$blueAvatarPath = $game->blue?->avatarPath;
|
||||
|
||||
return [
|
||||
'id' => $game->getId(),
|
||||
'uuid' => $game->getUuid()?->toRfc4122(),
|
||||
'id' => $game->id,
|
||||
'uuid' => $game->uuid?->toRfc4122(),
|
||||
'redName' =>
|
||||
$game->getRed()?->getUsername() ?? $game->getRedAnon()?->getUserName() ?? 'Guest',
|
||||
$game->red?->getUsername() ?? $game->redAnon?->userName ?? 'Guest',
|
||||
'blueName' =>
|
||||
$game->getBlue()?->getUsername() ?? $game->getBlueAnon()?->getUserName() ?? 'Guest',
|
||||
$game->blue?->getUsername() ?? $game->blueAnon?->userName ?? 'Guest',
|
||||
'redAvatar' => $redAvatarPath ? $cacheManager->generateUrl($redAvatarPath, 'avatar_thumb') : null,
|
||||
'blueAvatar' => $blueAvatarPath ? $cacheManager->generateUrl($blueAvatarPath, 'avatar_thumb') : null,
|
||||
'redPoints' => $game->getRedPoints(),
|
||||
'bluePoints' => $game->getBluePoints(),
|
||||
'redExplodedBomb' => $game->getRedExplodedBomb(),
|
||||
'blueExplodedBomb' => $game->getBlueExplodedBomb(),
|
||||
'redPoints' => $game->redPoints,
|
||||
'bluePoints' => $game->bluePoints,
|
||||
'redExplodedBomb' => $game->redExplodedBomb,
|
||||
'blueExplodedBomb' => $game->blueExplodedBomb,
|
||||
'resign' => $resign,
|
||||
'created' => $game->getCreated()?->format('Y-m-d H:i'),
|
||||
'date' => $game->getUpdated()?->format('Y-m-d H:i'),
|
||||
'created' => $game->created?->format('Y-m-d H:i'),
|
||||
'date' => $game->updated?->format('Y-m-d H:i'),
|
||||
'isRed' => $isRed,
|
||||
'result' => $result,
|
||||
'myPoints' => $myPts,
|
||||
'oppPoints' => $oppPts,
|
||||
'redBonusPoints' => $game->getRedBonusPoints() ?? 0,
|
||||
'blueBonusPoints' => $game->getBlueBonusPoints() ?? 0,
|
||||
'redBonusStats' => $game->getRedBonusStats() ?? [],
|
||||
'blueBonusStats' => $game->getBlueBonusStats() ?? [],
|
||||
'redBonusPoints' => $game->redBonusPoints ?? 0,
|
||||
'blueBonusPoints' => $game->blueBonusPoints ?? 0,
|
||||
'redBonusStats' => $game->redBonusStats ?? [],
|
||||
'blueBonusStats' => $game->blueBonusStats ?? [],
|
||||
];
|
||||
}, $recent),
|
||||
'chartData' => [
|
||||
@@ -202,10 +202,10 @@ class ProfileController extends AbstractController
|
||||
$mines = [];
|
||||
$bonus = [];
|
||||
foreach ($recent as $i => $game) {
|
||||
$isRed = $game->getRed()?->getId() === $userId;
|
||||
$isRed = $game->red?->id === $userId;
|
||||
$labels[] = '#' . ($i + 1);
|
||||
$mines[] = (int)($isRed ? $game->getRedPoints() : $game->getBluePoints());
|
||||
$bonus[] = (float)($isRed ? $game->getRedBonusPoints() : $game->getBlueBonusPoints()) ?: 0;
|
||||
$mines[] = (int)($isRed ? $game->redPoints : $game->bluePoints);
|
||||
$bonus[] = (float)($isRed ? $game->redBonusPoints : $game->blueBonusPoints) ?: 0;
|
||||
}
|
||||
|
||||
return ['labels' => $labels, 'mines' => $mines, 'bonus' => $bonus];
|
||||
@@ -224,17 +224,17 @@ class ProfileController extends AbstractController
|
||||
throw $this->createNotFoundException('Battle not found.');
|
||||
}
|
||||
|
||||
$redName = $game->getRed()?->getUsername() ?? ($game->getRedAnon() !== null ? 'Anonymous' : 'Guest');
|
||||
$blueName = $game->getBlue()?->getUsername() ?? ($game->getBlueAnon() !== null ? 'Anonymous' : 'Guest');
|
||||
$redPts = $game->getRedPoints();
|
||||
$bluePts = $game->getBluePoints();
|
||||
$resign = $game->getResign();
|
||||
$redAvatar = $game->getRed()?->getAvatarPath();
|
||||
$blueAvatar = $game->getBlue()?->getAvatarPath();
|
||||
$redBonusPoints = $game->getRedBonusPoints() ?? 0;
|
||||
$blueBonusPoints = $game->getBlueBonusPoints() ?? 0;
|
||||
$redBonusStats = $game->getRedBonusStats() ?? [];
|
||||
$blueBonusStats = $game->getBlueBonusStats() ?? [];
|
||||
$redName = $game->red?->getUsername() ?? ($game->redAnon !== null ? 'Anonymous' : 'Guest');
|
||||
$blueName = $game->blue?->getUsername() ?? ($game->blueAnon !== null ? 'Anonymous' : 'Guest');
|
||||
$redPts = $game->redPoints;
|
||||
$bluePts = $game->bluePoints;
|
||||
$resign = $game->resign;
|
||||
$redAvatar = $game->red?->avatarPath;
|
||||
$blueAvatar = $game->blue?->avatarPath;
|
||||
$redBonusPoints = $game->redBonusPoints ?? 0;
|
||||
$blueBonusPoints = $game->blueBonusPoints ?? 0;
|
||||
$redBonusStats = $game->redBonusStats ?? [];
|
||||
$blueBonusStats = $game->blueBonusStats ?? [];
|
||||
|
||||
if ($resign === 'red') {
|
||||
$summary = "$redName resigned — $blueName wins";
|
||||
@@ -321,7 +321,7 @@ class ProfileController extends AbstractController
|
||||
|
||||
$ext = $file->guessExtension() ?? 'jpg';
|
||||
$newPath = sprintf('avatar/%s.%s', Uuid::v4()->toRfc4122(), $ext);
|
||||
$oldPath = $user->getAvatarPath();
|
||||
$oldPath = $user->avatarPath;
|
||||
|
||||
/** Remove old file and any cached thumbnails */
|
||||
if ($oldPath) {
|
||||
@@ -343,7 +343,7 @@ class ProfileController extends AbstractController
|
||||
}
|
||||
fclose($stream);
|
||||
|
||||
$user->setAvatarPath($newPath);
|
||||
$user->avatarPath = $newPath;
|
||||
$em->flush();
|
||||
|
||||
return $this->json([
|
||||
@@ -360,18 +360,18 @@ class ProfileController extends AbstractController
|
||||
|
||||
$credentials = $this->webAuthnService->getCredentialsForUser($user);
|
||||
$credentialsData = array_map(fn($cred) => [
|
||||
'id' => $cred->getId(),
|
||||
'credentialName' => $cred->getCredentialName(),
|
||||
'createdAt' => $cred->getCreatedAt()?->format('Y-m-d H:i:s'),
|
||||
'lastUsedAt' => $cred->getLastUsedAt()?->format('Y-m-d H:i:s'),
|
||||
'isBackupEligible' => $cred->isBackupEligible(),
|
||||
'isBackupAuthenticated' => $cred->isBackupAuthenticated(),
|
||||
'id' => $cred->id,
|
||||
'credentialName' => $cred->credentialName,
|
||||
'createdAt' => $cred->createdAt?->format('Y-m-d H:i:s'),
|
||||
'lastUsedAt' => $cred->lastUsedAt?->format('Y-m-d H:i:s'),
|
||||
'isBackupEligible' => $cred->isBackupEligible,
|
||||
'isBackupAuthenticated' => $cred->isBackupAuthenticated,
|
||||
], $credentials);
|
||||
|
||||
return $this->render('Security/profile_security.html.twig', [
|
||||
'credentials' => $credentialsData,
|
||||
'isTotpEnabled' => $user->isTotpAuthenticationEnabled(),
|
||||
'backupCodesCount' => count($user->getBackupCodes()),
|
||||
'backupCodesCount' => count($user->backupCodes),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,10 +86,9 @@ class SecurityController extends AbstractController
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$token = bin2hex(random_bytes(32));
|
||||
|
||||
$user
|
||||
->setIsVerified(false)
|
||||
->setVerificationToken($token)
|
||||
->setPassword($hasher->hashPassword($user, $form->get('plainPassword')->getData()));
|
||||
$user->isVerified = false;
|
||||
$user->verificationToken = $token;
|
||||
$user->password = $hasher->hashPassword($user, $form->get('plainPassword')->getData());
|
||||
|
||||
$em->persist($user);
|
||||
$em->flush();
|
||||
@@ -108,7 +107,7 @@ class SecurityController extends AbstractController
|
||||
$mailer->send(
|
||||
new TemplatedEmail()
|
||||
->from('noreply@mineseeker.hu')
|
||||
->to($user->getEmail())
|
||||
->to($user->email)
|
||||
->subject('Activate your MineSeeker account')
|
||||
->htmlTemplate('emails/activation.html.twig')
|
||||
->context([
|
||||
@@ -130,7 +129,7 @@ class SecurityController extends AbstractController
|
||||
])
|
||||
);
|
||||
|
||||
$this->addFlash('verify_email', $user->getEmail());
|
||||
$this->addFlash('verify_email', $user->email);
|
||||
|
||||
return $this->redirectToRoute('MineSeekerBundle_register');
|
||||
}
|
||||
@@ -156,11 +155,10 @@ class SecurityController extends AbstractController
|
||||
$email = $form->get('email')->getData();
|
||||
$user = $userRepository->findOneByEmail($email);
|
||||
|
||||
if ($user && $user->isVerified()) {
|
||||
if ($user && $user->isVerified) {
|
||||
$token = bin2hex(random_bytes(32));
|
||||
$user
|
||||
->setResetToken($token)
|
||||
->setResetTokenExpiresAt(new DateTime('+1 hour'));
|
||||
$user->resetToken = $token;
|
||||
$user->resetTokenExpiresAt = new DateTime('+1 hour');
|
||||
$em->flush();
|
||||
|
||||
$resetUrl = $this->generateUrl(
|
||||
@@ -206,7 +204,7 @@ class SecurityController extends AbstractController
|
||||
): Response {
|
||||
$user = $userRepository->findOneByResetToken($token);
|
||||
|
||||
if (!$user || $user->getResetTokenExpiresAt() < new DateTime()) {
|
||||
if (!$user || $user->resetTokenExpiresAt < new DateTime()) {
|
||||
$this->addFlash('error', 'This password reset link is invalid or has expired.');
|
||||
return $this->redirectToRoute('MineSeekerBundle_forgot_password');
|
||||
}
|
||||
@@ -215,10 +213,9 @@ class SecurityController extends AbstractController
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$user
|
||||
->setPassword($hasher->hashPassword($user, $form->get('plainPassword')->getData()))
|
||||
->setResetToken(null)
|
||||
->setResetTokenExpiresAt(null);
|
||||
$user->password = $hasher->hashPassword($user, $form->get('plainPassword')->getData());
|
||||
$user->resetToken = null;
|
||||
$user->resetTokenExpiresAt = null;
|
||||
$em->flush();
|
||||
|
||||
$this->addFlash('success', 'Your password has been reset. You can now sign in.');
|
||||
@@ -239,7 +236,8 @@ class SecurityController extends AbstractController
|
||||
return $this->redirectToRoute('MineSeekerBundle_login');
|
||||
}
|
||||
|
||||
$user->setIsVerified(true)->setVerificationToken(null);
|
||||
$user->isVerified = true;
|
||||
$user->verificationToken = null;
|
||||
$em->flush();
|
||||
|
||||
/** Send admin notification about account activation */
|
||||
|
||||
@@ -156,16 +156,16 @@ class TwoFactorController extends AbstractController
|
||||
$code = $request->request->getString('_auth_code');
|
||||
|
||||
// Temporarily set the pending secret to verify the code
|
||||
$user->setTotpSecret($pendingSecret);
|
||||
$user->totpSecret = $pendingSecret;
|
||||
|
||||
if (!$this->totpAuthenticator->checkCode($user, $code)) {
|
||||
$user->setTotpSecret(null);
|
||||
$user->totpSecret = null;
|
||||
$this->addFlash('error', 'Invalid verification code. Please try again.');
|
||||
return $this->redirectToRoute('MineSeekerBundle_2fa_setup');
|
||||
}
|
||||
|
||||
$backupCodes = $this->generateBackupCodes();
|
||||
$user->setBackupCodes($backupCodes);
|
||||
$user->backupCodes = $backupCodes;
|
||||
$this->em->flush();
|
||||
|
||||
$request->getSession()->remove('totp_pending_secret');
|
||||
@@ -187,8 +187,8 @@ class TwoFactorController extends AbstractController
|
||||
|
||||
/** @var User $user */
|
||||
$user = $this->getUser();
|
||||
$user->setTotpSecret(null);
|
||||
$user->setBackupCodes([]);
|
||||
$user->totpSecret = null;
|
||||
$user->backupCodes = [];
|
||||
$this->em->flush();
|
||||
|
||||
$this->addFlash('success', 'Two-factor authentication has been disabled.');
|
||||
@@ -217,7 +217,7 @@ class TwoFactorController extends AbstractController
|
||||
}
|
||||
|
||||
$backupCodes = $this->generateBackupCodes();
|
||||
$user->setBackupCodes($backupCodes);
|
||||
$user->backupCodes = $backupCodes;
|
||||
$this->em->flush();
|
||||
|
||||
$this->addFlash('2fa_backup_codes', $backupCodes);
|
||||
|
||||
@@ -64,7 +64,7 @@ class WebAuthnController extends AbstractController
|
||||
|
||||
$userEntity = new PublicKeyCredentialUserEntity(
|
||||
$user->getUserIdentifier(),
|
||||
(string)$user->getId(),
|
||||
(string)$user->id,
|
||||
$user->getUsername(),
|
||||
);
|
||||
|
||||
@@ -141,7 +141,7 @@ class WebAuthnController extends AbstractController
|
||||
}
|
||||
|
||||
/** Store the credential with user ID for later retrieval during authentication */
|
||||
$credentialJson['userId'] = $user->getId();
|
||||
$credentialJson['userId'] = $user->id;
|
||||
$credentialJson['username'] = $user->getUsername();
|
||||
|
||||
/** Save the credential data directly */
|
||||
@@ -173,12 +173,12 @@ class WebAuthnController extends AbstractController
|
||||
$credentials = $this->webAuthnService->getCredentialsForUser($user);
|
||||
|
||||
return new JsonResponse(array_map(fn($credential) => [
|
||||
'id' => $credential->getId(),
|
||||
'name' => $credential->getCredentialName(),
|
||||
'createdAt' => $credential->getCreatedAt()?->format('Y-m-d H:i:s'),
|
||||
'lastUsedAt' => $credential->getLastUsedAt()?->format('Y-m-d H:i:s'),
|
||||
'isBackupEligible' => $credential->isBackupEligible(),
|
||||
'isBackupAuthenticated' => $credential->isBackupAuthenticated(),
|
||||
'id' => $credential->id,
|
||||
'name' => $credential->credentialName,
|
||||
'createdAt' => $credential->createdAt?->format('Y-m-d H:i:s'),
|
||||
'lastUsedAt' => $credential->lastUsedAt?->format('Y-m-d H:i:s'),
|
||||
'isBackupEligible' => $credential->isBackupEligible,
|
||||
'isBackupAuthenticated' => $credential->isBackupAuthenticated,
|
||||
], $credentials));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user