BlackBits.io

How to Disable User Registration in Laravel

How to Disable User Registration in Laravel

The Problem

During one of our projects, we developed a backend for a customer. As you can imagine, we had a situation where users should not be able to register themselves to the backend. Ok, what can we do?

The first thing that came to mind was, to go through all the standard template files and remove everything where registration was involved.

Sounds ok, right? But, what if at some point the users need to be able to register? You would have to undo all the work you did earlier, which is inefficient and labor intensive!

No worries, we found a pretty neat solution we want to show you!

The Solution

Auth::routes(['register' => false]);

If you have used Laravel's awesome php artisan make:auth command before, then you probably know that you have to place the Auth::routes() call in the web.php file in order to register all the routes.

What we are doing here is, telling Laravel that we don't want the registration part of the Auth routes.

After passing this little array as a parameter to the routes call, the Register link in the top bar should disappear, and even when you access /register manually, you should get a 404.

This is a pretty cool solution to a common problem and if our customer now wants registration in his backend again, it is just a simple one-liner we have to remove.

Have fun and try it out yourself!

Expert Level Laravel Web Development & Consulting Agency

We love Laravel, and so should you. Let us show you why.

About Us

Founded in 2014, Black Bits helps customers to reach their goals and to expand their market positions. We work with a wide range of companies, from startups that have a vision and first funding to get to market faster, to big industry leaders that want to profit from modern technologies. If you want to start on your project without building an internal dev-team first, or if you need extra expertise or resources, Black Bits – the Laravel Web Development Agency is here to help.

Laravel

Laravel

Vue.js

Vue.js

React

React

Next.js

Next.js

TailwindCSS

TailwindCSS

AWS

AWS

Laravel Cloud

Laravel Cloud

Vercel

Vercel

DigitalOcean

DigitalOcean

Cloudflare

Cloudflare

Terraform

Terraform

Kubernetes

Kubernetes

Wiz

Wiz

OpenAI

OpenAI

Stripe

Stripe

Let's Talk

You have the vision, we have the development expertise. We would love to hear about your project.

Platform down right now?

Call us directly at (+1) 541 237-0201. We're here to help!

Or send us a message. We'll get back to you within 24 hours.

Grants Pass, Oregon, U.S.A.

(+1) 541 237-0201

hello@blackbits.io