Example blog

Login links for your Laravel application during development

Laravel Login Link is a Blade component for quickly logging into your local environment.

After installing the login link package, logging in locally as an administrator or normal user is as easy as adding the following blade snippet:

1@env('local')

2 <div class="space-y-2">

3 <x-login-link email="[email protected]" label="Login as admin"/>

4 <x-login-link email="[email protected]" label="Login as regular user"/>

5 div>

6@endenv

Clicking on a login link will automatically log you in without having to remember or enter any credentials. Your non-local environments will not display these links, but your local login page might look like this:

According to Freek Van der Herten of Spatie, this package was envisioned and created by Spatie to manage predefined user credentials for various roles and a package designed to be shared with the open source community:

When developing an app with an admin section (or any other non-public section), you’ll likely have test users to login. In large teams that work on many different applications, it can be cumbersome to keep track of the correct credentials. Is the user account “[email protected]”, or “[email protected]”, or even “[email protected]”? Is this password “password”, “secret” or something else? How can I log in with a user who has a different role?

This package solves this problem by providing a component to render a login link. When you click on it, you will be connected.

Freek has written a detailed introductory article on this package if you want to know more about the background and use case of this package. You can also learn more about setting up this package and view the source code on GitHub.



Source link