https://github.com/knplabs/rad-user
Simply handle password encryption and salt generation.
https://github.com/knplabs/rad-user
php rad symfony-bundle
Last synced: 8 months ago
JSON representation
Simply handle password encryption and salt generation.
- Host: GitHub
- URL: https://github.com/knplabs/rad-user
- Owner: KnpLabs
- Archived: true
- Created: 2014-12-18T09:25:03.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2022-09-23T13:25:31.000Z (about 3 years ago)
- Last Synced: 2024-12-16T17:53:02.451Z (10 months ago)
- Topics: php, rad, symfony-bundle
- Language: PHP
- Homepage: http://knplabs.com
- Size: 56.6 KB
- Stars: 5
- Watchers: 26
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DEPRECATED
Unfortunately we decided to not maintain this project anymore ([see why](https://knplabs.com/en/blog/news-for-our-foss-projects-maintenance)).
If you want to mark another package as a replacement for this one please send an email to [hello@knplabs.com](mailto:hello@knplabs.com).Rapid Application Development : User
====================================
A **Symfony bundle** to simply handle password encryption and salt generation[](https://travis-ci.org/KnpLabs/rad-user)
[](https://scrutinizer-ci.com/g/KnpLabs/rad-user/?branch=master)
[](https://packagist.org/packages/knplabs/rad-user) [](https://packagist.org/packages/knplabs/rad-user) [](https://packagist.org/packages/knplabs/rad-user) [](https://packagist.org/packages/knplabs/rad-user)# Official maintainers:
* [@Einenlum](https://github.com/Einenlum)
# Installation
```bash
composer require knplabs/rad-user:~2.0
``````php
class AppKernel
{
function registerBundles()
{
$bundles = array(
//...
new Knp\Rad\User\Bundle\UserBundle(),
//...
);//...
return $bundles;
}
}
```# Usages
## I want to auto-generate my user salt
> The salt feature is deprecated since PHP 5.5 and BCrypt usage. Please upgrade your version of PHP and use BCrypt.
Your User model should implement the `Knp\Rad\User\HasSalt` interface.
```php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Knp\Rad\User\HasSalt;/**
* @ORM\Entity
*/
class User implements HasSalt
{
use HasSalt\HasSalt; //You can also use this trait/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;/**
* @ORM\Column
*/
private $salt;
}
```Now, before your user is inserted into your database, the salt will be auto-generated.
## I want to auto-generate my user password
Your User model should implement the `Knp\Rad\User\HasInitialPassword` interface.
```php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Knp\Rad\User\HasInitialPassword;/**
* @ORM\Entity
*/
class User implements HasInitialPassword
{
use HasInitialPassword\HasInitialPassword; // You can also use this trait/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;/**
* @ORM\Column
*/
private $password;
}
```Now, before your user is inserted or updated into your database, then the plain password will be automaticly generated.
## I want to auto-encode my user password
Your User model should implement the `Knp\Rad\User\HasPassword` interface.
```php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Knp\Rad\User\HasPassword;/**
* @ORM\Entity
*/
class User implements HasPassword
{
use HasPassword\HasPassword; // You can also use this trait/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;/**
* @ORM\Column
*/
private $password;
}
```Now, before your user is inserted or updated into your database, if you have set the attribute 'plainPassword', then the password will be automaticly generated.
# WARNING
The `Knp\Rad\User\HasPassword\HasPassword` trait use the `Knp\Rad\User\HasInitialPassword\HasInitialPassword` trait. So don't use both into the same class or you will have a method conflict.
# Some tips
## Using with MongoDB or CouchDB Object Document Mapper
The knp/rad-user library is also compatible with MongoDB and CouchDB