Laragear / TwoFactor

Two-Factor Authentication for all your users out-of-the-box.
https://github.com/sponsors/DarkGhostHunter
MIT License
273 stars 20 forks source link

[1.x] cannot use user.uuid because of TwoFactorAuthentication model casting authenticatable_id to "int" #56

Closed ollylowe closed 8 months ago

ollylowe commented 1 year ago

PHP & Platform

8.2.9 - MacOSX

Database

PostgreSQL 15

Laravel version

10.21.0

Have you done this?

Expectation

I expect to be able to use uuids as the authenticable id

Description

Reproduction

// user migration
$table->uuid('userId')->primary()->unique();

// two-factor migration
$table->uuidMorphs('authenticatable', '2fa_auth_type_auth_id_index');

// attempt to retrive the user from the 2fa model - results in an error because uuid is cast to int e.g.
// "97d08fcf-6639-4e66-a301-d325e7f7435b" -> 97
$twoFactorModel->authenticable

// Error Message
// PDOException: SQLSTATE[22P02]: Invalid text representation: 7 ERROR:  invalid input syntax for type uuid: "97"

Stack trace & logs

No response