| @@ 94-115 (lines=22) @@ | ||
| 91 | * @param Request $request |
|
| 92 | * @return \Illuminate\Response\RedirectResponse |
|
| 93 | */ |
|
| 94 | public function create(Request $request) |
|
| 95 | { |
|
| 96 | $repo = new ServiceRepository; |
|
| 97 | ||
| 98 | try { |
|
| 99 | $service = $repo->create($request->intersect([ |
|
| 100 | 'name', 'description', 'folder', 'startup', |
|
| 101 | ])); |
|
| 102 | Alert::success('Successfully created new service!')->flash(); |
|
| 103 | ||
| 104 | return redirect()->route('admin.services.view', $service->id); |
|
| 105 | } catch (DisplayValidationException $ex) { |
|
| 106 | return redirect()->route('admin.services.new')->withErrors(json_decode($ex->getMessage()))->withInput(); |
|
| 107 | } catch (DisplayException $ex) { |
|
| 108 | Alert::danger($ex->getMessage())->flash(); |
|
| 109 | } catch (\Exception $ex) { |
|
| 110 | Log::error($ex); |
|
| 111 | Alert::danger('An error occured while attempting to add a new service. This error has been logged.')->flash(); |
|
| 112 | } |
|
| 113 | ||
| 114 | return redirect()->route('admin.services.new')->withInput(); |
|
| 115 | } |
|
| 116 | ||
| 117 | /** |
|
| 118 | * Edits configuration for a specific service. |
|
| @@ 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 | { |
|