lundi 19 avril 2021

laravel manually login works, but after redirection to home page session is not working

i am using laravel version 8, i did single signon, i created EventServiceProvider , in this provide i did login by email data, i can see by Auth::check command login is working, but when it redirected to home page Auth::check doesn't work, can anyone please help me why i am getting this issue ? here i uploaded my code, can anyone please help me how to resolve this issue ?

class EventServiceProvider extends ServiceProvider
{
    protected $listen = [
        Registered::class => [
            SendEmailVerificationNotification::class,
        ],
    ];
    public function boot()
    {
        try{
            Event::listen('Aacotroneo\Saml2\Events\Saml2LoginEvent', function (Saml2LoginEvent $event) {
                $messageId = $event->getSaml2Auth()->getLastMessageId();
                $user = $event->getSaml2User();
                $userData = [
                    'id' => $user->getUserId(),
                    'attributes' => $user->getAttributes(),
                    'assertion' => $user->getRawSamlAssertion()
                ];
                $userInfo = User::where('email',$userData['id'])->first();
                if($userInfo) {
                    //$loggedInUser = Auth::loginUsingId($userInfo->id);
                    $loggedInUser = Auth::login($userInfo);
                }
            });
        } catch (\Throwable $e) {
            echo $e->getMessage(); die;
            report($e);
        }
    }
}


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire