Skip to content

Commit

Permalink
feat: allow clearing Discord Connector oAuth Fields (#67)
Browse files Browse the repository at this point in the history
* If you clear all fields, reset the setting.

* Invert logic (woops!)
  • Loading branch information
tehraven authored Jan 26, 2022
1 parent 25ac988 commit 8eede36
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/Http/Controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
namespace Warlof\Seat\Connector\Drivers\Discord\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException;
use Laravel\Socialite\Facades\Socialite;
use Seat\Web\Http\Controllers\Controller;
use SocialiteProviders\Manager\Config;
Expand Down Expand Up @@ -51,15 +52,24 @@ class SettingsController extends Controller
* @param \Illuminate\Http\Request $request
* @return mixed
* @throws \Seat\Services\Exceptions\SettingException
* @throws \Illuminate\Validation\ValidationException
*/
public function store(Request $request)
{
$request->validate([
'client_id' => 'required|string',
'client_secret' => 'required|string',
'bot_token' => 'required|string',
'use_email_scope' => 'boolean',
]);
try {
$request->validate([
'client_id' => 'required|string',
'client_secret' => 'required|string',
'bot_token' => 'required|string',
'use_email_scope' => 'boolean',
]);
} catch(ValidationException $e) {
if ($request->anyFilled(['client_id', 'client_secret', 'bot_token'])) {
throw $e;
} else {
setting(['seat-connector.drivers.discord', null], true);
}
}

$settings = (object) [
'client_id' => $request->input('client_id'),
Expand Down

0 comments on commit 8eede36

Please sign in to comment.