Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
Doorcode
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Guardians of the Kretschmar Elock System
Doorcode
Commits
d5ed4b6a
Commit
d5ed4b6a
authored
Mar 01, 2020
by
Jacob Priddy
👌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't need to throw different authentication exception
parent
1b4497fa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
16 deletions
+15
-16
src/web/backend/app/Exceptions/Handler.php
src/web/backend/app/Exceptions/Handler.php
+14
-10
src/web/backend/app/Http/Controllers/AuthController.php
src/web/backend/app/Http/Controllers/AuthController.php
+1
-6
No files found.
src/web/backend/app/Exceptions/Handler.php
View file @
d5ed4b6a
...
...
@@ -10,7 +10,9 @@ use Illuminate\Auth\AuthenticationException;
use
Source\Exceptions\AuthorizationException
;
use
Source\Exceptions\EntityNotFoundException
;
use
Illuminate\Validation\ValidationException
;
use
Symfony\Component\HttpFoundation\Response
;
use
Illuminate\Foundation\Exceptions\Handler
as
ExceptionHandler
;
use
Source\Exceptions\AuthenticationException
as
SourceAuthenticationException
;
class
Handler
extends
ExceptionHandler
{
/**
...
...
@@ -21,6 +23,8 @@ class Handler extends ExceptionHandler {
protected
$dontReport
=
[
EntityNotFoundException
::
class
,
EntityExistsException
::
class
,
SourceAuthenticationException
::
class
,
AuthorizationException
::
class
,
];
/**
...
...
@@ -42,9 +46,9 @@ class Handler extends ExceptionHandler {
/**
* Render an exception into an HTTP response.
*
* @param Request
$request
* @param
\
Exception $exception
* @return
\Symfony\Component\HttpFoundation\
Response
* @param Request $request
* @param Exception $exception
* @return Response
* @throws Exception
*/
public
function
render
(
$request
,
Exception
$exception
)
{
...
...
@@ -55,7 +59,7 @@ class Handler extends ExceptionHandler {
return
$this
->
respondWithError
(
$exception
->
getMessage
(),
$exception
->
getCode
());
}
if
(
$exception
instanceof
\
Source\Exceptions\
AuthenticationException
)
{
if
(
$exception
instanceof
Source
AuthenticationException
)
{
return
response
()
->
json
([
'message'
=>
$exception
->
getMessage
()],
401
);
}
...
...
@@ -69,9 +73,9 @@ class Handler extends ExceptionHandler {
/**
* Convert an authentication exception into a response.
*
* @param
\Illuminate\Http\
Request $request
* @param
\Illuminate\Auth\
AuthenticationException $exception
* @return
\Symfony\Component\HttpFoundation\
Response
* @param Request $request
* @param AuthenticationException $exception
* @return Response
*/
protected
function
unauthenticated
(
$request
,
AuthenticationException
$exception
)
{
return
response
()
->
json
([
'message'
=>
$exception
->
getMessage
()],
401
);
...
...
@@ -80,9 +84,9 @@ class Handler extends ExceptionHandler {
/**
* Create a response object from the given validation exception.
*
* @param
\Illuminate\Validation\
ValidationException $e
* @param
\Illuminate\Http\Request
$request
* @return
\Symfony\Component\HttpFoundation\
Response
* @param ValidationException $e
* @param
Request
$request
* @return Response
*/
protected
function
convertValidationExceptionToResponse
(
ValidationException
$e
,
$request
)
{
if
(
$e
->
response
)
{
...
...
src/web/backend/app/Http/Controllers/AuthController.php
View file @
d5ed4b6a
...
...
@@ -7,7 +7,6 @@ use Illuminate\Cookie\CookieJar;
use
Illuminate\Http\JsonResponse
;
use
Illuminate\Http\RedirectResponse
;
use
Illuminate\Support\Facades\Cookie
;
use
Illuminate\Auth\AuthenticationException
;
use
Source\Exceptions\AuthenticationException
;
use
Source\Exceptions\EntityNotFoundException
;
use
Source\UseCases\Users\Authenticate\APIPresenter
;
...
...
@@ -33,11 +32,7 @@ class AuthController extends ApiController {
public
function
login
(
AuthenticateUseCase
$authenticateUseCase
):
JsonResponse
{
$presenter
=
new
APIPresenter
();
try
{
$authenticateUseCase
->
attempt
(
$presenter
,
$this
->
request
->
all
());
}
catch
(
AuthenticationException
$e
)
{
throw
new
AuthenticationException
();
}
$authenticateUseCase
->
attempt
(
$presenter
,
$this
->
request
->
all
());
return
$this
->
respondWithData
(
$presenter
->
getViewModel
())
->
withCookie
(
cookie
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment