Package Data | |
---|---|
Maintainer Username: | ahmedash95 |
Maintainer Contact: | ahmed29329@gmail.com (Ahmed Ashraf) |
Package Create Date: | 2017-06-20 |
Package Last Update: | 2017-06-20 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-15 15:08:41 |
Package Statistics | |
---|---|
Total Downloads: | 19 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 4 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
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();
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 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.
public function getToken() : string
This method will verify if the given token is valid for the user
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
public function verify()
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
public function flushToken()
If you discover any security related issues, please email ahmed29329@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.