feat(weeztix): auto company from OAuth, remove company UI
Store company_guid after OAuth via profile API; drop company select and companies endpoint. Coupons AJAX uses stored company only. Form request no longer accepts company fields from the browser. Made-with: Cursor
This commit is contained in:
@@ -13,6 +13,7 @@ use Illuminate\Support\Facades\Log;
|
||||
use InvalidArgumentException;
|
||||
use LogicException;
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
|
||||
final class WeeztixService
|
||||
{
|
||||
@@ -84,6 +85,42 @@ final class WeeztixService
|
||||
return $this->normalizeCompaniesFromProfile($json);
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist company_guid when still empty after OAuth (single company per page; chosen in Weeztix login).
|
||||
* Uses the first company returned from the user profile when several are present.
|
||||
*/
|
||||
public function ensureCompanyStoredFromWeeztix(): void
|
||||
{
|
||||
$this->config->refresh();
|
||||
|
||||
if (is_string($this->config->company_guid) && $this->config->company_guid !== '') {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$companies = $this->getCompanies();
|
||||
if ($companies === []) {
|
||||
Log::warning('Weeztix: geen bedrijf uit profiel voor automatische koppeling.', [
|
||||
'weeztix_config_id' => $this->config->id,
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$row = $companies[0];
|
||||
$this->config->update([
|
||||
'company_guid' => $row['guid'],
|
||||
'company_name' => $row['name'],
|
||||
]);
|
||||
$this->config->refresh();
|
||||
} catch (Throwable $e) {
|
||||
Log::warning('Weeztix: automatisch bedrijf vastleggen mislukt', [
|
||||
'weeztix_config_id' => $this->config->id,
|
||||
'message' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exchange OAuth authorization code for tokens (admin callback).
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user