2

I'm trying to modify the original User.php file within the vendor folder of cartalyt/sentry because I want to register two accounts with the same email but the original code of Sentry is not allowing this feature so I added an attribute to the config.php file

/app/config/packages/cartalyst/sentry/config.php

But I don't know how to get this attribute to use in this file:

/vendor/cartalyst/sentry/src/Cartalyst/Sentry/Users/Eloquent/User.php

Because in that file I can simply add an if to check If I want to register one user per email or register more users with the same email.

Or if you have a better idea will be good to know it.

I hope you can help me!

SoldierCorp
  • 7,610
  • 16
  • 60
  • 100

1 Answers1

0
You dont need to touch that file what you should do is 

**remove this**     
$table->unique('email');
**from this file**  
**your-app/vendor/cartalyst/sentry/src/migrations/2012_12_06_225921_migration_cartalyst_sentry_install_users.php**

That would remove the unique constraint on creating a user with one single email

Then you might need to drop the db or look for a way to re-run the migrations.
osleonard
  • 595
  • 5
  • 22
  • That's true, it's a better idea. Thanks! – SoldierCorp Jul 10 '15 at 17:22
  • Actually I still have the same issue so I think for now I don't have other option only change directly to that User.php file and remove that vendor folder from the .gitignore. – SoldierCorp Jul 12 '15 at 07:58
  • did you re-run the migration?? – osleonard Jul 12 '15 at 12:02
  • Yes I did but the function to save the user has a method by default to compare whether the current email is already in the database or not – SoldierCorp Jul 13 '15 at 03:28
  • I quite agree with you you might have to remove this definition in the User model here -> your-app/vendor/cartalyst/sentry/src/Cartalyst/Sentry/Users/Eloquent/User/ Check if the user already exists $query = $this->newQuery(); $persistedUser = $query->where($this->getLoginName(), '=', $login)->first(); if ($persistedUser and $persistedUser->getId() != $this->getId()) { throw new UserExistsException("A user already exists with login [$login], logins must be unique for users."); } – osleonard Jul 15 '15 at 11:55
  • Yes, I did it now I'm researching about how don't update this package or exclude this one from the composer update. – SoldierCorp Jul 15 '15 at 15:29