delight-im / PHP-Auth

Authentication for PHP. Simple, lightweight and secure.
MIT License
1.09k stars 235 forks source link

User already exists when registering using InnoDB #270

Closed xRJx closed 2 years ago

xRJx commented 2 years ago

I'm trying to get the login library to work with InnoDB by following this: https://github.com/delight-im/PHP-Auth/issues/137

I changed users.email and users_confirmations.email to varchar(191) but I get a message saying "user already exists" when I attempt to register. Is there anything else I have to do that I missed? I'm still kinda new to using this library so I'm not all too familiar with how it works.

ocram commented 2 years ago

Are you using Auth#register or Auth#registerWithUniqueUsername?

Can you check in your database table users that there is indeed no user with the specified email address (and username)?

Apart from that, in your project directory, you could open vendor/delight-im/auth/src/UserManager.php, and in protected function createUserInternal, inside of catch (IntegrityConstraintViolationException $e) {}, log the full exception with all details and look at it.

xRJx commented 2 years ago

Are you using Auth#register or Auth#registerWithUniqueUsername?

Can you check in your database table users that there is indeed no user with the specified email address (and username)?

Apart from that, in your project directory, you could open vendor/delight-im/auth/src/UserManager.php, and in protected function createUserInternal, inside of catch (IntegrityConstraintViolationException $e) {}, log the full exception with all details and look at it.

Whoops, I see what I overlooked now. I was so used to using MyISAM without the foreign key constraints that I forgot I had made a foreign key that wasn't being filled upon user creation. I fixed that up with a default value. Sorry about that! A silly oversight on my part.

ocram commented 2 years ago

No problem, thanks!