Laravel OTP 身份验证包

v1.0.1 2023-07-22 01:28 UTC

This package is auto-updated.

Last update: 2024-09-22 04:12:48 UTC


README

Latest Version on Packagist Total Downloads GitHub Actions

使用本包,您可以在 Laravel 中轻松处理 OTP 登录/注册。

安装

您可以通过 composer 安装此包

composer require aliwebto/otp
php artisan vendor:publish --provider="Aliwebto\Otp\OtpServiceProvider"
php artisan migrate

用法

use Aliwebto\Otp\Otp;

// generate and send code
Otp::generate("09xxxxxxxxx");


// check entered code
Otp::check("code","09xxxxxxxxx");


// regenerate and send new code
Otp::regenerate("09xxxxxxxxx");


// get regenerate code cooldown in seconds
$code = Otp::lastCode("09xxxxxxxxx");
$seconds = Otp::regenerateCooldown($code);


// check code and login/register

$createUserIfNotExist = true;
$newUserEmail = random_int(100000,9999999)."@aliwento.com";
$newUserName = "User";

$isLoggedIn = Otp::authenticate("CODE","09xxxxxxxxx",$createUserIfNotExist,$newUserEmail,$newUserName);

测试

composer test

变更日志

请参阅 变更日志 了解最近更改的信息。

贡献

请参阅 贡献指南 了解详情。

安全

如果您发现任何与安全相关的问题,请通过电子邮件 aliwebto@gmail.com 而不是使用问题跟踪器。

致谢

许可证

MIT 许可证 (MIT)。请参阅 许可证文件 了解更多信息。