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

User is not redirected after authenticated. #47

Closed
qlur opened this issue Jul 23, 2022 · 1 comment
Closed

User is not redirected after authenticated. #47

qlur opened this issue Jul 23, 2022 · 1 comment

Comments

@qlur
Copy link

qlur commented Jul 23, 2022

I'm having issues trying to redirect user after successful login. Or even, just redirect to homepage(or anypage) on the apple callback post routes controller.

// web.php

Route::get('/redirect/apple', 'Auth\LoginController@redirectToApple');
Route::post('callback/apple', 'Auth\LoginController@handleAppleCallback');
// .env
SIGN_IN_WITH_APPLE_LOGIN=https://app.com/login/apple
SIGN_IN_WITH_APPLE_REDIRECT=https://app.com/callback/apple
//LoginController.php


	public function redirectToApple()
	{
//sucessfully redirects/prompts Sign in with Apple URL
return Socialite::driver("sign-in-with-apple")
				->scopes(["name", "email"])
				->redirect();

	}

public function handleAppleCallback(){
$user = Socialite::driver("sign-in-with-apple")->user();
//this $user has correct data as expected;

//HERE are some auth() codes that successfully logs in the user to app. 

//!!! THIS DOESN"T REDIRECT. RATHER REDIRECTS TO EMPTY PAGE ON /callback/apple. 
return redirect(url('/'));

}

Tried other ways to test like :

public function handleAppleCallback(){
$user = Socialite::driver("sign-in-with-apple")->user();

//This doesn't redirect either, but again $user has all data needed.
return redirect(url('/'));

I also created a common handleCallbackForLogins method, that handles every services I use. There, they are all able to redirect successfully but when the service is of apple, it just doesn't redirect. What could be the cause here?

Thanks!

@qlur
Copy link
Author

qlur commented Jul 23, 2022

Fixed. I was calling multiple methods within handleAppleCallback(). As a result I had to return from every method chain(total of 3 stack) as return redirect() didn't just redirect by itself.

@qlur qlur closed this as completed Jul 23, 2022
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