-
-
Notifications
You must be signed in to change notification settings - Fork 20
Description
As discussed on Discord with @mjauvin, guest users are currently not working.
I create a guest (documentation)
$user = Auth::registerGuest(['email' => $email]);
Assuming onCheckEmail is not an official part of the plugin but just an example; this can be ignored
I adjusted example the onCheckEmail() function because Auth::findUserByLogin returns TRUE if a user is found regardless of its value user->is_guest. In my case (and everyone elses?), it should also return FALSE if user->is_guest because even though the user already exists, the user with that specific e-mailadress is still available to be claimed by anyone.
I adjusted the function to solve this issue (which is not really an issue but not documented I guess).
~~public function onCheckEmail() {
// keep isTaken
$isTaken = 1;
// get email
$email = post('email');
// search the user
$user = Auth::findUserByLogin($email);
// if user is NOT found or user is guest -> account is still available to claim
if (!$user || $user->is_guest) $isTaken = 0;
return ['isTaken' => $isTaken];
}~~
This brings me to the next issue;
When the guest user finally wants to register, he gets a validation error that the e-mailadress is already in use because:
plugins/winter/user/components/Account.php (around line 295)
$rules = (new UserModel)->rules;
Which contains
plugins/winter/user/models/User.php
public $rules = [
'email' => 'required|between:6,255|email|unique:users',
...
];
but this should not ever happen because even though the user already exists and the e-mail is already taken, the e-mail can still be used to register the guest and claim the account in the process.