summaryrefslogtreecommitdiffstats
path: root/Core/Encoder/UserPasswordEncoderInterface.php
diff options
context:
space:
mode:
authorFabien Potencier <fabien.potencier@gmail.com>2014-07-25 10:49:22 +0200
committerFabien Potencier <fabien.potencier@gmail.com>2014-07-25 10:49:22 +0200
commit598e58a42f42eaaf597afdef41137557f8c862fc (patch)
tree2098036f3a4f3d11e57de3c238fc57de3b1cc48d /Core/Encoder/UserPasswordEncoderInterface.php
parent8e84c8e0aa3a9dcc4560f7223636e394c235d839 (diff)
parent37b68961f133fc8dacc66dcbdaf03e1859122ae0 (diff)
downloadsymfony-security-598e58a42f42eaaf597afdef41137557f8c862fc.zip
symfony-security-598e58a42f42eaaf597afdef41137557f8c862fc.tar.gz
symfony-security-598e58a42f42eaaf597afdef41137557f8c862fc.tar.bz2
feature #11306 [DX] New service to simplify password encoding (aferrandini)
This PR was merged into the 2.6-dev branch. Discussion ---------- [DX] New service to simplify password encoding | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #11299 | License | MIT | Doc PR | https://github.com/symfony/symfony-docs/pull/3995 This new service siplifies the way to encode a password. Just get the `security.password_encoder` service and encode the `User` password. ```php $encoded = $this->container->get('security.password_encoder') ->encodePassword($user, $plainPassword); $user->setPassword($encoded); ``` Commits ------- 7bc190a New service to simplify password encoding
Diffstat (limited to 'Core/Encoder/UserPasswordEncoderInterface.php')
-rw-r--r--Core/Encoder/UserPasswordEncoderInterface.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/Core/Encoder/UserPasswordEncoderInterface.php b/Core/Encoder/UserPasswordEncoderInterface.php
new file mode 100644
index 0000000..39e906a
--- /dev/null
+++ b/Core/Encoder/UserPasswordEncoderInterface.php
@@ -0,0 +1,41 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Security\Core\Encoder;
+
+use Symfony\Component\Security\Core\User\UserInterface;
+
+/**
+ * UserPasswordEncoderInterface is the interface for the password encoder service.
+ *
+ * @author Ariel Ferrandini <arielferrandini@gmail.com>
+ */
+interface UserPasswordEncoderInterface
+{
+ /**
+ *
+ * Encodes the plain password.
+ *
+ * @param UserInterface $user The user
+ * @param string $plainPassword The password to encode
+ *
+ * @return string The encoded password
+ */
+ public function encodePassword(UserInterface $user, $plainPassword);
+
+ /**
+ * @param UserInterface $user The user
+ * @param string $raw A raw password
+ *
+ * @return bool true if the password is valid, false otherwise
+ */
+ public function isPasswordValid(UserInterface $user, $raw);
+}