Commit 6feef257 authored by Jacob Priddy's avatar Jacob Priddy 👌

added password setting/changing abilities for authenticated users

parent e9a08b97
......@@ -52,6 +52,38 @@ class MeController extends Controller
return view('doorcode', $presenter->getViewModel());
}
/**
* @return \Illuminate\View\View
*/
public function password(): View
{
return view('password');
}
/**
* @param \Source\UseCases\Users\UpdateUser\UpdateCurrentUser $userUpdate
* @return \Illuminate\View\View
* @throws \Illuminate\Validation\ValidationException
* @throws \Source\Exceptions\AuthorizationException
* @throws \Source\Exceptions\EntityExistsException
*/
public function passwordUpdate(UpdateCurrentUser $userUpdate): View
{
$this->validate($this->request, [
'password' => 'required|string|min:20|max:255',
]);
$presenter = new UpdateUserWebPresenter();
$userUpdate->update(
$this->authorizer->getCurrentUserId(),
['password' => $this->request->input('password')],
$presenter
);
return view('password', $presenter->getViewModel());
}
public function access(UserDoorAccessUseCase $userDoorAccessUseCase): View
{
}
......
......@@ -5,6 +5,7 @@
@section('content')
<div class="list-group">
<a class="list-group-item list-group-item-action" href="{{ route('web.doorcode') }}">Change Doorcode</a>
<a class="list-group-item list-group-item-action" href="{{ route('web.password') }}">Change Password</a>
<a class="list-group-item list-group-item-action" href="{{ route('web.access') }}">View Door Access</a>
<a class="list-group-item list-group-item-action" href="{{ route('web.tokens') }}">View API Tokens</a>
<a class="list-group-item list-group-item-action" href="{{ route('saml.logout') }}">Logout</a>
......
......@@ -34,6 +34,7 @@
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="{{ route('web.doorcode') }}">Change Doorcode</a>
<a class="dropdown-item" href="{{ route('web.password') }}">Change Password</a>
<a class="dropdown-item" href="{{ route('web.access') }}">View Access</a>
<a class="dropdown-item" href="{{ route('web.tokens') }}">View API Tokens</a>
<a class="dropdown-item" href="{{ route('saml.logout') }}">Logout</a>
......@@ -44,7 +45,7 @@
<main role="main" class="container">
<div>
<div class="page-header">
<div class="page-header text-center">
<h1> @yield('title') </h1>
</div>
@yield('content')
......
@extends('layouts.base')
@section('title', 'Change Password')
@section('content')
<div>
<p>
The password can be used for obtaining temporary API tokens, or logging into the application
via the API without going through ADFS. This will not affect logging in through ADFS.
</p>
@include('partials.form-errors')
@include('partials.message')
<form action="{{ route('web.password.change') }}" method="POST">
@csrf
<div class="form-group">
<label for="password">
Enter your new password here.
</label>
<input type="password" class="form-control" name="password" id="password" placeholder="Enter password">
</div>
<button type="submit" class="btn btn-primary">Change password</button>
</form>
</div>
@endsection
......@@ -17,5 +17,7 @@ use App\Http\Controllers\Web\MeController;
Route::get('/', [MeController::class, 'index'])->name('web.index');
Route::get('/door-code', [MeController::class, 'doorcode'])->name('web.doorcode');
Route::post('/door-code', [MeController::class, 'doorcodeUpdate'])->name('web.doorcode.change');
Route::get('/password', [MeController::class, 'password'])->name('web.password');
Route::post('/password', [MeController::class, 'passwordUpdate'])->name('web.password.change');
Route::get('/access', [MeController::class, 'access'])->name('web.access');
Route::get('/tokens', [MeController::class, 'tokens'])->name('web.tokens');
......@@ -12,7 +12,7 @@ class WebPresenter extends BasePresenter implements Presenter
public function present(ResponseModel $responseModel): void
{
$this->viewModel['error'] = $responseModel->hasError();
$this->viewModel['message'] = $responseModel->getError() ?: 'Successfully updated doorcode.';
$this->viewModel['message'] = $responseModel->getError() ?: 'Successfully updated user.';
}
/** @inheritDoc */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment