1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Set first user to gmail after first authorization

This commit is contained in:
= 2021-03-23 17:19:06 +11:00
parent 3ed8479411
commit f74368e869

View File

@ -115,7 +115,6 @@ class ConnectedAccountController extends BaseController
$timeout = auth()->user()->company()->default_password_timeout;
Cache::put(auth()->user()->hashed_id.'_logged_in', Str::random(64), $timeout);
return $this->itemResponse(auth()->user());
}
@ -126,6 +125,8 @@ class ConnectedAccountController extends BaseController
->header('X-Api-Version', config('ninja.minimum_client_version'));
}
public function handleGmailOauth(Request $request)
{
@ -162,6 +163,8 @@ class ConnectedAccountController extends BaseController
auth()->user()->email_verified_at = now();
auth()->user()->save();
$this->activateGmail(auth()->user());
return $this->itemResponse(auth()->user());
}
@ -172,4 +175,19 @@ class ConnectedAccountController extends BaseController
->header('X-Api-Version', config('ninja.minimum_client_version'));
}
private function activateGmail(User $user)
{
$company = $user->company();
$settings = $company->settings;
if($settings->email_sending_method == 'default')
{
$settings->email_sending_method = 'gmail';
$settings->gmail_sending_user_id = (string)$user->hashed_id;
$company->settings = $settings;
$company->save();
}
}
}