Skip to content

Commit

Permalink
changed def admin email; fixed redirect after mail confirmation url
Browse files Browse the repository at this point in the history
  • Loading branch information
msalakhov-smartorange committed Mar 23, 2022
1 parent a1557ef commit bf3aeff
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ DATABASE_URL="mysql://lux_admin:&pHDG3%LcV@database:3306/lux?serverVersion=8.0"
# DATABASE_URL="postgresql://db_user:[email protected]:5432/db_name?serverVersion=13&charset=utf8"
###< doctrine/doctrine-bundle ###

MAIL_TO_ADDRESS=[email protected]
ADMIN_EMAIL=[email protected]

###> symfony/lock ###
# Choose one of the stores below
Expand Down
4 changes: 3 additions & 1 deletion app/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
parameters:
photoDir: "%kernel.project_dir%/public/uploads/photos"
sendTo: '%env(MAIL_TO_ADDRESS)%'
default_admin_email: '[email protected]'

services:
# default configuration for services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
bind:
$adminEmail: "%env(string:default:default_admin_email:ADMIN_EMAIL)%"

# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
Expand Down
6 changes: 3 additions & 3 deletions app/src/Controller/RegistrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(EmailVerifier $emailVerifier)
}

#[Route('/register', name: 'app_register')]
public function register(Request $request, UserPasswordHasherInterface $passwordHasher): Response
public function register(Request $request, UserPasswordHasherInterface $passwordHasher, string $adminEmail): Response
{
$user = new User();
$form = $this->createForm(RegistrationFormType::class, $user);
Expand All @@ -46,7 +46,7 @@ public function register(Request $request, UserPasswordHasherInterface $password
// generate a signed url and email it to the user
$this->emailVerifier->sendEmailConfirmation('app_verify_email', $user,
(new TemplatedEmail())
->from(new Address('[email protected]', 'Insurance Mail Bot'))
->from(new Address($adminEmail, 'Insurance Mail Bot'))
->to($user->getEmail())
->subject('Please Confirm your Email')
->htmlTemplate('registration/confirmation_email.html.twig')
Expand Down Expand Up @@ -78,6 +78,6 @@ public function verifyUserEmail(Request $request): Response
// @TODO Change the redirect on success and handle or remove the flash message in your templates
$this->addFlash('success', 'Your email address has been verified.');

return $this->redirectToRoute('app_register');
return $this->redirectToRoute('homepage');
}
}
5 changes: 3 additions & 2 deletions app/src/Controller/ResetPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public function checkEmail(): Response

return $this->render('reset_password/check_email.html.twig', [
'resetToken' => $resetToken,
'title' => 'Password Reset Email Sent'
]);
}

Expand Down Expand Up @@ -126,7 +127,7 @@ public function reset(Request $request, UserPasswordHasherInterface $passwordHas
]);
}

private function processSendingPasswordResetEmail(string $emailFormData, MailerInterface $mailer): RedirectResponse
private function processSendingPasswordResetEmail(string $emailFormData, MailerInterface $mailer, string $adminEmail): RedirectResponse
{
$user = $this->getDoctrine()->getRepository(User::class)->findOneBy([
'email' => $emailFormData,
Expand All @@ -153,7 +154,7 @@ private function processSendingPasswordResetEmail(string $emailFormData, MailerI
}

$email = (new TemplatedEmail())
->from(new Address('[email protected]', 'Insurance Mail Bot'))
->from(new Address($adminEmail, 'Insurance Mail Bot'))
->to($user->getEmail())
->subject('Your password reset request')
->htmlTemplate('reset_password/email.html.twig')
Expand Down
2 changes: 1 addition & 1 deletion app/templates/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</div>
</div>
{% endif %}
{% if app.request.attributes.get('_route') != "homepage" and app.request.attributes.get('_route') != "app_login" and app.request.attributes.get('_route') != "app_forgot_password_request" and app.request.attributes.get('_route') != "app_register" %}
{% if app.request.attributes.get('_route') != "homepage" and app.request.attributes.get('_route') != "app_login" and app.request.attributes.get('_route') != "app_forgot_password_request" and app.request.attributes.get('_route') != "app_register" and app.request.attributes.get('_route') != "app_check_email" %}
<ul class="nav nav-tabs mt-5">
{% block breadcrumb %}
<li class="nav-item">
Expand Down
4 changes: 2 additions & 2 deletions app/templates/reset_password/check_email.html.twig
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{% extends 'base.html.twig' %}

{% block title %}Password Reset Email Sent{% endblock %}
{% block title %}{{ title }}{% endblock %}

{% block body %}
<div class="d-flex h-100" style="background-image: linear-gradient(#6ab3ff, #191e62);">
<div class="container">
<ul class="nav nav-tabs mt-5">
<li class="nav-item">
<a class="nav-link" href="/login">Back</a>
<a class="nav-link" href="{{ path('app_login') }}">Back</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="#">Reset password</a>
Expand Down

0 comments on commit bf3aeff

Please sign in to comment.