terminal42 / contao-mailusername

MIT License
7 stars 5 forks source link

Update MailUsername.php #2

Closed tsarma closed 9 years ago

tsarma commented 11 years ago

When from is submitted with empty email, username is set to blank

aschempp commented 11 years ago

The email field is mandatory by default, did you change that in your DCA? If so, you should add doNotSaveEmpty = true, then the save_callback should automatically not be executed.

tsarma commented 11 years ago

No I didn't change it. The field is mandatory as before, and it gives error when I try to save it. But the username is changed to blank. May be as you've suggested it should work if I add - doNotSaveEmpty = true, but I think it is better if we filter that in callback function.

Again another thing to check is, don't change username when new email is already in system. At the moment, although I get an error message saying email should be unique, the username is changed to the new email. This makes 2 members having same username but neither can login. I would suggest following filter in callback ... $objMember = $this->Database->prepare("SELECT id from tl_member WHERE email=?")->execute($strValue); if ($objMember->numRows > 0) { return $strValue; } ...

aschempp commented 9 years ago

This should be changed in 1.0.4