定制 bizhub/impersonate 二次开发

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

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

bizhub/impersonate

最新稳定版本:0.2

Composer 安装命令:

composer require bizhub/impersonate

包简介

Impersonate a Laravel user

README 文档

README

Authenticate as another user while maintaining previous authentication.

This works by using Laravels Auth::onceUsingId() feature where you can authenticate as a user for that request only. A middleware will check if you're impersonating via a session variable and activate Auth::onceUsingId() for every request until you stop impersonating.

Installation

1. Composer

Execute the following command to get the latest version of the package:

composer require bizhub/impersonate

2. Laravel

Add CheckIfImpersonating middleware to app\Http\Kernel.php

  protected $middlewareGroups = [
      'web' => [
          // ...
          
          \Bizhub\Impersonate\Middleware\CheckIfImpersonating::class,
      ]
  ];

Add CanImpersonate trait to your User model

namespace App;

use Bizhub\Impersonate\Traits\CanImpersonate;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use CanImpersonate;
    
    // ...
}

Usage

// Retrieve your user model
$user = User::find(1);

// Start impersonating
$user->impersonate();

// Redirect/reload the page

// ...

// Stop impersonating
Auth::user()->stopImpersonating();

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-10-20