[CONTROLLER][Security] Override the `_next` form field in Security->register to redirect to login page
This commit is contained in:
parent
390c532456
commit
18864ca9fa
|
@ -11,6 +11,7 @@ use App\Core\Event;
|
|||
use App\Core\Form;
|
||||
use function App\Core\I18n\_m;
|
||||
use App\Core\Log;
|
||||
use App\Core\Router\Router;
|
||||
use App\Entity\Actor;
|
||||
use App\Entity\Feed;
|
||||
use App\Entity\LocalUser;
|
||||
|
@ -33,6 +34,7 @@ use Component\Subscription\Entity\ActorSubscription;
|
|||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
||||
use LogicException;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
@ -96,7 +98,8 @@ class Security extends Controller
|
|||
// \App\Core\Security $authenticator,
|
||||
// UserAuthenticatorInterface $user_authenticator,
|
||||
): array|Response {
|
||||
$form = Form::create([
|
||||
$form = Form::create(
|
||||
[
|
||||
['nickname', TextType::class, [
|
||||
'label' => _m('Nickname'),
|
||||
'help' => _m('Your desired nickname (e.g., j0hnD03)'),
|
||||
|
@ -121,8 +124,11 @@ class Security extends Controller
|
|||
'attr' => ['autocomplete' => 'email'],
|
||||
]],
|
||||
FormFields::repeated_password(['attr' => ['autocomplete' => 'new-password']]),
|
||||
['register', SubmitType::class, ['label' => _m('Register')]],
|
||||
], form_options: ['block_prefix' => 'register']);
|
||||
['register', SubmitType::class, ['label' => _m('Register')]]
|
||||
],
|
||||
extra_data: ['_next' => Router::url('security_login')],
|
||||
form_options: ['block_prefix' => 'register']
|
||||
);
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
|
@ -205,6 +211,7 @@ class Security extends Controller
|
|||
$user->setIsEmailVerified(true);
|
||||
}
|
||||
|
||||
return Form::forceRedirect($form, $request);
|
||||
// return $user_authenticator->authenticateUser($user, $authenticator, $request);
|
||||
}
|
||||
|
||||
|
|
|
@ -102,6 +102,7 @@ abstract class Form
|
|||
): SymfFormInterface {
|
||||
$name = $form[array_key_last($form)][0];
|
||||
$r = Common::getRequest();
|
||||
|
||||
$form[] = ['_next', HiddenType::class, ['data' => $r->get('next') ?? $r->get('_next') ?? $r->getRequestUri()]];
|
||||
|
||||
$fb = self::$form_factory->createNamedBuilder($name, $type, data: null, options: array_merge($form_options, ['translation_domain' => false]));
|
||||
|
|
Loading…
Reference in New Issue