wearesho-team / yii-tokens
4.0.0
2022-11-30 15:53 UTC
Requires
- php: >=7.4
- horat1us/yii2-carbon-behavior: ^1.2
- horat1us/yii2-validation-exception: ^1.1
- nesbot/carbon: ^2.24 || ^1.22
- wearesho-team/message-delivery: ^1.7
- yiisoft/yii2: ^2.0.47
Requires (Dev)
- horat1us/yii2-asset-free: ^1.0
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.7
This package is auto-updated.
Last update: 2022-11-30 15:54:55 UTC
README
通过发送令牌(短信、电子邮件、Telegram 等)验证某些操作。仅与 MySQL 和 PostgreSQL 兼容
变更日志
安装
composer require wearesho-team/yii-tokens:^3.0
迁移
- 将迁移复制到您的项目中
cd path-to-your-project
cp -R ./vendor/wearesho-team/yii-tokens/migrations ./console/migrations
配置
环境
默认的 TokenRepositoryConfig 从环境变量中加载配置。环境变量名称可能已更改,默认值
- TOKEN_EXPIRE_MINUTES - 令牌创建后的分钟数,当令牌失效时
- TOKEN_VERIFY_LIMIT - 最大验证限制(由 TokenValidator 使用)
- TOKEN_DELIVERY_LIMIT - 最大发送限制(由 TokenRepository 的 send 方法使用)
容器
您应配置 DI 容器以使用环境配置
<?php // bootstrap.php use Wearesho\Yii\Interfaces\TokenRepositoryConfigInterface; use Wearesho\Yii\Configs\TokenRepositoryConfig; Yii::$container->set( TokenRepositoryConfigInterface::class, [ 'class' => TokenRepositoryConfig::class, // Changing environment variables names 'expirePeriodKey' => 'TOKEN_EXPIRE_MINUTES', // optional 'verifyLimitKey' => 'TOKEN_VERIFY_LIMIT', // optional 'deliveryLimitKey' => 'TOKEN_DELIVERY_LIMIT', // optional // Defaults (if no env variables set) 'defaultExpirePeriod' => 30, // optional 'defaultDeliveryLimit' => 3, // optional 'defaultVerifyLimit' => 3, // optional ] );
贡献
运行测试
运行测试 MySQL 数据库
docker compose up -d
运行测试
composer lint
composer test
下线测试 MySQL 数据库
docker compose down
待办事项
- 文档
- 异常测试
许可证
未授权