| @@ 51-72 (lines=22) @@ | ||
| 48 | return view('base.api.new'); |
|
| 49 | } |
|
| 50 | ||
| 51 | public function save(Request $request) |
|
| 52 | { |
|
| 53 | try { |
|
| 54 | $repo = new APIRepository($request->user()); |
|
| 55 | $secret = $repo->create($request->only([ |
|
| 56 | 'memo', 'allowed_ips', |
|
| 57 | 'adminPermissions', 'permissions', |
|
| 58 | ])); |
|
| 59 | Alert::success('An API Key-Pair has successfully been generated. The API secret for this public key is shown below and will not be shown again.<br /><br /><code>' . $secret . '</code>')->flash(); |
|
| 60 | ||
| 61 | return redirect()->route('account.api'); |
|
| 62 | } catch (DisplayValidationException $ex) { |
|
| 63 | return redirect()->route('account.api.new')->withErrors(json_decode($ex->getMessage()))->withInput(); |
|
| 64 | } catch (DisplayException $ex) { |
|
| 65 | Alert::danger($ex->getMessage())->flash(); |
|
| 66 | } catch (\Exception $ex) { |
|
| 67 | Log::error($ex); |
|
| 68 | Alert::danger('An unhandled exception occured while attempting to add this API key.')->flash(); |
|
| 69 | } |
|
| 70 | ||
| 71 | return redirect()->route('account.api.new')->withInput(); |
|
| 72 | } |
|
| 73 | ||
| 74 | public function revoke(Request $request, $key) |
|
| 75 | { |
|
| @@ 56-77 (lines=22) @@ | ||
| 53 | return view('admin.services.new'); |
|
| 54 | } |
|
| 55 | ||
| 56 | public function postNew(Request $request) |
|
| 57 | { |
|
| 58 | try { |
|
| 59 | $repo = new ServiceRepository\Service; |
|
| 60 | $service = $repo->create($request->only([ |
|
| 61 | 'name', 'description', 'file', |
|
| 62 | 'executable', 'startup', |
|
| 63 | ])); |
|
| 64 | Alert::success('Successfully created new service!')->flash(); |
|
| 65 | ||
| 66 | return redirect()->route('admin.services.service', $service->id); |
|
| 67 | } catch (DisplayValidationException $ex) { |
|
| 68 | return redirect()->route('admin.services.new')->withErrors(json_decode($ex->getMessage()))->withInput(); |
|
| 69 | } catch (DisplayException $ex) { |
|
| 70 | Alert::danger($ex->getMessage())->flash(); |
|
| 71 | } catch (\Exception $ex) { |
|
| 72 | Log::error($ex); |
|
| 73 | Alert::danger('An error occured while attempting to add a new service.')->flash(); |
|
| 74 | } |
|
| 75 | ||
| 76 | return redirect()->route('admin.services.new')->withInput(); |
|
| 77 | } |
|
| 78 | ||
| 79 | public function getService(Request $request, $service) |
|
| 80 | { |
|