Shield: Set random user ID |
10-02-2023, 07:35 AM
(This post was last modified: 10-02-2023, 07:38 AM by AndrewDFrazier. Edit Reason: Additional information )
I'm working on rebuilding a project that was built on CI3 and used Community Auth for user registration functions. A key part of this user creation was that random IDs were used rather than sequential ones. I'd like to reproduce that using Shield.
I've generated an unused ID and set $user->id to use it within RegisterController: Code: // Workaround for email only registration/login However, this causes insertion to fail because of a foreign key constraint failure: Code: Cannot add or update a child row: a foreign key constraint fails (`auth_identities`, CONSTRAINT `auth_identities_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE) Is there a better way to generate and use random IDs? I should add that if I remove my line setting $user->ID then the user creation works as normal. Quote:save()
Create your own User Provider and customize.
See https://github.com/codeigniter4/shield/b...rovider.md |
Welcome Guest, Not a member yet? Register Sign In |