承接 mahdialikhani/otp-authenticator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

mahdialikhani/otp-authenticator

最新稳定版本:0.0.2

Composer 安装命令:

composer require mahdialikhani/otp-authenticator

包简介

This package assists with authenticating users using OTP (One-Time Password) method.

README 文档

README

Social Card of Laravel Media Library

OTP Authenticator

GitHub release (latest SemVer) Packagist Downloads

The OTP Authenticator package provides a simple and efficient solution for ensuring the security of your users' accounts. With the OTP (One-Time Password) method, users can securely log in to their accounts without the fear of their credentials being compromised. The package is easy to install and integrates seamlessly with your Laravel application, making it a hassle-free experience for developers.


Installation

Requirements

  • PHP 8.0+
  • Laravel 8+

You can install the package via composer:

composer require mahdialikhani/otp-authenticator

and add the OTPAuthenticatorServiceProvider service provider to config/app.php

and then run:

php artisan vendor:publish --tag=otpauthenticator

php artisan otp:install

Our default support includes two text message service provider, Ghasedak and Kavenegar, with plans to expand our support to additional services. To use any of these services, simply follow the instructions provided.

Kavenegar:

To utilize the Kavenegar service, first follow the installation instructions for the Kavenegar package as outlined in the service provider's official documentation. Then, specify the SMS sender number in the config/otpauthenticator.php file.

'kavenegar' => [
    'line_number' => ''
]

and then:

You can edit the toSms function in the \App\Notifications\VerificationNotification class as follows:

return (new KavenegarMessage)
            ->to('09301111111')
            ->message('Hi dear, your verification code is:123456');

and done!

Ghasedak:

To utilize the ghasedak service, first follow the installation instructions for the ghasedak package provided in the official service provider's documentation. If you opt to use a pre-made text message template from the Ghasedak service, indicate the name of your selected template in the config/otpauthenticator.php file.

'ghasedak' => [
    'template_name' => ''
]

and then:

You can edit the toSms function in the \App\Notifications\VerificationNotification class as follows:

return (new GhasedakMessage)
            ->to('09301111111')
            ->message('123456');

and done!

You can use the Laravel documentation to use the vonage service or create a personalized service by following these steps:

  • Create a custom class in \App\Notifications\Messages that implements the Messageable interface.
  • Define the send method for sending your text message.
  • Use this class in the \App\Notifications\VerificationNotification file, similar to other services.

To conveniently access the recipient and message text, extend your message class from the "SimpleMessage" class.

for example:

<?php

namespace App\Notifications\Messages;

use Mahdialikhani\OtpAuthenticator\Contracts\Messageable;
use Mahdialikhani\OtpAuthenticator\Notifications\Messages\SimpleMessage;

class SmsirMessage extends SimpleMessage implements Messageable
{
    public function send()
    {
        // Code here
    }
}
<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;
use Mahdialikhani\OtpAuthenticator\Notifications\Channels\SmsChannel;

class VerificationNotification extends Notification
{
    use Queueable;

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [SmsChannel::class];
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toSms($notifiable)
    {
        return (new SmsirMessage)
            ->to('09301111111')
            ->message('123456');
    }
}

Also, if you don't want the verification code to be sent to the user via text message, you can apply the email settings in your .env file and make the following changes in the file \App\Notifications\VerificationNotification to send the validation code via email.

<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class VerificationNotification extends Notification
{
    use Queueable;

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['mail'];
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail($notifiable)
    {
        return (new MailMessage)
            ->line('The introduction to the notification.')
            ->action('Notification Action', url('/'))
            ->line('Thank you for using our application!');
    }
}

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固