WemXPro / tracker

This repository is made to track bugs and suggestions in WemX
6 stars 4 forks source link

oAuth No lastname #447

Closed joti-prime closed 6 months ago

joti-prime commented 6 months ago

Describe the issue

Google oAuth doesn't give you a Last name, just implement this code:

$password = Str::random(16);

            // Split the full name into first name and last name
            $nameParts = explode(' ', $oauthUser->getName(), 2);
            $firstName = $nameParts[0];
            $lastName = isset($nameParts[1]) ? $nameParts[1] : $firstName;

            $user = User::create([
                'username' => $nickname,
                'email' => $oauthUser->getEmail(),
                'first_name' => $firstName,
                'last_name' => $lastName,
                'status' => 'active',
                'password' => Hash::make($password),
            ]);

Product Version

2.0.1

Pterodactyl Panel Version (if applicable)

No response

To Reproduce

No response

Expected Behaviour

No response

Screenshots

No response

Additional Information

No response

GIGABAIT93 commented 6 months ago

I don't quite understand what is not working. I know that some services do not provide a surname. But you can explain what is your error

joti-prime commented 6 months ago

In google oAuth google first name and last name are put as first name in wemx and last name it just leaves it blank (if google account have only first name also), then when creating a server (I use wisp) it requires a last name so it fails. The code above includes this fix checking the second argument and put it as last name if no last name is provided it just put the first name again.

GIGABAIT93 commented 6 months ago

ok i will fix it in next update