-
+
diff --git a/app/config/config.yml b/app/config/config.yml
index 5bf3039f3e..205a744634 100644
--- a/app/config/config.yml
+++ b/app/config/config.yml
@@ -66,6 +66,9 @@ fos_user:
profile:
form:
type: sylius_user_profile
+ registration:
+ form:
+ type: sylius_user_registration
swiftmailer:
transport: %sylius.mailer.transport%
diff --git a/features/backend/users.feature b/features/backend/users.feature
index f5fa5a0c47..427aca5b2c 100644
--- a/features/backend/users.feature
+++ b/features/backend/users.feature
@@ -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 |
diff --git a/features/frontend/account_profile.feature b/features/frontend/account_profile.feature
index 1165c9e8cd..f3c9f9d72f 100644
--- a/features/frontend/account_profile.feature
+++ b/features/frontend/account_profile.feature
@@ -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"
diff --git a/features/frontend/checkout_addressing.feature b/features/frontend/checkout_addressing.feature
index 7b03f46a59..3a7470894d 100644
--- a/features/frontend/checkout_addressing.feature
+++ b/features/frontend/checkout_addressing.feature
@@ -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 |
diff --git a/features/frontend/checkout_security.feature b/features/frontend/checkout_security.feature
index 15cdbbfcc7..c5dcf7edc9 100644
--- a/features/frontend/checkout_security.feature
+++ b/features/frontend/checkout_security.feature
@@ -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 |
diff --git a/features/frontend/user_login.feature b/features/frontend/user_login.feature
index 19113d99a7..d0cb23ce18 100644
--- a/features/frontend/user_login.feature
+++ b/features/frontend/user_login.feature
@@ -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
diff --git a/features/frontend/user_registration.feature b/features/frontend/user_registration.feature
index 140a8914c7..c64b6cd0b7 100644
--- a/features/frontend/user_registration.feature
+++ b/features/frontend/user_registration.feature
@@ -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"
\ No newline at end of file
+ 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"
diff --git a/src/Sylius/Bundle/CoreBundle/DataFixtures/ORM/LoadUsersData.php b/src/Sylius/Bundle/CoreBundle/DataFixtures/ORM/LoadUsersData.php
index 636c445f0c..f10f5e13cc 100644
--- a/src/Sylius/Bundle/CoreBundle/DataFixtures/ORM/LoadUsersData.php
+++ b/src/Sylius/Bundle/CoreBundle/DataFixtures/ORM/LoadUsersData.php
@@ -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();
-
}
/**
diff --git a/src/Sylius/Bundle/CoreBundle/Entity/User.php b/src/Sylius/Bundle/CoreBundle/Entity/User.php
index 9287203d37..dbdd014e1b 100644
--- a/src/Sylius/Bundle/CoreBundle/Entity/User.php
+++ b/src/Sylius/Bundle/CoreBundle/Entity/User.php
@@ -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;
+ }
}
diff --git a/src/Sylius/Bundle/CoreBundle/Form/Type/RegistrationFormType.php b/src/Sylius/Bundle/CoreBundle/Form/Type/RegistrationFormType.php
new file mode 100644
index 0000000000..5aa8e2e716
--- /dev/null
+++ b/src/Sylius/Bundle/CoreBundle/Form/Type/RegistrationFormType.php
@@ -0,0 +1,31 @@
+remove('username');
+ }
+
+ public function getName()
+ {
+ return 'sylius_user_registration';
+ }
+}
diff --git a/src/Sylius/Bundle/WebBundle/Behat/DataContext.php b/src/Sylius/Bundle/WebBundle/Behat/DataContext.php
index 279208904a..7188c02202 100644
--- a/src/Sylius/Bundle/WebBundle/Behat/DataContext.php
+++ b/src/Sylius/Bundle/WebBundle/Behat/DataContext.php
@@ -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);
diff --git a/src/Sylius/Bundle/WebBundle/Behat/WebUser.php b/src/Sylius/Bundle/WebBundle/Behat/WebUser.php
index a898f2ad66..44d5fbd053 100644
--- a/src/Sylius/Bundle/WebBundle/Behat/WebUser.php
+++ b/src/Sylius/Bundle/WebBundle/Behat/WebUser.php
@@ -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');
}
diff --git a/src/Sylius/Bundle/WebBundle/Form/ProfileFormType.php b/src/Sylius/Bundle/WebBundle/Form/ProfileFormType.php
index 97992b9d31..afcb3b6f7b 100644
--- a/src/Sylius/Bundle/WebBundle/Form/ProfileFormType.php
+++ b/src/Sylius/Bundle/WebBundle/Form/ProfileFormType.php
@@ -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'
))
diff --git a/src/Sylius/Bundle/WebBundle/Resources/config/services.xml b/src/Sylius/Bundle/WebBundle/Resources/config/services.xml
index d5a982cecb..0d0dd0a610 100644
--- a/src/Sylius/Bundle/WebBundle/Resources/config/services.xml
+++ b/src/Sylius/Bundle/WebBundle/Resources/config/services.xml
@@ -88,6 +88,11 @@
+
+
+
+ %fos_user.model.user.class%
+
diff --git a/src/Sylius/Bundle/WebBundle/Resources/translations/messages.en.xlf b/src/Sylius/Bundle/WebBundle/Resources/translations/messages.en.xlf
index 2a1ff2fa60..63f7af8282 100644
--- a/src/Sylius/Bundle/WebBundle/Resources/translations/messages.en.xlf
+++ b/src/Sylius/Bundle/WebBundle/Resources/translations/messages.en.xlf
@@ -350,9 +350,9 @@
sylius.form.login.password
Password
-
- sylius.form.login.username
- Username
+
+ sylius.form.login.email
+ Email
sylius.gallery.next
diff --git a/src/Sylius/Bundle/WebBundle/Resources/views/Frontend/Checkout/Step/security.html.twig b/src/Sylius/Bundle/WebBundle/Resources/views/Frontend/Checkout/Step/security.html.twig
index b34dbcd7a9..b651c824c9 100644
--- a/src/Sylius/Bundle/WebBundle/Resources/views/Frontend/Checkout/Step/security.html.twig
+++ b/src/Sylius/Bundle/WebBundle/Resources/views/Frontend/Checkout/Step/security.html.twig
@@ -14,7 +14,7 @@