定制 longman/laravel-dummyuser 二次开发

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

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

longman/laravel-dummyuser

Composer 安装命令:

composer require longman/laravel-dummyuser

包简介

Package to implement dummy user authorization (without database) for Laravel 5.x

README 文档

README

Build Status Code Quality Latest Stable Version Total Downloads Downloads Month License

Dummy (without database) user authorization for Laravel 5.x

Table of Contents

Installation

Install this package through Composer.

Edit your project's composer.json file to require longman/laravel-dummyuser

Create composer.json file:

{
    "name": "yourproject/yourproject",
    "type": "project",
    "require": {
        "longman/laravel-dummyuser": "~1.0"
    }
}

And run composer update

Or run a command in your command line:

composer require longman/laravel-dummyuser

After updating composer, add the DummyUserServiceProvider to the providers array in config/app.php

Longman\LaravelDummyUser\DummyUserServiceProvider::class,

In the config/auth.php file you should add dummy guard in the guards array:

'guards' => [
    . . .

    'dummy' => [
        'driver' => 'session',
        'provider' => 'dummy',
    ],
]

and provider in the providers array

'providers' => [
    . . .

    'dummy' => [
        'driver' => 'dummy',
        'lifetime' => 3600, // Cache lifetime in minutes
    ],
]

Usage

You can specify default guard dummy in the config/auth.php file (defaults array) and use just Auth:: calls, or use Auth::guard('dummy'), like Auth::guard('dummy')->login($user)

For authenticating users, you need some unique identifier. You can use remote id or something like md5('some-unique-mail@mail.com')

In User model you need to add id in fillable array. And if you use string id also add protected $keyType = 'string'; field.

Usage example:

<?php
// get some user data from Restful service
$user_data = get_user_data_from_service();
$email = $user_data['email'];

$user = new User(['id' => md5($email), 'name' => $user_data['name'], ...]);

// Log in user
Auth::login($user);

TODO

write tests

Troubleshooting

If you like living on the edge, please report any bugs you find on the laravel-dummyuser issues page.

Contributing

Pull requests are welcome. See CONTRIBUTING.md for information.

License

Please see the LICENSE included in this repository for a full copy of the MIT license, which this project is licensed under.

Credits

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-08-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固