syehan/forgotpassword-plugin
Composer 安装命令:
composer require syehan/forgotpassword-plugin
包简介
Allows users who have forgotten their password to unlock, retrieve, or reset it.
README 文档
README
Use syehan/forgotpassword-plugin. Allows users who have forgotten their password to unlock, retrieve, or reset it, usually by answering account security questions or sending them an e-mail. This plugin Currently verifying by OTP.
Installation
1 - You can install the package via composer:
$ composer require syehan/forgotpassword-plugin
Generating Secret Key Base32 for OTP
In this plugin, we have some command to generate base32 for your secret key, after that save into your config/syehan-otp-password.php in otp_secret_key key like this :
php artisan syehan:generate-otp-secret-key
// the output would be like this
Your Forgot Password OTP Secret Key is : Z566IV6FIMMANIKQQOIJDZNWREKJKAWKGTK3WGGBSFTOIOG4UFCN2QVDJNHUJKKT44JRDSPWTX6JNBYDGMIJHLKCD6UM4WJGFIVPU3VSLTXP6J45PG4V5Q2NMKY3H5FCXGXK4BAXHWX4PX3YDC6VYF5EB25GZJCS2LTKED5GA467HIEJHZW6XPVGXPQVMWITQVHILMDQHI7JE
Usage
1 - You can send the forgot password email using this API:
POST https://yourdomain.com/api/syehan/forgot-password
Add body Param email to deliver Forgot Password mail to your account.
2 - Or you can put this function into your function:
use Syehan\ForgotPassword\Classes\ForgotMailMaker; (new ForgotMailMaker)->setEmail($email)->hit(); // You also can change the mail template and mail data for your custom mail like this below. Also we will ensure that otp code and email user added into your mail data. (new ForgotMailMaker)->setMailTemplateCode('author.plugin::mail.forgot')->setMailData(['data' => 'test'])->setEmail($email)->hit(); // You also can change send mail mode in queue() rather than send(), just change the var like this : (new ForgotMailMaker)->setEmail($email)->hit('queue'); //<- only allow set `queue` or `send` mode
Usage (Verifying OTP)
1 - You can verify the OTP password into your function like this:
$is_otp_match = (new \Syehan\ForgotPassword\Classes\OtpMaker)->setIssuer($email)->verifyOtp($input_otp);
Usage (Change Password)
1 - by this plugin you can also change after verification by using this API:
POST https://yourdomain.com/api/syehan/change-password
Add body Param email, password and password_confirmation to make sure that change password for your account succeed. Additionally you can verify OTP simultaneously while change password by adding body otp request parameter.
or, you can put in any function like this :
use Syehan\ForgotPassword\Classes\ChangePasswordMaker; (new ChangePasswordMaker) ->setEmail($email) ->setPassword($password) ->setPasswordConfirmation($password_confirmation) ->change(); // You can verify OTP simultaneously when changing password like this (new ChangePasswordMaker) ->setEmail($email) ->setPassword($password) ->setPasswordConfirmation($password_confirmation) ->withVerifyOtp(true, $otp_input) ->change();
lastly, you can able to change your own user model by changing user_model in config/syehan-forgot-password.php
Config Forgot Password
If your have any setup for forgot password, please make sure to copy our config below and paste in config/syehan-forgot-password.php.
<?php return [ /** * The User Model, default is rainlab.user plugin. * this would be the model that allow us to change the password. * */ 'user_model' => env('SYEHAN_FORGOT_PASSWORD_USER_MODEL', \RainLab\User\Models\User::class), /** * The OTP secret key, identity of your app */ 'otp_secret_key' => env('SYEHAN_FORGOT_PASSWORD_OTP_SECRET_KEY', 'XFT35ETTPHPIBIAMIUEZ7SRE5K4YZLSQP3LU4DZFWW7NDUSRSGAR3JK2ETCXY4BYQIQQQRLX4GI2ZSUT4YQDWEEPMAMI75IHN6NBKBQYCCKPQZGBTJQJYBIBU4LGEBGMVRUW6XZFVSOUUVRL66NFIZ55CH7GIGWUJ5DMR2JRYCTMXUN2ZMVFCBWEJNOOJIMGLIAGZXIJOVGIY'), /** * The OTP issuer */ 'otp_issuer' => env('SYEHAN_FORGOT_PASSWORD_OTP_ISSUER', 'SyehanProductIssuer'), /** * Length of OTP digits, by default is 6. */ 'otp_digits' => env('SYEHAN_FORGOT_PASSWORD_OTP_DIGITS', 6), /** * The OTP digest algorithm, by default is sha1. */ 'otp_algorithm' => env('SYEHAN_FORGOT_PASSWORD_OTP_ALGORITHM', 'sha1'), /** * The Interval of OTP will be valid, by default is 60 second. */ 'otp_period' => env('SYEHAN_FORGOT_PASSWORD_OTP_PERIOD', 60), /** * Company Name is basically for using our default mail template which must include the company name. * Otherwise, the mail looks like sent by empty company. */ 'company_name' => env('SYEHAN_FORGOT_PASSWORD_COMPANY_NAME', 'Syehan Company'), /** * Company Site/Website is basically for using our default mail template which must include the company link. */ 'company_site' => env('SYEHAN_FORGOT_PASSWORD_COMPANY_SITE', 'syehan.com'), /** * Company Location is basically for using our default mail template which must include the company location. */ 'company_location' => env('SYEHAN_FORGOT_PASSWORD_COMPANY_LOCATION', 'Jakarta, Indonesia'), /** * Company Sender Name is basically for using our default mail template which must include the company sender name. */ 'company_sender_name' => env('SYEHAN_FORGOT_PASSWORD_COMPANY_SENDER_NAME', 'Syehan CS'), ];
syehan/forgotpassword-plugin 适用场景与选型建议
syehan/forgotpassword-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 2, 最近一次更新时间为 2023 年 10 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「email」 「laravel」 「otp」 「october」 「octobercms」 「forgot-password」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 syehan/forgotpassword-plugin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 syehan/forgotpassword-plugin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 syehan/forgotpassword-plugin 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Extensible library for building notifications and sending them via different delivery channels.
Email+ extends Kirby's email capabilities by adding support for multiple email services using the same Kirby email API.
OTP generating package
Laravel contact us form package to send email and save to database
OTP generating package
Alfabank REST API integration
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-10-25