Commit 29eee4a8 authored by Jacob Priddy's avatar Jacob Priddy 👌
Browse files

style changes fixing exceptions idk lots of stuff. New image assets

parent b12df85c
...@@ -20,3 +20,5 @@ DB_PASSWORD=secret ...@@ -20,3 +20,5 @@ DB_PASSWORD=secret
SAML_SIMPLESAMLPHP_AUTOLOAD=/var/simplesamlphp/lib/_autoload.php SAML_SIMPLESAMLPHP_AUTOLOAD=/var/simplesamlphp/lib/_autoload.php
SAML_SIMPLESAMLPHP_AUTH_SOURCE=default-sp SAML_SIMPLESAMLPHP_AUTH_SOURCE=default-sp
FRONTEND_URL=https://localhost:8080 FRONTEND_URL=https://localhost:8080
SUPPORT_EMAIL=elock@persignum.com
...@@ -10,6 +10,7 @@ use Source\Exceptions\EntityExistsException; ...@@ -10,6 +10,7 @@ use Source\Exceptions\EntityExistsException;
use Source\Exceptions\AuthorizationException; use Source\Exceptions\AuthorizationException;
use Source\Exceptions\EntityNotFoundException; use Source\Exceptions\EntityNotFoundException;
use Source\UseCases\Door\ScheduleEvents\JsonPresenter; use Source\UseCases\Door\ScheduleEvents\JsonPresenter;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Source\UseCases\Door\ScheduleEvents\ScheduleEventsUseCase; use Source\UseCases\Door\ScheduleEvents\ScheduleEventsUseCase;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Source\Exceptions\AuthenticationException as SourceAuthenticationException; use Source\Exceptions\AuthenticationException as SourceAuthenticationException;
...@@ -81,6 +82,13 @@ class Handler extends ExceptionHandler ...@@ -81,6 +82,13 @@ class Handler extends ExceptionHandler
} }
} }
if ($e instanceof EntityNotFoundException ||
$e instanceof SourceAuthenticationException ||
$e instanceof AuthorizationException ||
$e instanceof EntityExistsException) {
throw new HttpException($e->getCode(), $e->getMessage());
}
return parent::render($request, $e); return parent::render($request, $e);
} }
} }
...@@ -6,6 +6,8 @@ namespace App\Http\Controllers\Web\Admin; ...@@ -6,6 +6,8 @@ namespace App\Http\Controllers\Web\Admin;
use Illuminate\View\View; use Illuminate\View\View;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Source\Exceptions\EntityExistsException;
use Illuminate\Validation\ValidationException;
use Source\UseCases\Doors\GetDoor\GetDoorUseCase; use Source\UseCases\Doors\GetDoor\GetDoorUseCase;
use Source\UseCases\Doors\GetDoors\GetDoorsUseCase; use Source\UseCases\Doors\GetDoors\GetDoorsUseCase;
use Source\UseCases\Groups\GetGroups\GetGroupsUseCase; use Source\UseCases\Groups\GetGroups\GetGroupsUseCase;
...@@ -73,7 +75,6 @@ class DoorsController extends Controller ...@@ -73,7 +75,6 @@ class DoorsController extends Controller
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Validation\ValidationException * @throws \Illuminate\Validation\ValidationException
* @throws \Source\Exceptions\EntityNotFoundException * @throws \Source\Exceptions\EntityNotFoundException
* @throws \Source\Exceptions\EntityExistsException
*/ */
public function update(string $doorId, UpdateDoorUseCase $updateDoor): RedirectResponse public function update(string $doorId, UpdateDoorUseCase $updateDoor): RedirectResponse
{ {
...@@ -83,7 +84,11 @@ class DoorsController extends Controller ...@@ -83,7 +84,11 @@ class DoorsController extends Controller
]); ]);
$presenter = new UpdateDoorPresenter(); $presenter = new UpdateDoorPresenter();
$updateDoor->update($doorId, $this->request->all(), $presenter); try {
$updateDoor->update($doorId, $this->request->all(), $presenter);
} catch (EntityExistsException $e) {
throw ValidationException::withMessages(['errors' => $e->getMessage()]);
}
return redirect(route('web.admin.doors.index'))->with($presenter->getViewModel()); return redirect(route('web.admin.doors.index'))->with($presenter->getViewModel());
} }
...@@ -92,7 +97,6 @@ class DoorsController extends Controller ...@@ -92,7 +97,6 @@ class DoorsController extends Controller
* @param \Source\UseCases\Doors\CreateDoor\CreateDoorUseCase $createDoor * @param \Source\UseCases\Doors\CreateDoor\CreateDoorUseCase $createDoor
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Validation\ValidationException * @throws \Illuminate\Validation\ValidationException
* @throws \Source\Exceptions\EntityExistsException
*/ */
public function store(CreateDoorUseCase $createDoor): RedirectResponse public function store(CreateDoorUseCase $createDoor): RedirectResponse
{ {
...@@ -103,7 +107,11 @@ class DoorsController extends Controller ...@@ -103,7 +107,11 @@ class DoorsController extends Controller
$presenter = new CreateDoorPresenter(); $presenter = new CreateDoorPresenter();
$createDoor->create($this->request->all(), $presenter); try {
$createDoor->create($this->request->all(), $presenter);
} catch (EntityExistsException $e) {
throw ValidationException::withMessages(['errors' => $e->getMessage()]);
}
return redirect(route('web.admin.doors.index'))->with($presenter->getViewModel()); return redirect(route('web.admin.doors.index'))->with($presenter->getViewModel());
} }
...@@ -127,14 +135,18 @@ class DoorsController extends Controller ...@@ -127,14 +135,18 @@ class DoorsController extends Controller
* @param string $doorId * @param string $doorId
* @param \Source\UseCases\Doors\GenerateDoorToken\GenerateDoorTokenUseCase $tokenGenerator * @param \Source\UseCases\Doors\GenerateDoorToken\GenerateDoorTokenUseCase $tokenGenerator
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \Source\Exceptions\EntityExistsException
* @throws \Source\Exceptions\EntityNotFoundException * @throws \Source\Exceptions\EntityNotFoundException
* @throws \Illuminate\Validation\ValidationException
*/ */
public function regenerateToken(string $doorId, GenerateDoorTokenUseCase $tokenGenerator): RedirectResponse public function regenerateToken(string $doorId, GenerateDoorTokenUseCase $tokenGenerator): RedirectResponse
{ {
$presenter = new WebTokenGeneratePresenter(); $presenter = new WebTokenGeneratePresenter();
$tokenGenerator->generate($doorId, $presenter); try {
$tokenGenerator->generate($doorId, $presenter);
} catch (EntityExistsException $e) {
throw ValidationException::withMessages(['error' => 'Please re-perform this action. ' . $e->getMessage()]);
}
return redirect()->back()->with($presenter->getViewModel()); return redirect()->back()->with($presenter->getViewModel());
} }
......
...@@ -6,7 +6,9 @@ use Illuminate\View\View; ...@@ -6,7 +6,9 @@ use Illuminate\View\View;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Source\Exceptions\DeleteFailedException; use Source\Exceptions\DeleteFailedException;
use Source\Exceptions\EntityExistsException;
use Source\Exceptions\AuthorizationException; use Source\Exceptions\AuthorizationException;
use Illuminate\Validation\ValidationException;
use Source\UseCases\Users\GetUser\GetUserUseCase; use Source\UseCases\Users\GetUser\GetUserUseCase;
use Source\UseCases\Doors\GetDoors\GetDoorsUseCase; use Source\UseCases\Doors\GetDoors\GetDoorsUseCase;
use Source\UseCases\Users\GetUsers\GetUsersUseCase; use Source\UseCases\Users\GetUsers\GetUsersUseCase;
...@@ -52,7 +54,6 @@ class UsersController extends Controller ...@@ -52,7 +54,6 @@ class UsersController extends Controller
* @param \Source\UseCases\Users\CreateUser\CreateUserUseCase $createUser * @param \Source\UseCases\Users\CreateUser\CreateUserUseCase $createUser
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Validation\ValidationException * @throws \Illuminate\Validation\ValidationException
* @throws \Source\Exceptions\EntityExistsException
*/ */
public function store(CreateUserUseCase $createUser): RedirectResponse public function store(CreateUserUseCase $createUser): RedirectResponse
{ {
...@@ -69,7 +70,11 @@ class UsersController extends Controller ...@@ -69,7 +70,11 @@ class UsersController extends Controller
$presenter = new CreateUserPresenter(); $presenter = new CreateUserPresenter();
$createUser->create($this->request->all(), $presenter); try {
$createUser->create($this->request->all(), $presenter);
} catch (EntityExistsException $e) {
throw ValidationException::withMessages(['error' => $e->getMessage()]);
}
return redirect(route('web.admin.users.index'))->with($presenter->getViewModel()); return redirect(route('web.admin.users.index'))->with($presenter->getViewModel());
} }
...@@ -98,7 +103,6 @@ class UsersController extends Controller ...@@ -98,7 +103,6 @@ class UsersController extends Controller
* @param \Source\UseCases\Users\UpdateUser\UpdateUserUseCase $updateUser * @param \Source\UseCases\Users\UpdateUser\UpdateUserUseCase $updateUser
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Validation\ValidationException * @throws \Illuminate\Validation\ValidationException
* @throws \Source\Exceptions\EntityExistsException
*/ */
public function update(string $userId, UpdateUserUseCase $updateUser): RedirectResponse public function update(string $userId, UpdateUserUseCase $updateUser): RedirectResponse
{ {
...@@ -118,7 +122,7 @@ class UsersController extends Controller ...@@ -118,7 +122,7 @@ class UsersController extends Controller
try { try {
$updateUser->update($userId, $this->request->all(), $presenter); $updateUser->update($userId, $this->request->all(), $presenter);
} catch (AuthorizationException $e) { } catch (AuthorizationException $e) {
return redirect()->back()->with(['error' => $e->getMessage()]); throw ValidationException::withMessages(['error' => $e->getMessage()]);
} }
return redirect(route('web.admin.users.index'))->with($presenter->getViewModel()); return redirect(route('web.admin.users.index'))->with($presenter->getViewModel());
......
...@@ -31,7 +31,6 @@ class MeController extends Controller ...@@ -31,7 +31,6 @@ class MeController extends Controller
* @return \Illuminate\View\View * @return \Illuminate\View\View
* @throws \Illuminate\Validation\ValidationException * @throws \Illuminate\Validation\ValidationException
* @throws \Source\Exceptions\AuthorizationException * @throws \Source\Exceptions\AuthorizationException
* @throws \Source\Exceptions\EntityExistsException
*/ */
public function doorcodeUpdate(UpdateCurrentUser $userUpdate): View public function doorcodeUpdate(UpdateCurrentUser $userUpdate): View
{ {
...@@ -55,7 +54,6 @@ class MeController extends Controller ...@@ -55,7 +54,6 @@ class MeController extends Controller
* @return \Illuminate\View\View * @return \Illuminate\View\View
* @throws \Illuminate\Validation\ValidationException * @throws \Illuminate\Validation\ValidationException
* @throws \Source\Exceptions\AuthorizationException * @throws \Source\Exceptions\AuthorizationException
* @throws \Source\Exceptions\EntityExistsException
*/ */
public function passwordUpdate(UpdateCurrentUser $userUpdate): View public function passwordUpdate(UpdateCurrentUser $userUpdate): View
{ {
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
</div> </div>
<div class="form-group col-3"> <div class="form-group col-3">
<button id="submitDoorId" type="submit" class="btn btn-primary">View Access</button> <button id="submitDoorId" type="submit" class="btn btn-primary">View Access</button>
<a href="{{ route('web.requests.build') }}" class="btn btn-success">Request Door Access</a> <a href="{{ route('web.requests.build') }}" class="btn btn-secondary">Request Door Access</a>
</div> </div>
</div> </div>
</form> </form>
......
@extends('layouts.admin') @extends('layouts.admin')
@section('main-content') @section('title', 'About')
<!-- Page Heading -->
<h1 class="h3 mb-4 text-gray-800">{{ __('About') }}</h1>
@section('main-content')
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col-lg-8"> <div class="col-lg-8">
<div class="card shadow mb-4"> <div class="card shadow mb-4">
<div class="card-profile-image mt-4"> {{-- <div class="card-profile-image mt-4">--}}
<img src="{{ asset('img/favicon.png') }}" class="rounded-circle" alt="user-image"> {{-- <img src="{{ asset('img/favicon.png') }}" class="rounded-circle" alt="user-image">--}}
</div> {{-- </div>--}}
<div class="card-body"> <div class="card-body">
<div class="row"> <div class="row">
<div class="col-lg-12 mb-1"> <div class="col-lg-12 mb-1">
<div class="text-center"> <div class="text-center">
<h5 class="font-weight-bold">Alejandro RH</h5> <h5 class="font-weight-bold">E-Lock/Doorcode</h5>
</div> </div>
</div> </div>
</div> </div>
<hr>
<div class="row"> <div class="row">
<div class="col-md-4 mb-1 text-center"> <div class="col-lg-12">
<a href="https://facebook.com/aleckrh" target="_blank" class="btn btn-facebook btn-circle btn-lg"><i class="fab fa-facebook-f fa-fw"></i></a> <h5 class="font-weight-bold">General Information</h5>
</div> <p>
<div class="col-md-4 mb-1 text-center"> The E-Lock system controls access to all the doors with keypads in Kretschmar Hall and
<a href="https://github.com/aleckrh" target="_blank" class="btn btn-github btn-circle btn-lg"><i class="fab fa-github fa-fw"></i></a> Chan Shun Pavilion at Walla Walla University. It allows students and faculty to manage
</div> their own door code to enter doors, as well as shows users what doors they have access
<div class="col-md-4 mb-1 text-center"> to and when. It has an API to allow users a nice programmatic interface for the system.
<a href="https://twitter.com/aleckrh" target="_blank" class="btn btn-twitter btn-circle btn-lg"><i class="fab fa-twitter fa-fw"></i></a> It also allows administrators to manage the door system in the building.
</p>
</div> </div>
</div> </div>
...@@ -40,12 +42,15 @@ ...@@ -40,12 +42,15 @@
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-12">
<h5 class="font-weight-bold">Laravel SB Admin 2</h5> <h5 class="font-weight-bold">Support</h5>
<p>SB Admin 2 for Laravel.</p> <p>
<p>Recommend to install this preset on a project that you are starting from scratch, otherwise your project's design might break.</p> The creator (JD), is available for support and fixing bugs. Please post any bugs as
<a href="https://github.com/aleckrh/laravel-sb-admin-2" target="_blank" class="btn btn-github"> issues onto the
<i class="fab fa-github fa-fw"></i> Go to repository <a href="https://gitlab.cs.wallawalla.edu/elock" target="_blank">GitLab</a> repository.
</a> He will get to them if he sees them. Alternatively you can also shoot an email to
<a href="mailto:{{env('SUPPORT_EMAIL', 'blank')}}">{{ env('SUPPORT_EMAIL', '(You can\'t because no support email is configured)') }}</a>
for any questions, concerns, or for faster response time on bug fixes.
</p>
</div> </div>
</div> </div>
...@@ -54,20 +59,16 @@ ...@@ -54,20 +59,16 @@
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-12">
<h5 class="font-weight-bold">Credits</h5> <h5 class="font-weight-bold">Credits</h5>
<p>Laravel SB Admin 2 uses some open-source third-party libraries/packages, many thanks to the web community.</p> <p>The E-Lock system was written by Jacob Priddy, a 2020 EE and CS graduate.</p>
<ul> <ul>
<li><a href="https://laravel.com" target="_blank">Laravel</a> - Open source framework.</li> <li><a href="https://gitlab.cs.wallawalla.edu/elock" target="_blank">GitLab</a> - Source code for the project.</li>
<li><a href="https://github.com/DevMarketer/LaravelEasyNav" target="_blank">LaravelEasyNav</a> - Making managing navigation in Laravel easy.</li>
<li><a href="https://startbootstrap.com/themes/sb-admin-2" target="_blank">SB Admin 2</a> - Thanks to Start Bootstrap.</li> <li><a href="https://startbootstrap.com/themes/sb-admin-2" target="_blank">SB Admin 2</a> - Thanks to Start Bootstrap.</li>
<li><a href="https://laravel.com" target="_blank">Laravel</a> - Open source framework.</li>
</ul> </ul>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
@endsection @endsection
...@@ -7,26 +7,26 @@ ...@@ -7,26 +7,26 @@
]) ])
@section('filters') @section('filters')
<div class="form-inline col-sm-12 col-md-6 col-xl-3"> <div class="form-inline col-sm-12 col-md-6 col-xl-3 text-center mb-3 mb-md-0">
<label for="doorId"> <label for="doorId">
Door ID: Door ID:
</label> </label>
<input type="number" name="door_id" id="doorId" class="form-control" value="{{ request('door_id') }}"> <input type="number" name="door_id" id="doorId" class="form-control" value="{{ request('door_id') }}">
</div> </div>
<div class="form-inline col-sm-12 col-md-6 col-xl-3"> <div class="form-inline col-sm-12 col-md-6 col-xl-3 text-center mb-3 mb-md-0">
<label for="start"> <label for="start">
Start: Start:
</label> </label>
<input type="date" name="start" id="start" class="form-control" value="{{ request('start') }}"> <input type="date" name="start" id="start" class="form-control" value="{{ request('start') }}">
</div> </div>
<div class="form-inline col-sm-12 col-md-6 col-xl-3"> <div class="form-inline col-sm-12 col-md-6 col-xl-3 text-center mb-3 mb-md-0">
<label for="end"> <label for="end">
End: End:
</label> </label>
<input type="date" name="end" id="end" class="form-control" value="{{ request('end') }}"> <input type="date" name="end" id="end" class="form-control" value="{{ request('end') }}">
</div> </div>
<div class="col-sm-12 col-md-6 col-xl-3"> <div class="col-sm-12 col-md-6 col-xl-3 text-center">
<input class="btn btn-primary" type="submit" value="Filter"> <input class="btn btn-primary" type="submit" value="Filter">
</div> </div>
@endsection @endsection
......
...@@ -8,21 +8,21 @@ ...@@ -8,21 +8,21 @@
]) ])
@section('filters') @section('filters')
<div class="col-sm-12 col-md-6 col-xl-3 text-center"> <div class="col-sm-12 col-md-6 col-xl-3 text-center mb-3">
<label class="sr-only" for="query"> <label class="sr-only" for="query">
Search Search
</label> </label>
<input id="query" type="text" name="query" placeholder="Search" <input id="query" type="text" name="query" placeholder="Search"
value="{{ request('query') }}"> value="{{ request('query') }}">
</div> </div>
<div class="col-sm-12 col-md-4 col-xl-2 text-center"> <div class="col-sm-12 col-md-4 col-xl-2 text-center mb-3">
<label class="sr-only" for="query"> <label class="sr-only" for="query">
Seen within seconds. Seen within seconds.
</label> </label>
<input id="query" type="number" name="active_seconds" placeholder="Seen within (seconds)" <input id="query" type="number" name="active_seconds" placeholder="Seen within (seconds)"
value="{{ request('active_seconds') }}"> value="{{ request('active_seconds') }}">
</div> </div>
<div class="col-sm-12 col-md-4 col-xl-2 text-center"> <div class="col-sm-12 col-md-4 col-xl-2 text-center mb-3">
<label class="sr-only" for="query"> <label class="sr-only" for="query">
Not seen since in seconds. Not seen since in seconds.
</label> </label>
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
</h1> </h1>
</div> </div>
<div class="col-md-4 col-sm-12 text-center"> <div class="col-md-4 col-sm-12 text-center">
<a href="{{ url()->previous() }}" class="btn btn-primary btn-lg"> <a href="javascript:history.back()" class="btn btn-primary btn-lg">
Back Back
</a> </a>
</div> </div>
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
</h1> </h1>
</div> </div>
<div class="col-md-4 col-sm-12 text-center"> <div class="col-md-4 col-sm-12 text-center">
<a href="{{ url()->previous() }}" class="btn btn-primary btn-lg"> <a href="javascript:history.back()" class="btn btn-primary btn-lg">
Back Back
</a> </a>
</div> </div>
......
...@@ -7,32 +7,32 @@ ...@@ -7,32 +7,32 @@
]) ])
@section('filters') @section('filters')
<div class="form-inline col-sm-12 col-md-6 col-xl-3"> <div class="form-inline col-sm-12 col-md-6 col-xl-3 text-center mb-3 mb-md-0">
<label for="userId"> <label for="userId">
User ID: User ID:
</label> </label>
<input type="number" name="user_id" id="userId" class="form-control" value="{{ request('user_id') }}"> <input type="number" name="user_id" id="userId" class="form-control" value="{{ request('user_id') }}">
</div> </div>
<div class="form-inline col-sm-12 col-md-6 col-xl-3"> <div class="form-inline col-sm-12 col-md-6 col-xl-3 text-center mb-3 mb-md-0">
<label for="doorId"> <label for="doorId">
Door ID: Door ID:
</label> </label>
<input type="number" name="door_id" id="doorId" class="form-control" value="{{ request('door_id') }}"> <input type="number" name="door_id" id="doorId" class="form-control" value="{{ request('door_id') }}">
</div> </div>
<div class="form-inline col-sm-12 col-md-6 col-xl-3"> <div class="form-inline col-sm-12 col-md-6 col-xl-3 text-center mb-3 mb-md-0">
<label for="start"> <label for="start">
Start: Start:
</label> </label>
<input type="date" name="start" id="start" class="form-control" value="{{ request('start') }}"> <input type="date" name="start" id="start" class="form-control" value="{{ request('start') }}">
</div> </div>
<div class="form-inline col-sm-12 col-md-6 col-xl-3"> <div class="form-inline col-sm-12 col-md-6 col-xl-3 text-center mb-3 mb-md-0">
<label for="end"> <label for="end">
End: End:
</label> </label>
<input type="date" name="end" id="end" class="form-control" value="{{ request('end') }}"> <input type="date" name="end" id="end" class="form-control" value="{{ request('end') }}">
</div> </div>
<div class="col-sm-12 col-md-6 col-xl-3"> <div class="col-sm-12 col-md-6 col-xl-3 text-center">
<input class="btn btn-primary" type="submit" value="Filter"> <input class="btn btn-primary" type="submit" value="Filter">
</div> </div>