ahmedash95/users-verification 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

ahmedash95/users-verification

Composer 安装命令:

composer require ahmedash95/users-verification

包简介

Laravel Package for managing users verification.

README 文档

README

This package contains a trait to support Eloquent Models Verification

$user = App\User::find(1);

// Generate token or get it if exists
$user->getToken();

// check if user is verified or not
$user->isVerified()

// check if token is valid for user
$token = 'random_token_generated_by_getToken()_method'
$user->verifyToken($token) // return true or false

// verify the user
if($user->verifyToken($token)) {
	$user->verify();
}

// remove user token
$user->flushToken();

Installation

You can install the package via composer:

composer require ahmedash95/users-verification

Next up, the service provider must be registered:

// config/app.php
'providers' => [
    ...
    Ahmedash95\UsersVerification\UsersVerificationServiceProvider::class,

];

you must publish the migration file:

php artisan vendor:publish --provider="Ahmedash95\UsersVerification\UsersVerificationServiceProvider" --tag="migrations"

then run the migration command

php artisan migrate

Use verification in User model

use Illuminate\Foundation\Auth\User as Authenticatable;

use Ahmedash95\UsersVerification\UsersVerification;

class User extends Authenticatable
{
    use UsersVerification;

Available Methods

Get\Generate token for user

The getToken method will return the user token string or generate it if it doesn't not exists.

public function getToken() : string

Check user token

This method will verify if the given token is valid for the user

public function verifyToken(String $token) : bool

Verify the user

After checking if the token is valid you may want to activate user verification .. then you should use verify method

public function verify()

Get user by token

If you want to validate your users using token you could use findByToken method

public static function findByToken($token)

this method return object of user or null if doesn't exists

Remove user's token

public function flushToken()

Security

If you discover any security related issues, please email ahmed29329@gmail.com instead of using the issue tracker.

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-06-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固