Compare commits

..
2 Commits
Author SHA1 Message Date
nilsandopenhands 7545873aec Replace Laravel boilerplate with German project README
Co-authored-by: openhands <openhands@all-hands.dev>
2026-11-30 00:26:44 +01:00
nilsandopenhands af044ab501 Protect application form management with organizer login
Co-authored-by: openhands <openhands@all-hands.dev>
2026-11-30 00:20:44 +01:00
12 changed files with 250 additions and 85 deletions

No files matched your search

+37 -44
View File
@@ -1,61 +1,54 @@
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
# Bandtool v2
<p align="center">
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>
Bandtool v2 ist eine Webanwendung für Mukke SHG e. V. Das Orga-Team kann für Veranstaltungen Bewerbungsrunden anlegen und festlegen, welches Formular für Bands geöffnet ist. Bands brauchen kein Konto, um ein öffentliches Formular aufzurufen.
## About Laravel
## Aktueller Stand
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- **Für das Orga-Team:** Bewerbungsrunden anlegen, bearbeiten, aktivieren, deaktivieren und löschen. Pro Runde lassen sich ein Beschreibungstext, ein Bild, Bewerbungsbedingungen als PDF und ein Zeitraum hinterlegen.
- **Für Bands:** Das Orga-Team kann den Link `/bewerbungen/{id}/form` teilen. Ist die Runde aktiv, wird das Formular angezeigt; andernfalls erscheint ein Hinweis. Der hinterlegte Zeitraum schaltet das Formular noch nicht automatisch frei oder ab.
- **Noch offen:** Das öffentliche Formular nimmt noch keine Einsendungen entgegen und speichert keine Bandbewerbungen.
- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
Unter `/` erscheint derzeit eine Wartungsseite. Die Projektstartseite liegt unter `/start`, der Orga-Login unter `/login` und die Verwaltung unter `/bewerbungen`.
Laravel is accessible, powerful, and provides tools required for large, robust applications.
## Lokal starten
## Learning Laravel
Vorausgesetzt werden PHP ab 8.2 mit PDO SQLite, Composer 2 sowie Node.js 24 mit npm. Die Anwendung nutzt Laravel 12, Blade, Bootstrap und Vite.
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
1. Dieses Repository klonen und den Branch `try_and_error` auschecken.
2. Im Projektverzeichnis eine lokale `.env` anlegen, falls noch keine existiert. Das Repository enthält derzeit keine `.env.example`. Für die lokale Einrichtung genügen diese Werte:
You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.
```dotenv
APP_ENV=local
APP_DEBUG=true
APP_URL=http://127.0.0.1:8000
DB_CONNECTION=sqlite
```
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
3. Abhängigkeiten installieren, die lokale Datenbank vorbereiten und die Anwendung starten:
## Laravel Sponsors
```sh
composer install
php artisan key:generate
touch database/database.sqlite
php artisan migrate
php artisan storage:link
npm install
npm run build
php artisan serve
```
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).
Danach ist die Anwendung unter <http://127.0.0.1:8000/start> erreichbar. `storage:link` macht hochgeladene Bilder und PDF-Dateien über die Anwendung abrufbar. Die `.env` und die lokale Datenbank gehören nicht ins Repository.
### Premium Partners
## Orga-Zugang
- **[Vehikl](https://vehikl.com)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Curotec](https://www.curotec.com/services/technologies/laravel)**
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
- **[Redberry](https://redberry.international/laravel-development)**
- **[Active Logic](https://activelogic.com)**
Es gibt keine öffentliche Registrierung und kein voreingestelltes Orga-Konto. Nach der Migration muss ein Benutzerkonto in der Datenbank vorhanden sein und ausdrücklich für die Verwaltung freigeschaltet werden. Für ein vorhandenes Konto geht das zum Beispiel über `php artisan tinker`:
## Contributing
```php
\App\Models\User::where('email', 'orga@example.org')->firstOrFail()->forceFill(['is_admin' => true])->save();
```
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
Die Beispieladresse durch die E-Mail des vorgesehenen Kontos ersetzen. Danach kann sich das Orga-Team unter `/login` anmelden. Die Standard-Testdaten sind nicht für eine bereitgestellte Instanz gedacht.
## Code of Conduct
## Tests
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
Nach der lokalen Einrichtung führt `php artisan test` die Tests aus. Sie prüfen unter anderem, dass Gäste das öffentliche Formular öffnen können, aber nur freigeschaltete Orga-Konten Bewerbungsrunden verwalten dürfen.
@@ -0,0 +1,36 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\ValidationException;
class OrgaSessionController extends Controller
{
public function store(Request $request): RedirectResponse
{
$credentials = $request->validate([
'email' => ['required', 'email', 'max:255'],
'password' => ['required', 'string'],
]);
if (! Auth::attempt($credentials + ['is_admin' => true])) {
throw ValidationException::withMessages(['email' => 'E-Mail-Adresse oder Passwort ist ungültig.']);
}
$request->session()->regenerate();
return redirect()->intended(route('bewerbungen.index'));
}
public function destroy(Request $request): RedirectResponse
{
Auth::logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return redirect()->route('login');
}
}
+1
View File
@@ -43,6 +43,7 @@ class User extends Authenticatable
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
'is_admin' => 'boolean',
];
}
}
+3 -1
View File
@@ -2,6 +2,8 @@
namespace App\Providers;
use App\Models\User;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
@@ -19,6 +21,6 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot(): void
{
//
Gate::define('manage-bewerbungen', fn (User $user): bool => $user->is_admin === true);
}
}
@@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->boolean('is_admin')->default(false);
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('is_admin');
});
}
};
+28
View File
@@ -0,0 +1,28 @@
@extends('template')
@section('title', 'Orga-Login')
@section('content')
<div class="col-md-6 mx-auto p-4">
<h1 class="h3 mb-3">Orga-Login</h1>
<form method="POST" action="{{ route('login.store') }}">
@csrf
<div class="mb-3">
<label for="email" class="form-label">E-Mail-Adresse</label>
<input id="email" name="email" type="email" class="form-control" value="{{ old('email') }}" autocomplete="username" required autofocus>
@error('email')
<p class="text-danger mt-2" role="alert">{{ $message }}</p>
@enderror
</div>
<div class="mb-3">
<label for="password" class="form-label">Passwort</label>
<input id="password" name="password" type="password" class="form-control" autocomplete="current-password" required>
@error('password')
<p class="text-danger mt-2" role="alert">{{ $message }}</p>
@enderror
</div>
<button type="submit" class="btn btn-primary">Anmelden</button>
</form>
</div>
@endsection
+6 -4
View File
@@ -9,10 +9,12 @@
<div class="d-flex justify-content-between align-items-center mb-3">
<h1 class="h3 mb-0">{{ $bewerbung->name }} Form</h1>
<div>
<a href="{{ route('bewerbungen.edit', $bewerbung->id) }}" class="btn btn-sm btn-primary">Bearbeiten</a>
<a href="{{ route('bewerbungen.index') }}" class="btn btn-sm btn-outline-secondary">Zur Liste</a>
</div>
@can('manage-bewerbungen')
<div>
<a href="{{ route('bewerbungen.edit', $bewerbung->id) }}" class="btn btn-sm btn-primary">Bearbeiten</a>
<a href="{{ route('bewerbungen.index') }}" class="btn btn-sm btn-outline-secondary">Zur Liste</a>
</div>
@endcan
</div>
<p><strong>Aktiv:</strong> {{ $bewerbung->active ? 'Ja' : 'Nein' }}</p>
@@ -9,10 +9,12 @@
<div class="d-flex justify-content-between align-items-center mb-3">
<h1 class="h3 mb-0">{{ $bewerbung->name }} Form</h1>
<div>
<a href="{{ route('bewerbungen.edit', $bewerbung->id) }}" class="btn btn-sm btn-primary">Bearbeiten</a>
<a href="{{ route('bewerbungen.index') }}" class="btn btn-sm btn-outline-secondary">Zur Liste</a>
</div>
@can('manage-bewerbungen')
<div>
<a href="{{ route('bewerbungen.edit', $bewerbung->id) }}" class="btn btn-sm btn-primary">Bearbeiten</a>
<a href="{{ route('bewerbungen.index') }}" class="btn btn-sm btn-outline-secondary">Zur Liste</a>
</div>
@endcan
</div>
<p><strong>Aktiv:</strong> {{ $bewerbung->active ? 'Ja' : 'Nein' }}</p>
+7 -1
View File
@@ -5,7 +5,13 @@
<div class="container mt-4">
<div class="d-flex justify-content-between align-items-center mb-3">
<h1 class="h3">Bewerbungen</h1>
<a href="{{ route('bewerbungen.create') }}" class="btn btn-primary">Neu</a>
<div class="d-flex gap-2">
<a href="{{ route('bewerbungen.create') }}" class="btn btn-primary">Neu</a>
<form method="POST" action="{{ route('logout') }}">
@csrf
<button type="submit" class="btn btn-outline-secondary">Abmelden</button>
</form>
</div>
</div>
@if(session('success'))
+1 -29
View File
@@ -44,7 +44,7 @@
<p class="lead">Hier findet ihr in Zukunft Infos zu Veranstaltungen, für die wir nach Bands Suchen. Zusätzlich soll in Zukunft auch die Möglichkeit entstehen eure Bands hier zu Presentieren.</p>
<div class="d-grid gap-2 d-md-flex justify-content-md-start mb-4 mb-lg-3">
<button type="button" class="btn btn-primary btn-lg px-4 me-md-2 fw-bold" data-bs-toggle="modal" data-bs-target="#signupModal">Registrieren</button>
<button type="button" class="btn btn-outline-secondary btn-lg px-4" data-bs-toggle="modal" data-bs-target="#loginModal">Zum Login</button>
<a class="btn btn-outline-secondary btn-lg px-4" href="{{ route('bewerbungen.index') }}">Zur Orga-Verwaltung</a>
</div>
</div>
<div class="col-lg-4 offset-lg-1 p-0 overflow-hidden shadow-lg">
@@ -76,34 +76,6 @@
</div>
</div>
<div class="modal fade" id="loginModal" tabindex="-1" aria-labelledby="loginModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="loginModalLabel">Login</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form id="Login" method="POST" action="./index.php">
<div class="mb-3">
<input type="text" name="user" class="form-control" placeholder="User" required>
</div>
<div class="mb-3">
<input type="password" name="pwd" class="form-control" placeholder="Password" required>
</div>
<div class="forgot">
<a href="./resetpwd.php?u=reset">Passwort Vergessen?</a>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Login</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<footer class="mt-auto">
+7 -2
View File
@@ -4,6 +4,7 @@ use Illuminate\Support\Facades\Route;
use App\Http\Controllers\BandsController;
use App\Http\Controllers\BewerbungController;
use App\Http\Controllers\OrgaSessionController;
@@ -31,9 +32,13 @@ Route::get('kontakt', function() {
// Bewerbung CRUD
Route::view('/login', 'auth.login')->name('login');
Route::post('/login', [OrgaSessionController::class, 'store'])->middleware('throttle:5,1')->name('login.store');
Route::post('/logout', [OrgaSessionController::class, 'destroy'])->middleware('auth')->name('logout');
Route::resource('bewerbungen', BewerbungController::class)
->parameters(['bewerbungen' => 'bewerbung']); // ← erzwingt {bewerbung}
->parameters(['bewerbungen' => 'bewerbung'])
->middleware(['auth', 'can:manage-bewerbungen']);
Route::get('/bewerbungen/{bewerbung}/form', [BewerbungController::class, 'form'])
->name('bewerbungen.form');
+96
View File
@@ -0,0 +1,96 @@
<?php
namespace Tests\Feature;
use App\Models\Bewerbung;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class BewerbungAccessTest extends TestCase
{
use RefreshDatabase;
public function test_guests_cannot_use_the_management_routes(): void
{
$this->withoutVite();
$round = Bewerbung::create(['name' => 'Festival', 'text' => 'Band gesucht']);
foreach ([
['GET', route('bewerbungen.index')],
['GET', route('bewerbungen.create')],
['POST', route('bewerbungen.store')],
['GET', route('bewerbungen.show', $round)],
['GET', route('bewerbungen.edit', $round)],
['PUT', route('bewerbungen.update', $round)],
['PATCH', route('bewerbungen.update', $round)],
['DELETE', route('bewerbungen.destroy', $round)],
] as [$method, $url]) {
$this->call($method, $url)->assertRedirect('/login');
}
$this->assertDatabaseCount('bewerbungen', 1);
}
public function test_public_form_is_accessible_without_an_account(): void
{
$this->withoutVite();
$round = Bewerbung::create(['name' => 'Festival', 'text' => 'Band gesucht', 'active' => true]);
$this->get(route('bewerbungen.form', $round))
->assertOk()
->assertSee('Band gesucht')
->assertSee('name="bname"', false)
->assertDontSee(route('bewerbungen.edit', $round));
$round->update(['active' => false]);
$this->get(route('bewerbungen.form', $round))
->assertOk()
->assertSee('Diese Bewerbung ist Inaktiv')
->assertDontSee('name="bname"', false);
}
public function test_regular_users_cannot_log_in_to_or_access_management(): void
{
$user = User::factory()->create();
$this->from('/login')->post('/login', ['email' => $user->email, 'password' => 'password'])
->assertRedirect('/login')
->assertSessionHasErrors('email');
$this->assertGuest();
$this->actingAs($user)->get(route('bewerbungen.create'))->assertForbidden();
$this->post(route('bewerbungen.store'), ['name' => 'Festival', 'text' => 'Band gesucht'])->assertForbidden();
$this->assertDatabaseCount('bewerbungen', 0);
}
public function test_admin_can_log_in_manage_rounds_and_log_out(): void
{
$this->withoutVite();
$admin = User::factory()->create(['is_admin' => true]);
$this->get(route('bewerbungen.create'))->assertRedirect('/login');
$this->get('/login')->assertOk();
$this->from('/login')->post('/login', ['email' => $admin->email, 'password' => 'wrong-password'])
->assertRedirect('/login')
->assertSessionHasErrors('email');
$this->assertGuest();
$this->post('/login', ['email' => $admin->email, 'password' => 'password'])
->assertRedirect(route('bewerbungen.create'));
$this->assertAuthenticatedAs($admin);
$this->get(route('bewerbungen.create'))->assertOk();
$response = $this->post(route('bewerbungen.store'), ['name' => 'Festival', 'text' => 'Band gesucht']);
$round = Bewerbung::sole();
$response->assertRedirect(route('bewerbungen.show', $round));
$this->patch(route('bewerbungen.update', $round), ['name' => 'Sommerfestival', 'text' => 'Band gesucht'])
->assertRedirect(route('bewerbungen.show', $round));
$this->assertDatabaseHas('bewerbungen', ['id' => $round->id, 'name' => 'Sommerfestival']);
$this->delete(route('bewerbungen.destroy', $round))->assertRedirect(route('bewerbungen.index'));
$this->assertDatabaseCount('bewerbungen', 0);
$this->post('/logout')->assertRedirect('/login');
$this->assertGuest();
$this->get(route('bewerbungen.create'))->assertRedirect('/login');
}
}