Wallogit.com
2017 © Pedro Peláez
Laravel Package for managing users verification.
This package contains a trait to support Eloquent Models Verification, (*1)
$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();
You can install the package via composer:, (*2)
composer require ahmedash95/users-verification
Next up, the service provider must be registered:, (*3)
// config/app.php
'providers' => [
...
Ahmedash95\UsersVerification\UsersVerificationServiceProvider::class,
];
you must publish the migration file:, (*4)
php artisan vendor:publish --provider="Ahmedash95\UsersVerification\UsersVerificationServiceProvider" --tag="migrations"
then run the migration command, (*5)
php artisan migrate
use Illuminate\Foundation\Auth\User as Authenticatable;
use Ahmedash95\UsersVerification\UsersVerification;
class User extends Authenticatable
{
use UsersVerification;
The getToken method will return the user token string or generate it if it doesn't not exists., (*6)
public function getToken() : string
This method will verify if the given token is valid for the user, (*7)
public function verifyToken(String $token) : bool
After checking if the token is valid you may want to activate user verification .. then you should use verify method, (*8)
public function verify()
If you want to validate your users using token you could use findByToken method, (*9)
public static function findByToken($token)
this method return object of user or null if doesn't exists, (*10)
public function flushToken()
If you discover any security related issues, please email ahmed29329@gmail.com instead of using the issue tracker., (*11)
The MIT License (MIT). Please see License File for more information., (*12)