Users - Auto-login after registered?
Created 2 years ago by emergingdzns

I have two clients that both want to have it so that when the user registers, they are automatically and immediately logged in. Is this possible at all with the system already or am I going to have to hijack the registration process and custom build it myself?

huglester  —  2 years ago


edit app/streams.php > singletons with: '\Anomaly\UsersModule\User\Register\RegisterFormBuilder' => '\App\Extensions\User\RegisterFormBuilder', content like so:


namespace App\Extensions\User;

use Anomaly\UsersModule\User\Register\RegisterFormBuilder as BaseRegisterFormBuilder;

class RegisterFormBuilder extends BaseRegisterFormBuilder

    protected $handler = RegisterFormHandler::class;


And the RegisterFormHandler.php:


namespace App\Extensions\User;

use Anomaly\CustomersModule\Customer\CustomerModel;
use Anomaly\Streams\Platform\Traits\Transmitter;
use Anomaly\UsersModule\User\Contract\UserInterface;
use Anomaly\UsersModule\User\Notification\UserHasRegistered;
use Anomaly\UsersModule\User\Register\Command\HandleEmailRegistration;
use Anomaly\UsersModule\User\Register\Command\HandleManualRegistration;
use Anomaly\UsersModule\User\UserActivator;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Foundation\Bus\DispatchesJobs;

class RegisterFormHandler

    use Transmitter;
    use DispatchesJobs;

    public function handle(Repository $config, RegisterFormBuilder $builder, UserActivator $activator)
        if (! $builder->canSave()) {


// maybe you will need to copy of some login from Default Handler... but you should get the idea 😄

ryanthompson  —  2 years ago

This was actually pushed and done this last weekend. Already like that now 😊

emergingdzns  —  1 year ago

Thanks @ryanthompson. I just ran composer update and tested this but it still didn't log the user in after registering. I've got the Activation Mode set to "Automatically activate the user after they register."

Is there something I'm doing wrong?

ryanthompson  —  1 year ago

No let me double check that mode. Write up a quick issue cause Ima be AFK for a while.

emergingdzns  —  1 year ago

Done. Thanks bro.

emergingdzns  —  1 year ago

I can see that it was added to the event handler for the user activation, which is done when the user gets an email to activate.

But when the activation is automatic, it's not there: Unless I'm missing something, we need to add the UserAuthenticator to the function and then add the login line correct?

emergingdzns  —  1 year ago

Thank you sir!