Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guest users are not working as expected #28

Open
AIC-BV opened this issue Feb 2, 2023 · 1 comment
Open

Guest users are not working as expected #28

AIC-BV opened this issue Feb 2, 2023 · 1 comment

Comments

@AIC-BV
Copy link
Contributor

AIC-BV commented Feb 2, 2023

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.

AIC-BV added a commit to AIC-BV/wn-user-plugin that referenced this issue Feb 3, 2023
remove unique:users onRegister to fix User guest accounts
See: wintercms#28
AIC-BV added a commit to AIC-BV/wn-user-plugin that referenced this issue Feb 3, 2023
remove unique:users onRegister to fix User guest accounts
See: wintercms#28
@AIC-BV AIC-BV mentioned this issue Feb 3, 2023
@AIC-BV
Copy link
Contributor Author

AIC-BV commented Apr 20, 2023

This is also a bug related to guest users
#35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant