定制 sindika-id/nedo-auth 二次开发

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

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

sindika-id/nedo-auth

Composer 安装命令:

composer require sindika-id/nedo-auth

包简介

Nedo Authentication Bridge

README 文档

README

Nedo Authentication is a laravel library written in pure PHP and providing a set of classes that allow you to use Nedo Platform user authentication and authorization.

Documentation

Steps:
  1. From the projects root folder, in the terminal, run composer to get the needed package.

    • Example:
       composer require sindika-id/nedo-auth
    
  2. From the projects root folder run composer update

  3. Change config/auth.php use nedo user driver :

    ...
    
    'providers' => [
        'users' => [
            'driver' => 'nedo'
        ],
    ],
    
    ...
  4. This plugin will automatically make some controller and view related to authentication mechanism.

    • auth/login
    • auth/logout
    • auth/register
    • auth/forgotpass
  5. To get user information across all controller you can hook middleware :

      namespace App\Http\Controllers;
    
      use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
      use Illuminate\Foundation\Bus\DispatchesJobs;
      use Illuminate\Foundation\Validation\ValidatesRequests;
      use Illuminate\Routing\Controller as BaseController;
    
      use Illuminate\Support\Facades\Auth;
      use Nedoquery\Api\NedoRequest;
    
      class Controller extends BaseController
      {
          use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
    
          /**
           * Authenticate User
           * 
           * @var \Illuminate\Auth\GenericUser 
           */
          protected $user;
    
          /**
           *
           * Request class to send data to Nedo server
           * 
           * @var \Nedoquery\Api\NedoRequest 
           */
          protected $nedoRequest;
    
          public function __construct(NedoRequest $nedoRequest)
          {
              $this->nedoRequest = $nedoRequest;
    
              $this->middleware(function ($request, $next) {
    
                  $this->user = Auth::user();
                  
                  $this->nedoRequest->setUser($this->user);
    
                  view()->share('user', $this->user);
                  return $next($request);
              });
          }
      }
  6. Example usage of nedo-query with nedo-auth module :

    • Example:
       
      $result = $this->nedoRequest->select('user_username, user_name, user_email')
              ->from('usermanagement')
              ->filter('user_id', 'gt', '1')
              ->order('user_name', 'ASC')
              ->get();
  7. You can protect your page using laravel routers.

    • Example:
      Route::group(['namespace' => 'Test', 'middleware' => ['notloggedin']], function () {
          Route::get('/', 'HomeController@index');
      });
    
      Route::group(['namespace' => 'Test', 'middleware' => ['loggedin']], function () {
          Route::get('/admin/', 'AdminController@index');
      });
      
  8. To publish view you can use vendor:publish command in terminal

      php artisan vendor:publish --provider=Nedoquery\Auth\NedoAuthServiceProvider
    

License

Nedo Authentication is licensed under the MIT license. Enjoy!

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-02-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固