mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
Merge pull request #144 from winzou/email-login-clean
[clean] Use email instead of username
This commit is contained in:
commit
5a73acbacc
17 changed files with 104 additions and 64 deletions
|
|
@ -6,7 +6,7 @@
|
|||
</div>
|
||||
|
||||
<blockquote>
|
||||
<p>Please login using "<strong>sylius</strong>" username and "<strong>sylius</strong>" as password.</p>
|
||||
<p>Please login using "<strong>sylius@example.com</strong>" email and "<strong>sylius</strong>" as password.</p>
|
||||
<small>Mr. Sylius Demo Guide</small>
|
||||
</blockquote>
|
||||
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
<form action="{{ path('fos_user_security_check') }}" method="post">
|
||||
<fieldset>
|
||||
<div class="control-group">
|
||||
<label for="username" class="control-label">Login</label>
|
||||
<label for="username" class="control-label">Email</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="username" name="_username" value="{{ last_username }}" />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -66,6 +66,9 @@ fos_user:
|
|||
profile:
|
||||
form:
|
||||
type: sylius_user_profile
|
||||
registration:
|
||||
form:
|
||||
type: sylius_user_registration
|
||||
|
||||
swiftmailer:
|
||||
transport: %sylius.mailer.transport%
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ Feature: Users management
|
|||
Background:
|
||||
Given I am logged in as administrator
|
||||
And there are following users:
|
||||
| username | enabled |
|
||||
| beth | no |
|
||||
| martha | yes |
|
||||
| rick | no |
|
||||
| dale | yes |
|
||||
| email | enabled |
|
||||
| beth@foo.com | no |
|
||||
| martha@foo.com | yes |
|
||||
| rick@foo.com | no |
|
||||
| dale@foo.com | yes |
|
||||
And the following zones are defined:
|
||||
| name | type | members |
|
||||
| Poland | country | Poland |
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ Feature: User account profile edition
|
|||
When I leave "Email" field blank
|
||||
And I fill in "First name" with "John"
|
||||
And I fill in "Last name" with "Doe"
|
||||
And I fill in "Username" with "jdoe"
|
||||
And I press "Save changes"
|
||||
Then I should still be on my account profile edition page
|
||||
And I should see "Please enter an email"
|
||||
|
|
@ -26,7 +25,6 @@ Feature: User account profile edition
|
|||
When I fill in "Email" with "username@example.com"
|
||||
And I leave "First name" field blank
|
||||
And I fill in "Last name" with "Doe"
|
||||
And I fill in "Username" with "jdoe"
|
||||
And I press "Save changes"
|
||||
Then I should still be on my account profile edition page
|
||||
And I should see "Please enter a first name"
|
||||
|
|
@ -36,27 +34,15 @@ Feature: User account profile edition
|
|||
When I fill in "Email" with "username@example.com"
|
||||
And I fill in "First name" with "John"
|
||||
And I leave "Last name" field blank
|
||||
And I fill in "Username" with "jdoe"
|
||||
And I press "Save changes"
|
||||
Then I should still be on my account profile edition page
|
||||
And I should see "Please enter a last name"
|
||||
|
||||
Scenario: Editing my information with a blank username
|
||||
Given I am on my account profile edition page
|
||||
When I fill in "Email" with "username@example.com"
|
||||
And I fill in "First name" with "John"
|
||||
And I fill in "Last name" with "Doe"
|
||||
And I leave "Username" field blank
|
||||
And I press "Save changes"
|
||||
Then I should still be on my account profile edition page
|
||||
And I should see "Please enter a username"
|
||||
|
||||
Scenario: Editing my information with an invalid email
|
||||
Given I am on my account profile edition page
|
||||
When I fill in "Email" with "wrongemail"
|
||||
And I fill in "First name" with "John"
|
||||
And I fill in "Last name" with "Doe"
|
||||
And I fill in "Username" with "jdoe"
|
||||
And I press "Save changes"
|
||||
Then I should still be on my account profile edition page
|
||||
And I should see "The email is not valid"
|
||||
|
|
@ -66,7 +52,6 @@ Feature: User account profile edition
|
|||
When I fill in "Email" with "johndoe@example.com"
|
||||
And I fill in "First name" with "John"
|
||||
And I fill in "Last name" with "Doe"
|
||||
And I fill in "Username" with "jdoe"
|
||||
And I press "Save changes"
|
||||
Then I should be on my account profile page
|
||||
And I should see "Your personal information have been updated"
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ Feature: Checkout addressing
|
|||
| name | price | taxons |
|
||||
| PHP Top | 5.99 | PHP T-Shirts |
|
||||
And there are following users:
|
||||
| username | password | enabled |
|
||||
| john | foo | yes |
|
||||
| rick | bar | yes |
|
||||
| email | password | enabled |
|
||||
| john@example.com | foo | yes |
|
||||
| rick@example.com | bar | yes |
|
||||
And I am logged in user
|
||||
And there are following countries:
|
||||
| name |
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ Feature: Checkout security
|
|||
| name | price | taxons |
|
||||
| PHP Top | 5.99 | PHP T-Shirts |
|
||||
And there are following users:
|
||||
| username | password | enabled |
|
||||
| john | foo | yes |
|
||||
| rick | bar | yes |
|
||||
| email | password | enabled |
|
||||
| john@example.com | foo | yes |
|
||||
| rick@example.com | bar | yes |
|
||||
And the following zones are defined:
|
||||
| name | type | members |
|
||||
| UK | country | United Kingdom |
|
||||
|
|
@ -31,21 +31,20 @@ Feature: Checkout security
|
|||
Scenario: Trying to sign in with bad credentials
|
||||
during the checkout
|
||||
When I fill in the following:
|
||||
| Username | john |
|
||||
| Password | habababa |
|
||||
| Email | john@example.com |
|
||||
| Password | habababa |
|
||||
And I press "Login"
|
||||
Then I should see "Bad credentials"
|
||||
|
||||
Scenario: Signing in during the checkout
|
||||
When I fill in the following:
|
||||
| Username | john |
|
||||
| Password | foo |
|
||||
| Email | john@example.com |
|
||||
| Password | foo |
|
||||
And I press "Login"
|
||||
Then I should be redirected to the checkout addressing step
|
||||
|
||||
Scenario: Creating account during the checkout
|
||||
When I fill in the following:
|
||||
| fos_user_registration_form_username | mike |
|
||||
| fos_user_registration_form_email | mike@example.com |
|
||||
| fos_user_registration_form_plainPassword_first | mikepass |
|
||||
| fos_user_registration_form_plainPassword_second | mikepass |
|
||||
|
|
@ -54,7 +53,6 @@ Feature: Checkout security
|
|||
|
||||
Scenario: Creating account during the whole checkout
|
||||
When I fill in the following:
|
||||
| fos_user_registration_form_username | mike |
|
||||
| fos_user_registration_form_email | mike@example.com |
|
||||
| fos_user_registration_form_plainPassword_first | mikepass |
|
||||
| fos_user_registration_form_plainPassword_second | mikepass |
|
||||
|
|
|
|||
|
|
@ -5,15 +5,15 @@ Feature: Sign in to the store
|
|||
|
||||
Background:
|
||||
Given there are following users:
|
||||
| username | password | enabled |
|
||||
| bar | foo | yes |
|
||||
| email | password | enabled |
|
||||
| bar@foo.com | foo | yes |
|
||||
|
||||
Scenario: Log in with username and password
|
||||
Given I am on the store homepage
|
||||
And I follow "Login"
|
||||
When I fill in the following:
|
||||
| Login | bar |
|
||||
| Password | foo |
|
||||
| Email | bar@foo.com |
|
||||
| Password | foo |
|
||||
And I press "Login"
|
||||
Then I should be on the store homepage
|
||||
And I should see "Logout"
|
||||
|
|
@ -22,8 +22,8 @@ Feature: Sign in to the store
|
|||
Given I am on the store homepage
|
||||
And I follow "Login"
|
||||
When I fill in the following:
|
||||
| Login | bar |
|
||||
| Password | bar |
|
||||
| Email | bar@foo.com |
|
||||
| Password | bar |
|
||||
And I press "Login"
|
||||
Then I should be on login page
|
||||
And I should see "Bad credentials"
|
||||
|
|
@ -32,7 +32,7 @@ Feature: Sign in to the store
|
|||
Given I am on the store homepage
|
||||
And I follow "Login"
|
||||
When I fill in the following:
|
||||
| Login | john |
|
||||
| Email | john |
|
||||
| Password | bar |
|
||||
And I press "Login"
|
||||
Then I should be on login page
|
||||
|
|
|
|||
|
|
@ -5,15 +5,14 @@ Feature: User registration
|
|||
|
||||
Background:
|
||||
Given there are following users:
|
||||
| username | password |
|
||||
| bar | foo |
|
||||
| email | password |
|
||||
| bar@bar.com | foo |
|
||||
|
||||
Scenario: Successfully creating account in store
|
||||
Given I am on the store homepage
|
||||
And I follow "Register"
|
||||
When I fill in the following:
|
||||
| Email | foo@bar.com |
|
||||
| Username | foo |
|
||||
| Password | bar |
|
||||
| Verification | bar |
|
||||
And I press "Register"
|
||||
|
|
@ -25,9 +24,19 @@ Feature: User registration
|
|||
And I follow "Register"
|
||||
When I fill in the following:
|
||||
| Email | foo@bar.com |
|
||||
| Username | foo |
|
||||
| Password | bar |
|
||||
| Verification | foo |
|
||||
And I press "Register"
|
||||
Then I should be on registration page
|
||||
And I should see "The entered passwords don't match"
|
||||
And I should see "The entered passwords don't match"
|
||||
|
||||
Scenario: Trying to register with already existing email
|
||||
Given I am on the store homepage
|
||||
And I follow "Register"
|
||||
When I fill in the following:
|
||||
| Email | bar@bar.com |
|
||||
| Password | bar |
|
||||
| Verification | bar |
|
||||
And I press "Register"
|
||||
Then I should be on registration page
|
||||
And I should see "The email is already used"
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ class LoadUsersData extends DataFixture
|
|||
{
|
||||
$user = new User();
|
||||
|
||||
$user->setUsername('sylius');
|
||||
$user->setEmail('sylius@example.com');
|
||||
$user->setPlainPassword('sylius');
|
||||
$user->setEnabled(true);
|
||||
|
|
@ -44,7 +43,6 @@ class LoadUsersData extends DataFixture
|
|||
|
||||
$username = $this->faker->username;
|
||||
|
||||
$user->setUsername($username);
|
||||
$user->setEmail($username.'@example.com');
|
||||
$user->setPlainPassword($username);
|
||||
$user->setEnabled($this->faker->boolean());
|
||||
|
|
@ -55,7 +53,6 @@ class LoadUsersData extends DataFixture
|
|||
}
|
||||
|
||||
$manager->flush();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class User extends BaseUser implements TimestampableInterface
|
|||
$this->billingAddress = $billingAddress;
|
||||
|
||||
if (null !== $billingAddress && !$this->hasAddress($billingAddress)) {
|
||||
$this->addAddress($billingAddress);
|
||||
$this->addAddress($billingAddress);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
@ -91,7 +91,7 @@ class User extends BaseUser implements TimestampableInterface
|
|||
$this->shippingAddress = $shippingAddress;
|
||||
|
||||
if (null !== $shippingAddress && !$this->hasAddress($shippingAddress)) {
|
||||
$this->addAddress($shippingAddress);
|
||||
$this->addAddress($shippingAddress);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
@ -192,4 +192,20 @@ class User extends BaseUser implements TimestampableInterface
|
|||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
}
|
||||
|
||||
public function setEmail($email)
|
||||
{
|
||||
parent::setEmail($email);
|
||||
$this->setUsername($email);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setEmailCanonical($emailCanonical)
|
||||
{
|
||||
parent::setEmailCanonical($emailCanonical);
|
||||
$this->setUsernameCanonical($emailCanonical);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use FOS\UserBundle\Form\Type\RegistrationFormType as BaseType;
|
||||
|
||||
class RegistrationFormType extends BaseType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
parent::buildForm($builder, $options);
|
||||
|
||||
// remove the username field
|
||||
$builder->remove('username');
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'sylius_user_registration';
|
||||
}
|
||||
}
|
||||
|
|
@ -133,7 +133,7 @@ class DataContext extends BehatContext implements KernelAwareInterface
|
|||
|
||||
foreach ($table->getHash() as $data) {
|
||||
$this->thereIsUser(
|
||||
$data['username'],
|
||||
$data['email'],
|
||||
isset($data['password']) ? $data['password'] : $this->faker->word(),
|
||||
'ROLE_USER',
|
||||
isset($data['enabled']) ? $data['enabled'] : true
|
||||
|
|
@ -141,11 +141,10 @@ class DataContext extends BehatContext implements KernelAwareInterface
|
|||
}
|
||||
}
|
||||
|
||||
public function thereIsUser($username, $password, $role = null, $enabled = 'yes')
|
||||
public function thereIsUser($email, $password, $role = null, $enabled = 'yes')
|
||||
{
|
||||
$user = new User();
|
||||
$user->setUsername($username);
|
||||
$user->setEmail($this->faker->email());
|
||||
$user->setEmail($email);
|
||||
$user->setEnabled('yes' === $enabled);
|
||||
$user->setPlainPassword($password);
|
||||
|
||||
|
|
|
|||
|
|
@ -636,10 +636,10 @@ class WebUser extends MinkContext implements KernelAwareInterface
|
|||
*/
|
||||
private function iAmLoggedInAsRole($role)
|
||||
{
|
||||
$this->getSubContext('data')->thereIsUser('username', 'password', $role);
|
||||
$this->getSubContext('data')->thereIsUser('email@foo.com', 'password', $role);
|
||||
$this->getSession()->visit($this->generatePageUrl('fos_user_security_login'));
|
||||
|
||||
$this->fillField('Login', 'username');
|
||||
$this->fillField('Email', 'email@foo.com');
|
||||
$this->fillField('Password', 'password');
|
||||
$this->pressButton('login');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,9 +30,6 @@ class ProfileFormType extends BaseType
|
|||
->add('lastName', 'text', array(
|
||||
'label' => 'sylius.form.profile.lastName'
|
||||
))
|
||||
->add('username', null, array(
|
||||
'label' => 'sylius.form.profile.username'
|
||||
))
|
||||
->add('email', 'email', array(
|
||||
'label' => 'sylius.form.profile.email'
|
||||
))
|
||||
|
|
|
|||
|
|
@ -88,6 +88,11 @@
|
|||
<service id="sylius.twig.text_extension" class="Twig_Extensions_Extension_Text">
|
||||
<tag name="twig.extension" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.user.registration.form.type" class="Sylius\Bundle\CoreBundle\Form\Type\RegistrationFormType">
|
||||
<tag name="form.type" alias="sylius_user_registration" />
|
||||
<argument>%fos_user.model.user.class%</argument>
|
||||
</service>
|
||||
</services>
|
||||
|
||||
</container>
|
||||
|
|
|
|||
|
|
@ -350,9 +350,9 @@
|
|||
<source>sylius.form.login.password</source>
|
||||
<target>Password</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="ff22d36333dd2c7f46f18088cd81f596" resname="sylius.form.login.username">
|
||||
<source>sylius.form.login.username</source>
|
||||
<target>Username</target>
|
||||
<trans-unit id="ea0c4a2c08a2d13161d6e4312d5f7e22" resname="sylius.form.login.email">
|
||||
<source>sylius.form.login.email</source>
|
||||
<target>Email</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="25b6370883ff5b94aef1ceb697b6d3f6" resname="sylius.gallery.next">
|
||||
<source>sylius.gallery.next</source>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
<form action="{{ path('fos_user_security_check') }}" method="post">
|
||||
<fieldset>
|
||||
<div class="control-group">
|
||||
<label for="username" class="control-label">{{ 'sylius.form.login.username'|trans }}</label>
|
||||
<label for="username" class="control-label">{{ 'sylius.form.login.email'|trans }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="username" name="_username" />
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue