Laravel login not work

I have a web app in laravel admin that was using eloquent authentication, I want to change the authentication to auth0.
I followed this guide https://auth0.com/docs/quickstart/webapp/laravel and the login it is working well to the auth0 session but it doesn`t login to my app.

This is what happen
-I see the button to login(added like the guide) and my old login.
-I login with auth0 authentication
-I see the logout button and my old login.

So I can login to my app just if I use my old login, it doesn`t login with the auth0 login.

Hi @Maxi,

Can you post the code associated with you auth0 implementation?

Thanks,
Dan

Hey Dan!

My code is like the guide, https://auth0.com/docs/quickstart/webapp/laravel

In web.php

Route::get( ‘/auth0/callback’, ‘\Auth0\Login\Auth0Controller@callback’ )->name( ‘auth0-callback’ );
Route::get( ‘/login’, ‘Auth\Auth0IndexController@login’ )->name( ‘login’ );
Route::get( ‘/auth/logout’, ‘Auth\Auth0IndexController@logout’ )->name( ‘logout’ )->middleware(‘auth’);

A controller

class Auth0IndexController extends Controller
{
/**
* Redirect to the Auth0 hosted login page
*
* @return mixed
*/
public function login()
{
$authorize_params = [
‘scope’ => ‘openid profile email’,
// Use the key below to get an access token for your API.
// ‘audience’ => config(‘laravel-auth0.api_identifier’),
];
return \App::make(‘auth0’)->login(null, null, $authorize_params);
}

/**
 * Log out of Auth0
 *
 * @return mixed
 */
public function logout()
{
    \Auth::logout();
    $logoutUrl = sprintf(
        'https://%s/v2/logout?client_id=%s&returnTo=%s',
        env('AUTH0_DOMAIN'),
        env('AUTH0_CLIENT_ID'),
        env('APP_URL'));
    return  \Redirect::intended($logoutUrl);
}

}

In auth.php, I change the eloquent driver for

‘providers’ => [
‘users’ => [
‘driver’ => ‘auth0’
],
],

but I also have an admin.php where I have a driver and says eloquent,

‘providers’ => [
‘admin’ => [
‘driver’ => ‘eloquent’,
//‘driver’ => ‘auth0’,
‘model’ => App\Models\Administrator::class,
],

If I change for auth0 like commented, the old login doesn`t work.

And the register in appserviceprovder that use my own CustomUserRepository .

thanks!

Are you getting any errors? I think I might need more clarification on the problem. Can you DM me a har file and your tenant name.

1 Like

So you are having a successful login according to your logs. What behavior are you seeing when you say:

1 Like