Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
privrja committed Apr 27, 2021
1 parent d911780 commit d7477b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/Controller/SecurityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use App\Structure\ResetStructure;
use App\Structure\ResetTransformed;
use DateTime;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Doctrine\ORM\EntityManagerInterface;
use Exception;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -317,8 +318,12 @@ public function changeMail(Request $request, EntityManagerInterface $entityManag
/** @var User $user */
$user = $security->getUser();
$user->setMail($trans->mail);
$entityManager->persist($user);
$entityManager->flush();
try {
$entityManager->persist($user);
$entityManager->flush();
} catch (UniqueConstraintViolationException $ex) {
return ResponseHelper::jsonResponse(new Message('Mail is taken'));
}
return ResponseHelper::jsonResponse(Message::createNoContent());
}

Expand Down Expand Up @@ -573,7 +578,7 @@ public function generatePassword(Request $request, EntityManagerInterface $entit
return ResponseHelper::jsonResponse(new Message(ErrorConstants::ERROR_SOMETHING_GO_WRONG, Response::HTTP_INTERNAL_SERVER_ERROR));
}
try {
mail($user->getMail(), 'MassSpecBlocks - password reset', 'You request a new password for Mass Spec Blocks. New generated password: ' . $pass . '. After first login with new password we recommended you to change it. Thanks');
mail($user->getMail(), 'MassSpecBlocks - password reset', 'You requested a new password for MassSpecBlocks. The new password is: ' . $pass . '. After the first login with the new password, we recommend you change it. Thanks');
} catch (Exception $exception) {
return ResponseHelper::jsonResponse(new Message('Server doesn\'t support sending mails'));
}
Expand Down
2 changes: 1 addition & 1 deletion src/CycloBranch/BlockMergeFormulaCycloBranch.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function download(): string {
if (!empty($arResult)) {
foreach ($arResult as $block) {
$this->data .= str_replace(',', '.', $block['block_name']) . self::TABULATOR
. $block['acronym'] . self::TABULATOR
. str_replace(',', '.', $block['acronym']) . self::TABULATOR
. $block['residue'] . self::TABULATOR
. $block['block_mass'] . self::TABULATOR
. $block['losses'] . self::TABULATOR
Expand Down

0 comments on commit d7477b6

Please sign in to comment.