定制 esplora/auto-login 二次开发

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

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

esplora/auto-login

最新稳定版本:1.0.0

Composer 安装命令:

composer require esplora/auto-login

包简介

Enables seamless autologin functionality via temporary links, providing convenient and secure access to your application.

README 文档

README

The AutoLogin package for Laravel enables seamless autologin functionality via temporary links. Empower your users with convenient access to your application by securely logging them in using time-limited, temporary autologin links.

Installation

You can install AutoLogin in your project using the Composer package manager:

composer require esplora/auto-login

Usage

To get started with the AutoLogin package, follow the steps below:

  1. Add the route for autologin in your routes/web.php file:
use Esplora\AutoLogin\AutoLogin;

AutoLogin::routes();

This will register the necessary route for autologin functionality.

  1. Create temporary autologin links in your controllers, emails, or other relevant places using the following methods:
AutoLogin::to('/path');
// or use named routes
AutoLogin::route('telescope', [
    'active' => '1'
]);

These methods will generate temporary links that automatically log in the user. By default, the current authenticated user will be used. However, if the code is executed in the console or in a non-authenticated context, you need to pass the user ID as the second argument:

AutoLogin::to('/path', 123);
// or use named routes
AutoLogin::route('telescope', [
    'active' => '1'
], 123);

Configuration

The AutoLogin package provides some configuration options to suit your needs. By default, the autologin URL is set to /autologin. However, if you have changed this route usage, you can specify the desired URL using the following method:

use Esplora\AutoLogin\AutoLogin;

AutoLogin::routes('/your/path/autologin');

Additionally, you can specify a Blade template to customize the autologin view. Simply pass the desired template path as the second argument:

use Esplora\AutoLogin\AutoLogin;

AutoLogin::routes('/your/path/autologin', 'path.for.your.blade.template');

In your custom template, you can access the link variable, which contains the autologin URL, and use it as needed.

<!-- path.for.your.blade.template -->

<!doctype html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Redirecting...</title>

    <script type="text/javascript">
      setTimeout(function () {
        window.location.href = "{{ $link }}";
      }, 3000);
    </script>
  </head>
  <body>
    <h1>You are being redirected</h1>

    <p>You will be redirected to an external page in a few seconds.</p>

    <p>
      If you are not redirected automatically, please click
      <a href="{{ $link }}">here</a>.
    </p>
  </body>
</html>

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-22