Try and get error messages working again

This commit is contained in:
Jonny Barnes 2017-02-24 15:15:58 +00:00
parent 70d17006dd
commit 32b5b057fa
2 changed files with 8 additions and 12 deletions

View file

@ -62,7 +62,7 @@ class MicropubClientController extends Controller
$this->indieClient
);
if (! $micropubEndpoint) {
return redirect(route('micropub-client'))->withErrors('Unable to determine micropub API endpoint', 'endpoint');
return redirect(route('micropub-client'))->with('error', 'Unable to determine micropub API endpoint');
}
$response = $this->postNoteRequest($request, $micropubEndpoint, $token);
@ -76,7 +76,7 @@ class MicropubClientController extends Controller
return redirect($location);
}
return redirect(route('micropub-client'))->withErrors('Endpoint didnt create the note.', 'endpoint');
return redirect(route('micropub-client'))->with('error', 'Endpoint didnt create the note.');
}
/**
@ -95,7 +95,7 @@ class MicropubClientController extends Controller
$token = $request->session()->get('token');
$micropubEndpoint = $this->indieAuthService->discoverMicropubEndpoint($domain, $this->indieClient);
if (! $micropubEndpoint) {
return redirect(route('micropub-client'))->withErrors('Unable to determine micropub API endpoint', 'endpoint');
return redirect(route('micropub-client'))->with('error', 'Unable to determine micropub API endpoint');
}
try {
@ -104,7 +104,7 @@ class MicropubClientController extends Controller
'query' => ['q' => 'syndicate-to'],
]);
} catch (\GuzzleHttp\Exception\BadResponseException $e) {
return redirect(route('micropub-client'))->withErrors('Bad response when refreshing syndication targets', 'endpoint');
return redirect(route('micropub-client'))->with('error', 'Bad response when refreshing syndication targets');
}
$body = (string) $response->getBody();
$syndication = $this->parseSyndicationTargets($body);
@ -178,8 +178,7 @@ class MicropubClientController extends Controller
'headers' => $headers,
]);
} catch (\GuzzleHttp\Exception\BadResponseException $e) {
return redirect(route('micropub-client'))
->withErrors('There was a bad response from the micropub endpoint.', 'endpoint');
return redirect(route('micropub-client'))->with('error', 'There was a bad response from the micropub endpoint.');
}
return $response;

View file

@ -5,13 +5,10 @@ New Note «
@stop
@section('content')
@if (session('error'))
<p class="error">{{ session('error') }}</p>
@endif
<p>This is my UI for posting new notes, hopefully youll soon be able to use this if your site supports the micropub API.</p>
@if($errors->endpoint->first() != '')
<p class="error">{{ $errors->endpoint->first() }}</p>
@endif
@if($errors->indieauth->first() != '')
<p class="error">{{ $errors->indieauth->first() }}</p>
@endif
@if($url === null)
<form action="{{ route('indieauth-start') }}" method="post">
<input type="hidden" name="_token" value="{{ csrf_token() }}">