first commit
Some checks failed
Build / run (push) Has been cancelled

This commit is contained in:
maher
2025-10-29 11:42:25 +01:00
commit 703f50a09d
4595 changed files with 385164 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
<?php
namespace Common\Settings\Mail;
use Common\Auth\Oauth;
use Illuminate\Contracts\View\View as ViewContract;
use Illuminate\Support\Facades\File;
use Laravel\Socialite\Facades\Socialite;
class HandleConnectGmailOauthCallback
{
public function execute(string $provider): ViewContract
{
$profile = Socialite::with('google')->user();
File::ensureDirectoryExists(dirname(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 (settings('incoming_email.gmail.enabled')) {
(new GmailClient())->watch();
}
return (new Oauth())->getPopupResponse('SUCCESS', [
'profile' => $profile,
]);
}
}