Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kohinos-tav
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
agplv3
kohinos-tav
Commits
7f12cd1c
Commit
7f12cd1c
authored
Apr 07, 2025
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP prevent automaticaly enabeling user at password creation
parent
dc64330f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
12 deletions
+43
-12
routes.yaml
config/routes.yaml
+5
-0
RegistrationController.php
src/Controller/RegistrationController.php
+26
-0
GeolocListener.php
src/EventListener/GeolocListener.php
+12
-12
No files found.
config/routes.yaml
View file @
7f12cd1c
...
...
@@ -33,3 +33,7 @@ app.swagger_ui:
payum_all
:
resource
:
"
@PayumBundle/Resources/config/routing/all.xml"
fos_user_registration_confirm
:
path
:
/register/confirm/{token}
controller
:
App\Controller\RegistrationController::confirmAction
\ No newline at end of file
src/Controller/RegistrationController.php
View file @
7f12cd1c
...
...
@@ -9,6 +9,7 @@ use FOS\UserBundle\Event\GetResponseUserEvent;
use
FOS\UserBundle\FOSUserEvents
;
use
Symfony\Component\HttpFoundation\RedirectResponse
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\Routing\Annotation\Route
;
class
RegistrationController
extends
BaseController
{
...
...
@@ -63,4 +64,29 @@ class RegistrationController extends BaseController
'form'
=>
$form
->
createView
(),
]);
}
/**
* Override confirmAction from FOSUserBundle to prevent automatically enabeling a user
* if its account was created disabled by the admin
*
* @Route("/register/confirm/{token}", name="fos_user_registration_confirm")
*/
public
function
confirmAction
(
Request
$request
,
$token
)
{
$user
=
$this
->
get
(
'fos_user.user_manager'
)
->
findUserByConfirmationToken
(
$token
);
if
(
null
===
$user
)
{
throw
new
NotFoundHttpException
(
sprintf
(
'The user with confirmation token "%s" does not exist'
,
$token
));
}
$user
->
setConfirmationToken
(
null
);
$user
->
setLastLogin
(
new
\DateTime
());
// Don't automatically enable user if created disabled
// $user->setEnabled(true);
$this
->
get
(
'fos_user.user_manager'
)
->
updateUser
(
$user
);
return
new
RedirectResponse
(
$this
->
generateUrl
(
'fos_user_registration_confirmed'
));
}
}
src/EventListener/GeolocListener.php
View file @
7f12cd1c
...
...
@@ -31,18 +31,18 @@ class GeolocListener
return
;
}
if
(
empty
(
$entity
->
getLat
())
&&
empty
(
$entity
->
getLon
()))
{
// GEOCODING ADDRESS :
$httpClient
=
new
\Http\Adapter\Guzzle6\Client
();
$provider
=
Nominatim
::
withOpenStreetMapServer
(
$httpClient
,
'Mozilla/5.0'
);
$geocoder
=
new
\Geocoder\StatefulGeocoder
(
$provider
,
'fr'
);
$fullAddress
=
$entity
->
getAdresse
()
.
' '
.
$entity
->
getCpostal
()
.
' '
.
$entity
->
getVille
();
// Query geocoding from complete address
$result
=
$geocoder
->
geocodeQuery
(
GeocodeQuery
::
create
(
$fullAddress
));
if
(
count
(
$result
)
>
0
)
{
$coords
=
$result
->
first
()
->
getCoordinates
();
$entity
->
setLat
(
floatval
(
str_replace
(
','
,
'.'
,
$coords
->
getLatitude
())));
$entity
->
setLon
(
floatval
(
str_replace
(
','
,
'.'
,
$coords
->
getLongitude
())));
}
//
//
GEOCODING ADDRESS :
//
$httpClient = new \Http\Adapter\Guzzle6\Client();
//
$provider = Nominatim::withOpenStreetMapServer($httpClient, 'Mozilla/5.0');
//
$geocoder = new \Geocoder\StatefulGeocoder($provider, 'fr');
//
$fullAddress = $entity->getAdresse() . ' ' . $entity->getCpostal() . ' ' . $entity->getVille();
//
//
Query geocoding from complete address
//
$result = $geocoder->geocodeQuery(GeocodeQuery::create($fullAddress));
//
if (count($result) > 0) {
//
$coords = $result->first()->getCoordinates();
//
$entity->setLat(floatval(str_replace(',', '.', $coords->getLatitude())));
//
$entity->setLon(floatval(str_replace(',', '.', $coords->getLongitude())));
//
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment