Skip to content

Commit

Permalink
Feature/bootstrap and font awesome (#6)
Browse files Browse the repository at this point in the history
* Updates to frontendery

* wip

 M _docker/plugins/default-login.php
 M app/Models/Person.php
 M app/Models/Team.php
 M database/factories/TeamFactory.php
 M resources/views/layouts/app.blade.php
 M resources/views/team/index.blade.php
 M routes/auth.php
 M tests/Feature/Auth/PasswordUpdateTest.php

* additional frontendery

 M app/View/Components/Input.php
 M resources/views/components/input.blade.php
 M resources/views/layouts/app.blade.php
 M resources/views/team/index.blade.php

* Remove bootstrap JS and tailwind

* update nav

 M resources/views/layouts/navigation.blade.php

* Add option to just log in as a user locally without a password

* Add validationexception to throwing

* Update user id in sessions table

* class updates

 M resources/views/components/input.blade.php
 M resources/views/layouts/navigation.blade.php

* remove old nav

 M resources/views/layouts/navigation.blade.php

* wip

 M app/Http/Controllers/CompetitionController.php
 M app/Http/Controllers/GameController.php
 M app/Http/Controllers/PersonController.php
 M app/Http/Controllers/PositionController.php
 M app/Http/Controllers/SportController.php
 M app/Http/Controllers/TeamController.php
 M app/Models/Game.php
 M app/Models/Position.php
 M app/Providers/AppServiceProvider.php
 M database/factories/CompetitionFactory.php
 M database/factories/GameFactory.php
 M database/factories/PersonFactory.php
 M database/factories/PositionFactory.php
 M database/factories/SportFactory.php
 M database/factories/TeamFactory.php
 M resources/views/auth/login.blade.php
 M resources/views/competition/create.blade.php
 M resources/views/competition/edit.blade.php
 M resources/views/competition/index.blade.php
 M resources/views/game/create.blade.php
 M resources/views/game/edit.blade.php
 M resources/views/game/index.blade.php
 M resources/views/person/create.blade.php
 M resources/views/person/edit.blade.php
 M resources/views/position/create.blade.php
 M resources/views/position/edit.blade.php
 M resources/views/position/index.blade.php
 M resources/views/sport/index.blade.php
 M stubs/controller.model.stub

* testing and some binaries starting

 M app/Http/Controllers/Auth/AuthenticatedSessionController.php
 M app/Http/Controllers/LocalLoginAsUserController.php
 M app/Models/Game.php
 M app/Models/Position.php
 M app/Providers/AppServiceProvider.php
 M app/View/Components/Input.php
AM bin/util/exec
AM bin/util/install
 M composer.json
 M database/factories/PositionFactory.php
 M database/factories/SportFactory.php
 M database/migrations/0001_01_01_000000_create_users_table.php
 M routes/auth.php
?? .github/
?? bin/util/start

* make them executable

 M bin/util/exec
 M bin/util/install
 M bin/util/start

* remove -

 M bin/util/install

* missed a word

 M .github/workflows/testing.yaml

* amends for CI

 M app/Console/Commands/MakeEntity.php
 M app/Http/Controllers/Auth/ConfirmablePasswordController.php
 M app/Http/Controllers/Auth/EmailVerificationNotificationController.php
 M app/Http/Controllers/Auth/EmailVerificationPromptController.php
 M app/Http/Controllers/Auth/PasswordController.php
 M app/Http/Controllers/Auth/VerifyEmailController.php
 M app/Http/Controllers/LocalLoginAsUserController.php
 M app/Http/Controllers/ProfileController.php
 M app/Http/Requests/Auth/LoginRequest.php
 M app/Http/Requests/ProfileUpdateRequest.php
 M app/Models/Competition.php
 M app/Models/Game.php
 M app/Models/Person.php
 M app/Models/Position.php
 M app/Models/Sport.php
 M app/Models/Team.php
 M app/Models/User.php
 M app/View/Components/Input.php
 M composer.json
 M database/factories/PositionFactory.php

* amend model stub

 M stubs/model.stub
  • Loading branch information
GingertronMk1 authored Aug 18, 2024
1 parent 85102cb commit b8d0434
Show file tree
Hide file tree
Showing 69 changed files with 657 additions and 159 deletions.
20 changes: 20 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
time: "00:00"
timezone: "Europe/London"
open-pull-requests-limit: 10
commit-message:
prefix: "[DEPS][NPM]"
- package-ecosystem: composer
directory: "/"
schedule:
interval: daily
time: "00:00"
timezone: "Europe/London"
open-pull-requests-limit: 10
commit-message:
prefix: "[DEPS][COMPOSER]"
37 changes: 37 additions & 0 deletions .github/workflows/automerge-dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Auto-merge Dependabot PRs
on:
pull_request:
branches:
- main

permissions:
contents: write
pull-requests: write

jobs:
dependabot:
name: Auto-merge dependabot where appropriate
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/[email protected]
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Leave a comment with the metadata extracted
run: gh pr comment "$PR_URL" --body "Type is ${{steps.metadata.outputs.update-type}}"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Enable auto-merge for Dependabot PRs
if: |
endsWith(steps.metadata.outputs.update-type, 'semver-patch') ||
endsWith(steps.metadata.outputs.update-type, 'semver-minor')
run: |
gh pr comment "$PR_URL" --body "Merging" && \
gh pr review --approve "$PR_URL" && \
gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
44 changes: 44 additions & 0 deletions .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Testing

on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
testing:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache Composer
id: cache-composer
uses: actions/cache@v3
with:
path: vendor
key: ${{ hashFiles('composer.lock') }}
- name: Cache NPM
id: cache-npm
uses: actions/cache@v3
with:
path: node_modules
key: ${{ hashFiles('package-lock.json') }}
- name: Install
run: ./bin/util/install
- name: Start
run: ./bin/util/start
# - name: Deptrac
# run: ./_docker/bin/app/composer deptrac
# if: always()
- name: ECS
run: ./bin/util/exec app composer cs:check
if: always()
- name: Stan
run: ./bin/util/exec app composer stan
if: always()
# - name: PHPUnit
# run: ./_docker/bin/app/phpunit-with-coverage
# if: always()
2 changes: 1 addition & 1 deletion _docker/plugins/default-login.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function loginForm()
public function loginFormField(string $name, string $envValue = '', string $value = ''): string
{
$inputValue = $value;
if (! empty($envValue) && isset($_ENV[$envValue])) {
if (!empty($envValue) && isset($_ENV[$envValue])) {
$inputValue = $_ENV[$envValue];
}

Expand Down
3 changes: 3 additions & 0 deletions app/Console/Commands/MakeEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public function handle(): int
return self::SUCCESS;
}

/**
* @return array<string>
*/
private function getCrudOperations(): array
{
return [
Expand Down
3 changes: 3 additions & 0 deletions app/Http/Controllers/Auth/AuthenticatedSessionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\ValidationException;
use Illuminate\View\View;

class AuthenticatedSessionController extends Controller
Expand All @@ -21,6 +22,8 @@ public function create(): View

/**
* Handle an incoming authentication request.
*
* @throws ValidationException
*/
public function store(LoginRequest $request): RedirectResponse
{
Expand Down
6 changes: 6 additions & 0 deletions app/Http/Controllers/Auth/ConfirmablePasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ public function show(): View
*/
public function store(Request $request): RedirectResponse
{
if (!$request->user()) {
$request->session()->flash('status', __('auth.failed'));

return redirect()->route('login');
}

if (!Auth::guard('web')->validate([
'email' => $request->user()->email,
'password' => $request->password,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ class EmailVerificationNotificationController extends Controller
*/
public function store(Request $request): RedirectResponse
{
if (!$request->user()) {
$request->session()->flash('status', __('auth.failed'));

return redirect()->route('login');
}

if ($request->user()->hasVerifiedEmail()) {
return redirect()->intended(route('dashboard', absolute: false));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ class EmailVerificationPromptController extends Controller
*/
public function __invoke(Request $request): RedirectResponse|View
{
if (!$request->user()) {
$request->session()->flash('status', __('auth.failed'));

return redirect()->route('login');
}

return $request->user()->hasVerifiedEmail()
? redirect()->intended(route('dashboard', absolute: false))
: view('auth.verify-email');
Expand Down
6 changes: 6 additions & 0 deletions app/Http/Controllers/Auth/PasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ class PasswordController extends Controller
*/
public function update(Request $request): RedirectResponse
{
if (!$request->user()) {
$request->session()->flash('error', __('auth.failed'));

return redirect()->route('login');
}

$validated = $request->validateWithBag('updatePassword', [
'current_password' => ['required', 'current_password'],
'password' => ['required', Password::defaults(), 'confirmed'],
Expand Down
20 changes: 17 additions & 3 deletions app/Http/Controllers/Auth/VerifyEmailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Http\Controllers\Controller;
use Illuminate\Auth\Events\Verified;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\EmailVerificationRequest;
use Illuminate\Http\RedirectResponse;

Expand All @@ -14,12 +15,25 @@ class VerifyEmailController extends Controller
*/
public function __invoke(EmailVerificationRequest $request): RedirectResponse
{
if ($request->user()->hasVerifiedEmail()) {
$user = $request->user();
if (is_null($user)) {
$request->session()->flash('error', __('auth.failed'));

return redirect()->route('login');
}

if (!$user instanceof MustVerifyEmail) {
$request->session()->flash('error', __('auth.failed'));

return redirect()->route('dashboard');
}

if ($user->hasVerifiedEmail()) {
return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
}

if ($request->user()->markEmailAsVerified()) {
event(new Verified($request->user()));
if ($user->markEmailAsVerified()) {
event(new Verified($user));
}

return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/CompetitionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function index(): Application|Factory|View
return view(
'competition.index',
[
'competitions' => Competition::all(),
'competitions' => Competition::get(),
]
);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/GameController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function index(): Application|Factory|View
return view(
'game.index',
[
'games' => Game::all(),
'games' => Game::get(),
]
);
}
Expand Down
29 changes: 29 additions & 0 deletions app/Http/Controllers/LocalLoginAsUserController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Http\Controllers;

use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Symfony\Component\HttpFoundation\RedirectResponse;

class LocalLoginAsUserController extends Controller
{
/**
* Handle the incoming request.
*/
public function __invoke(Request $request): RedirectResponse
{
$userId = $request->input('user_id');
$user = User::find($userId);
if ($user instanceof User) {
Auth::login($user);

return to_route('dashboard');
}

$request->session()->flash('error', 'User not found');

return to_route('login');
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/PersonController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function index(): Application|Factory|View
return view(
'person.index',
[
'people' => Person::all(),
'people' => Person::get(),
]
);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/PositionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function index(): Application|Factory|View
return view(
'position.index',
[
'positions' => Position::all(),
'positions' => Position::get(),
]
);
}
Expand Down
8 changes: 8 additions & 0 deletions app/Http/Controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public function edit(Request $request): View
*/
public function update(ProfileUpdateRequest $request): RedirectResponse
{
if (!$request->user()) {
return redirect()->route('login');
}

$request->user()->fill($request->validated());

if ($request->user()->isDirty('email')) {
Expand All @@ -42,6 +46,10 @@ public function update(ProfileUpdateRequest $request): RedirectResponse
*/
public function destroy(Request $request): RedirectResponse
{
if (!$request->user()) {
return redirect()->route('login');
}

$request->validateWithBag('userDeletion', [
'password' => ['required', 'current_password'],
]);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/SportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function index(): Application|Factory|View
return view(
'sport.index',
[
'sports' => Sport::all(),
'sports' => Sport::get(),
]
);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/TeamController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function index(): Application|Factory|View
return view(
'team.index',
[
'teams' => Team::all(),
'teams' => Team::get(),
]
);
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Requests/Auth/LoginRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Requests\Auth;

use Illuminate\Auth\Events\Lockout;
use Illuminate\Contracts\Validation\Rule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\RateLimiter;
Expand All @@ -22,7 +23,7 @@ public function authorize(): bool
/**
* Get the validation rules that apply to the request.
*
* @return array<string, array|\Illuminate\Contracts\Validation\Rule|string>
* @return array<string, array<Rule|string>|Rule|string>
*/
public function rules(): array
{
Expand Down
11 changes: 9 additions & 2 deletions app/Http/Requests/ProfileUpdateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,20 @@ class ProfileUpdateRequest extends FormRequest
/**
* Get the validation rules that apply to the request.
*
* @return array<string, array|\Illuminate\Contracts\Validation\Rule|string>
* @return array<string, array<Rule|string>|Rule|string>
*/
public function rules(): array
{
return [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', Rule::unique(User::class)->ignore($this->user()->id)],
'email' => [
'required',
'string',
'lowercase',
'email',
'max:255',
Rule::unique(User::class)->ignore($this->user()?->id),
],
];
}
}
2 changes: 2 additions & 0 deletions app/Models/Competition.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

namespace App\Models;

use Database\Factories\CompetitionFactory;
use Illuminate\Database\Eloquent\Concerns\HasVersion7Uuids;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Competition extends Model
{
/** @use HasFactory<CompetitionFactory> */
use HasFactory;
use HasVersion7Uuids;
use SoftDeletes;
Expand Down
Loading

0 comments on commit b8d0434

Please sign in to comment.