Skip to content
This repository was archived by the owner on Jul 24, 2025. It is now read-only.
This repository was archived by the owner on Jul 24, 2025. It is now read-only.

Do we need this? #2

@nikolaynesov

Description

@nikolaynesov

Hey @websanova,

Why do we return this at all if oauth2 function already generates the url and makes the redirect without even touching the backend? Can we just check if the the code exists, parse the socialite user etc.
For ex.:

if (!$request->has('code')) {

            return response(['ErrorParsingAuthCode' => 'No callback code found'], 400);

        }

        $user = $this->userService->findOrCreate(
            $this->socialite->driver($provider)->stateless()->user()
        );

        if (!empty($user)) {

            if (!$token = JWTAuth::fromUser($user)) {
                throw new AuthorizationException;
            }

            return response([
                'msg' => 'Successfully logged in via ' . $provider . '.'
            ])->header('Authorization', $token);

        }

        return response(['ErrorGettingSocialUser' => 'There was an error getting the ' . $provider . ' user.'], 400);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions