feat(auth): add dummy test login for local dev + update env for Herd
- Update .env.example for Herd (APP_URL, CHURCHTOOLS_REDIRECT_URI) - Add POST /dev-login route (local/testing only) - Add "Test-Anmeldung" button to Login.vue - Update UserFactory with OAuth fields (churchtools_id, avatar, groups, roles)
This commit is contained in:
parent
cffa2cea3e
commit
3a1ba1fc7d
|
|
@ -2,7 +2,7 @@ APP_NAME="CTS Presenter"
|
|||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost:8000
|
||||
APP_URL=http://cts-work.test
|
||||
|
||||
# Application Locale (German)
|
||||
APP_LOCALE=de
|
||||
|
|
@ -74,9 +74,13 @@ CTS_API_TOKEN=CHANGEME
|
|||
CHURCHTOOLS_URL=https://CHANGEME.church.tools
|
||||
CHURCHTOOLS_CLIENT_ID=CHANGEME
|
||||
CHURCHTOOLS_CLIENT_SECRET=CHANGEME
|
||||
CHURCHTOOLS_REDIRECT_URI=http://localhost:8000/auth/churchtools/callback
|
||||
CHURCHTOOLS_REDIRECT_URI=http://cts-work.test/auth/churchtools/callback
|
||||
|
||||
# File Upload Configuration
|
||||
# Maximum file size in bytes (default: 100MB)
|
||||
UPLOAD_MAX_FILE_SIZE=104857600
|
||||
UPLOAD_TEMP_DIR=/tmp
|
||||
|
||||
# TestData
|
||||
TEST_CTS_USERNAME=
|
||||
TEST_CTS_PASSWORD=
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@ class AuthController extends Controller
|
|||
*/
|
||||
public function showLogin(): Response
|
||||
{
|
||||
return Inertia::render('Auth/Login');
|
||||
return Inertia::render('Auth/Login', [
|
||||
'canDevLogin' => app()->environment('local', 'testing'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -29,6 +29,10 @@ public function definition(): array
|
|||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
'churchtools_id' => fake()->unique()->numberBetween(1000, 99999),
|
||||
'avatar' => null,
|
||||
'churchtools_groups' => [],
|
||||
'churchtools_roles' => [],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
<script setup>
|
||||
import GuestLayout from '@/Layouts/GuestLayout.vue';
|
||||
import { Head } from '@inertiajs/vue3';
|
||||
import { Head, router } from '@inertiajs/vue3';
|
||||
|
||||
defineProps({
|
||||
canDevLogin: Boolean,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
@ -25,6 +29,17 @@ import { Head } from '@inertiajs/vue3';
|
|||
</svg>
|
||||
Mit ChurchTools anmelden
|
||||
</a>
|
||||
|
||||
<button
|
||||
v-if="canDevLogin"
|
||||
@click="router.post(route('dev-login'))"
|
||||
class="inline-flex w-full items-center justify-center gap-2 rounded-md bg-amber-500 px-6 py-3 text-sm font-semibold text-white shadow-sm transition hover:bg-amber-600 focus:outline-none focus:ring-2 focus:ring-amber-500 focus:ring-offset-2"
|
||||
>
|
||||
<svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4" />
|
||||
</svg>
|
||||
Test-Anmeldung
|
||||
</button>
|
||||
</div>
|
||||
</GuestLayout>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
use App\Http\Controllers\TranslationController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Inertia\Inertia;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
Route::middleware('guest')->group(function () {
|
||||
Route::get('/login', [AuthController::class, 'showLogin'])->name('login');
|
||||
|
|
@ -16,6 +17,26 @@
|
|||
Route::get('/auth/churchtools/callback', [AuthController::class, 'callback'])->name('auth.churchtools.callback');
|
||||
});
|
||||
|
||||
if (app()->environment('local', 'testing')) {
|
||||
Route::middleware('guest')->group(function () {
|
||||
Route::post('/dev-login', function () {
|
||||
$user = \App\Models\User::updateOrCreate(
|
||||
['email' => 'test@local.dev'],
|
||||
[
|
||||
'name' => 'Test Benutzer',
|
||||
'churchtools_id' => 99999,
|
||||
'password' => '',
|
||||
'avatar' => null,
|
||||
'churchtools_groups' => [],
|
||||
'churchtools_roles' => [],
|
||||
]
|
||||
);
|
||||
Auth::login($user);
|
||||
return redirect()->route('dashboard');
|
||||
})->name('dev-login');
|
||||
});
|
||||
}
|
||||
|
||||
Route::post('/logout', [AuthController::class, 'logout'])
|
||||
->middleware('auth')
|
||||
->name('logout');
|
||||
|
|
|
|||
Loading…
Reference in a new issue