Cartalyst LLC.
Sentinel-unique-passwords by Cartalyst
0
4
0
4
0

This package requires a valid subscription. Subscribe for access.

Introduction

Sentinel Unique-Passwords is a Sentinel addon that prevents users from setting the same password more than once.

Installation

The best and easiest way to install the addon is with Composer.

Preparation

Open your composer.json file and add the following to the require array:

"cartalyst/sentinel-unique-passwords": "^5.0"

Add the following lines after the require array on your composer.json file:

"repositories": [
    {
        "type": "composer",
        "url": "https://packages.cartalyst.com"
    }
],

Note: Make sure that after the required changes your composer.json file is valid by running composer validate.

Install the dependencies

Run Composer to install or update the new requirement.

php composer install

or

php composer update

Now you are able to require the vendor/autoload.php file to autoload the package.

Integration

Laravel 8

The Sentinel Unique-Passwords addon has optional support for Laravel 8 and it comes bundled with a Service Provider for easy integration.

After installing the addon, open your Laravel config file located at config/app.php and add the following.

In the $providers array add the following service provider for this addon.

'Cartalyst\Sentinel\Addons\UniquePasswords\Laravel\UniquePasswordsServiceProvider',

Migrations

Run the following command to migrate Sentinel Unique Passwords after publishing the assets.

`php artisan migrate`

Native

<?php

use Cartalyst\Sentinel\Addons\UniquePasswords\UniquePasswords;

$users = Sentinel::getUserRepository();

$model = $users->getModel();

$uniquePasswords = new UniquePasswords($users);

Sentinel::getEventDispatcher()->listen("eloquent.created: Cartalyst\Sentinel\Users\EloquentUser", function($user, $credentials) use ($uniquePasswords) {
    $uniquePasswords->created($user, $credentials);
});

Sentinel::getEventDispatcher()->listen('sentinel.user.filled', function($user, $credentials) use ($uniquePasswords) {
    $uniquePasswords->filled($user, $credentials);
});

Sentinel::getEventDispatcher()->listen("eloquent.deleted: {$model}", function($user) use ($uniquePasswords) {
    $uniquePasswords->deleted($user);
});

Usage

<?php

use Cartalyst\Sentinel\Addons\UniquePasswords\Exceptions\NotUniquePasswordException;

$user = Sentinel::findById(1);

try {
    Sentinel::update($user, ['password' => 'foobar']);
} catch (NotUniquePasswordException $e) {
    // Handle the error here
}

You wont find fancy lifestyle graphics and marketing bravado here. Just cold... hard... code...

Code Well, Rock On!
Processing Payment...