定制 aldo/laravel-passwordless-login 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aldo/laravel-passwordless-login

最新稳定版本:v1.0.0

Composer 安装命令:

composer require aldo/laravel-passwordless-login

包简介

Log into your application using just a link

README 文档

README

A login link generator for Laravel

This package provides a temporary signed route that can be used to login a user. You can implement the login yourself or you can use the implementation provided by this package. It includes a must verify email registration and a passwordless login implementation.

Installation

  composer require aldo/laravel-passwordless-login

Publish the config file

  php artisan vendor:publish --tag=passwordless-config

Usage

In the published config file you should set the correct user model namespace and the name of the route that is going to be used to verify the generated login link. Your can also set the expiration time you want for the link.

<?php

return [
    /*
    |
    | The namespace of your applications user model
    |
    */
    "model" => [
        "namespace" => "\App\Models\User",
    ],

    /*
    |
    | The route name and the url expiration in minutes
    |
    */
    "url" => [
        "route" => "login.verify",
        "expire" => 5,
    ],

    /*
    |--------------------------------------------------------------------------------
    | Only applicable if you are using the provided authentication implementation
    |--------------------------------------------------------------------------------
    |
    | Change flag to true if you want to use the provided implementation routes. 
    | This flag is necessary for not loading the routes if you don't want to use the default implementation.
    | This way you can avoid route collision.
    | 
    | The name of the home route to redirect to after login
    |
    */
    "routes" => [
        "flag" => false,
        
        "home" => "home",
    ],
];

To generate the login link use the provided facade

use App\Models\User;
use Aldo\LaravelPasswordlessLogin\Facades\PasswordlessLogin;

function sendLoginLink()
{
    $user = User::first();
    
    $url = PasswordlessLogin::forUser($user)->generate();
    
    // You can also add remember me (by default it's false)
    $url = PasswordlessLogin::forUser($user)->remember()->generate();    
    
    // Send the url to the user
}

If you want to use the provided authentication implementation follow the steps below.

  • Publish the migration files
  php artisan vendor:publish --tag=passwordless-migrations
  • Run the migrations
  php artisan migrate

The packages migration modifies the users table making the password column nullable.

  • In the config file change the flag to true and set the correct route name for your home page
/*
|--------------------------------------------------------------------------------
| Only applicable if you are using the provided authentication implementation
|--------------------------------------------------------------------------------
|
| Change flag to true if you want to use the provided implementation routes. 
| This flag is necessary for not loading the routes if you don't want to use the default implementation.
| This way you can avoid route collision.
| 
| The name of the home route to redirect to after login
|
*/
"routes" => [
    "flag" => false, // change to true
    
    "home" => "home",
],
  • In your user model implement Illuminate\Contracts\Auth\MustVerifyEmail. The package uses it in the user registration.

If you want to publish the views and the localization files run:

  php artisan vendor:publish --tag=passwordless-views

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-05-06