lachezargrigorov/laravel-tokens-manager
最新稳定版本:1.0.3
Composer 安装命令:
composer require lachezargrigorov/laravel-tokens-manager
包简介
An easy to use tokens manager for Laravel applications. Useful in user email confirmation process and not only.
README 文档
README
An easy to use tokens manager for Laravel applications. Useful in user email confirmation process and not only.
Installation
Via Composer
$ composer require lachezargrigorov\laravel-tokens-manager
If you do not run Laravel 5.5 (or higher), then add the service provider in config/app.php:
\Lachezargrigorov\TokensManager\TokensManagerServiceProvider::class,
If you do not run Laravel 5.5 and want to use the facade, add this to your aliases in app.php:
'Tokens' => \Lachezargrigorov\TokensManager\Facades\TokensManager::class,
Usage
//using Facades //1. Create token with payload $token = Tokens::use('default')->create(['userId' => 123]); //2. Send confirmation url with created token to user per email. //3. User click on confirmation url. //4.Get the token's payload from the token in the url. //This will delete the token! $payload = Tokens::use('default')->get($token); //if token exist and not expired if($payload) { $userId = $payload["userId"]; //confirm user email } //using IOC $tokensManager = app("tokens-manager"); $token = $tokensManager->use('default')->create(['userId' => 123]); $payload = $tokensManager->use('default')->get($token);
Get payload without deleting the token
$payload = Tokens::use('default')->get($token,false);
Token not found
$payload = Tokens::use('default')->get($token); //null
Expired tokens are deleted automatically on every Tokens::use call for all managers so you can't receive the payload of expired token and you don't need to delete them manually too!
If you still wants to delete a token
$payload = Tokens::use('default')->delete($token);
Testing
$ composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING , ISSUE_TEMPLATE and PULL_REQUEST_TEMPLATE for details.
Security
If you discover any security related issues, please email lachezar@grigorov.website instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 170
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-10-15