mohamad-zatar/saudi-nafath-integration 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

mohamad-zatar/saudi-nafath-integration

Composer 安装命令:

composer require mohamad-zatar/saudi-nafath-integration

包简介

A Laravel package for integrating with the Saudi Nafath service, providing seamless identity verification and authentication solutions.

README 文档

README

This Laravel package provides an integration with the Saudi Nafath authentication system. It allows you to easily manage user authentication via Nafath and handle verification callbacks.

Features

  • Send authentication requests to Nafath.
  • Handle verification callbacks and update user statuses.
  • Dispatch events for custom handling of verification success and rejection.

Installation

1. Install the Package

You can install the package via Composer. Run the following command in your Laravel project:

composer require mohamad-zatar/nafath

2. Publish the Configuration

Publish the package configuration file to customize it according to your needs:

php artisan vendor:publish --provider="MohamadZatar\Nafath\NafathServiceProvider"

This will create a nafath.php configuration file in your config directory.

Configuration

1. Add Configuration

In the config/nafath.php file, set your Nafath API URL base and API key:

return [
    'NAFATH_URL_BASE' => env('NAFATH_URL_BASE', 'your-subdomain'),
    'NAFATH_API_KEY' => env('NAFATH_API_KEY', 'your-api-key'),
];

Add these values to your .env file:

NAFATH_URL_BASE=your-subdomain
NAFATH_API_KEY=your-api-key

2. Migration

Publish the migration for the nafath_logins table:

php artisan migrate

Usage

1. Sending Login Requests

To send a login request to Nafath, use the NafathController provided by the package. You can use this controller to handle authentication requests.

2. Handling Callbacks

Handle the callback from Nafath by defining the callback URL in your Nafath dashboard and configuring it to point to your application endpoint. The endpoint should be handled by the nafathPostCallback method in NafathController.

3. Event Handling

The package dispatches two events that you can listen to in your application:

  • MohamadZatar\Nafath\Events\VerificationVerified
  • MohamadZatar\Nafath\Events\VerificationRejected

Define Listeners

Create listeners for these events in your Laravel application:

// app/Listeners/HandleVerificationVerified.php
namespace App\Listeners;

use MohamadZatar\Nafath\Events\VerificationVerified;

class HandleVerificationVerified
{
    public function handle(VerificationVerified $event)
    {
        // Custom logic for verification success
    }
}

// app/Listeners/HandleVerificationRejected.php
namespace App\Listeners;

use MohamadZatar\Nafath\Events\VerificationRejected;

class HandleVerificationRejected
{
    public function handle(VerificationRejected $event)
    {
        // Custom logic for verification rejection
    }
}

Register Event Listeners

Add your listeners to the EventServiceProvider:

// app/Providers/EventServiceProvider.php
protected $listen = [
    VerificationVerified::class => [
        HandleVerificationVerified::class,
    ],
    VerificationRejected::class => [
        HandleVerificationRejected::class,
    ],
];

Contributing

Contributions are welcome! Please submit a pull request or create an issue for any bugs or feature requests.

License

MIT

Contact

For any questions or support, please contact Mohamad Zatar at lokasees@gmail.com.

统计信息

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

GitHub 信息

  • Stars: 23
  • Watchers: 1
  • Forks: 9
  • 开发语言: PHP

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固